If you want to enable custom php.ini settings for PHP FCGI on your server then follow the below steps :
root@server[#] cd /home/username/public_html
root@server[/home/username/public_html]# vi info.php
Add the below lines :
< ?php
phpinfo();
?>
save and quit.
Change the ownership of info.php file to user:user
root@server[/home/username/public_html]# chown username:username info.php
Now browse the URL : http://domain.com/info.php
And search for the line : Loaded Configuration File
Loaded Configuration File /home/username/public_html/cgi-bin/php.ini
Or
Here's a simpler solution:
Edit the file called /usr/local/cpanel/cgi-sys/php5 -- insert the line above exec /usr/bin/php as follows:
Copy the file over to /var/cpanel/conf/apache/wrappers/php5 as indicated at the top of the file.
Now, if any account has a php.ini file in their home directory (not public_html) then it will be used instead of the system-provided one.
1 > Create a .htaccess file under the directory : /home/username/public_html
root@server[#] cd /home/username/public_html
root@server[/home/username/public_html]# vi .htaccess
And the below two lines at the top :
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php.fcgi
save and quit.
2 > go to the cgi-bin directory : /home/username/public_html/cgi-bin
root@server[#] cd /home/username/public-html/cgi-bin
and then copy the default php.ini here
root@server[#] cp /usr/local/lib/php.ini /home/username/public_html/cgi-bin/
3 > Create php.fcgi file to load custom php.ini
Please note that you should still be in /home/username/public_html/cgi-bin location.
root@server[/home/username/public_html/cgi-bin] # vi php.fcgi
and then add the below code :
#!/bin/sh
export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=10
exec /usr/local/cpanel/cgi-sys/php5
save and quit.
Now make the file php.cgi executable:
root@server[/home/username/public_html/cgi-bin] # chmod + x php.fcgi
4 > Change ownership of files to correct user:And if it still does not work for you then follow the below steps as well :
root@server[/home/username/public_html/cgi-bin] chown username.username * -R
5 > Add paths to php.conf file
root@server[#] vi /usr/local/apache/conf/php.conf
and add the below lines :
Action php5-fastcgi /cgi-bin/php.fcgi
AddType application/x-httpd-php .php
save and quit.
and after adding the above two lines the php.conf file should look like this :
root@server[/usr/local/apache/conf] # cat php.conf
# Fastcgi configuration for PHP5
LoadModule fcgid_module modules/mod_fcgid.so
MaxRequestsPerProcess 500
AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml
Action php5-fastcgi /cgi-bin/php.fcgi
AddType application/x-httpd-php .php
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php5
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php4
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php3
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php2
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .phtml
# End of autogenerated PHP configuration.
6 > Distill and rebuild Apache, then restart ApacheAnd finally to test if the custom php.ini is working follow the steps :
root@server[#] /usr/local/cpanel/bin/apache_conf_distiller –update
root@server[#] /scripts/rebuildhttpdconf
root@server[#] /etc/init.d/httpd restart
root@server[#] cd /home/username/public_html
root@server[/home/username/public_html]# vi info.php
Add the below lines :
< ?php
phpinfo();
?>
save and quit.
Change the ownership of info.php file to user:user
root@server[/home/username/public_html]# chown username:username info.php
Now browse the URL : http://domain.com/info.php
And search for the line : Loaded Configuration File
Loaded Configuration File /home/username/public_html/cgi-bin/php.ini
Or
Here's a simpler solution:
Edit the file called /usr/local/cpanel/cgi-sys/php5 -- insert the line above exec /usr/bin/php as follows:
Code:
#!/bin/sh # If you customize the contents of this wrapper script, place # a copy at /var/cpanel/conf/apache/wrappers/php5 # so that it will be reinstalled when Apache is updated or the # PHP handler configuration is changed [ -f ~/php.ini ] && exec /usr/bin/php -c ~/ exec /usr/bin/php
Copy the file over to /var/cpanel/conf/apache/wrappers/php5 as indicated at the top of the file.
Now, if any account has a php.ini file in their home directory (not public_html) then it will be used instead of the system-provided one.
Không có nhận xét nào:
Đăng nhận xét