My server uses Ubuntu with PHP5 and NginX.
I have installed pear using sudo apt-get install php-pear
, and later uninstalled it using sudo pear uninstall pear
. Today I downloaded phpmailer using sudo apt-get install libphp-phpmailer
.
I wrote code to send email with phpmailer. It begins with:
require_once("class.phpmailer.php");
and I edit the php.ini
both in /etc/php5/cli
and in /etc/php5/fpm
to set:
include_path = ".:/usr/share/php/libphp-phpmailer"
It did work well if I execute this php program in command line, but if I visit this php page through my browser, it produce a HTML500 error, and I checked the error.log
file, which shows:
PHP message: PHP Fatal error: require_once():
Failed opening required 'class.phpmailer.php'
(include_path='.:/usr/share/php:/usr/share/pear') in ...
I wander how comes this path? I am sure I have edited the include_path
in both php.ini files. Is there another configuration file I missed? Where does the string ".:/usr/share/php:/usr/share/pear"
come from?
If you are absolutely sure all paths are correct then it could be a file permission issue.
nginx
. Run groups nginx
and the output should be nginx : nginx
, meaning the user nginx exists, and has only one group, which is also nginx.class.phpmailer.php
and run ls -l
to view the permissions of the files in that directory. Example output would be: -rw-r--r-- 1 someuser somegroup
, meaning read and write access is granted to the owner (someuser), read access for the group (somegroup), and read access to everybody else.If you need further explanation of how to do any of this just give me a shout and I will update this with further instructions.