PHP: Difference between revisions

From Cheatsheet
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by the same user not shown)
Line 28: Line 28:


copy the whole line and if you are doing php4 change the 5 to 4's and vice versa, but dont have any duplicate options.
copy the whole line and if you are doing php4 change the 5 to 4's and vice versa, but dont have any duplicate options.
== Using a Custom / Local php.ini with FCGI on cPanel ==
Confirm they are using fcgi by using /usr/local/cpanel/bin/rebuild_phpconf --current
cd /home/USERNAME/public_html/cgi-bin/
cp /usr/local/lib/php.ini .
At this point, edit the new php.ini and make the required changes, save.
echo -en "#!/bin/sh\nexport PHP_FCGI_CHILDREN=1\nexport PHP_FCGI_MAX_REQUESTS=10\nexec /usr/local/cpanel/cgi-sys/php5" > php.fcgi , if this command doesn't work just manually create the file php.fcgi.
Then add:
#!/bin/sh
export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=10
exec /usr/local/cpanel/cgi-sys/php5
After that proceed with the rest....
chmod 0755 php.fcgi
chown USERNAME:USERNAME php.*
cd ../
Now, add the following to the .htaccess in public_html/.htaccess
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php.fcgi


== Random PHP stuffs ==
== Random PHP stuffs ==

Latest revision as of 01:08, 29 August 2015

PHP FOO, Enjoy ;P


PHP info

Make a file called phpinfo.php under the account that you wish to test. Place the below in as the contents.

<?php phpinfo(); ?>

One liner PHP info, make sure to change (username here) ti the account in questions username.

touch phpinfo.php && chown (username here). phpinfo.php && echo "<?php phpinfo(); ?>" > phpinfo.php

A real one liner, that requires no edits copy pasta go!

for i in `pwd | cut -d/ -f3`; do touch /home/$i/public_html/phpinfo.php && chown $i. /home/$i/public_html/phpinfo.php && echo "<?php phpinfo(); ?>" > /home/$i/public_html/phpinfo.php; done

PHP version's

To test the current handler as well as the versions of php.

/usr/local/cpanel/bin/rebuild_phpconf --current

If EasyApache has never been ran you will need to fo a manual query to figure the relavent information out.

cat /usr/local/apache/conf/httpd.conf | grep  LoadModule | grep php

Setting the default PHP version in the .htaccess

vim /usr/local/apache/conf/php.conf

go to the following and you want to copy out the line starting with "AddType" will look something like this but might be different...

AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml

copy the whole line and if you are doing php4 change the 5 to 4's and vice versa, but dont have any duplicate options.

Using a Custom / Local php.ini with FCGI on cPanel

Confirm they are using fcgi by using /usr/local/cpanel/bin/rebuild_phpconf --current

cd /home/USERNAME/public_html/cgi-bin/
cp /usr/local/lib/php.ini .

At this point, edit the new php.ini and make the required changes, save.

echo -en "#!/bin/sh\nexport PHP_FCGI_CHILDREN=1\nexport PHP_FCGI_MAX_REQUESTS=10\nexec /usr/local/cpanel/cgi-sys/php5" > php.fcgi , if this command doesn't work just manually create the file php.fcgi.

Then add:

#!/bin/sh
export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=10
exec /usr/local/cpanel/cgi-sys/php5

After that proceed with the rest....

chmod 0755 php.fcgi
chown USERNAME:USERNAME php.*
cd ../

Now, add the following to the .htaccess in public_html/.htaccess

AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php.fcgi


Random PHP stuffs

PHP 4 module check

/usr/local/php4/bin/php

enable/disable monitoring script ---

wget http://scripts.ssullivan.org/apiCalls/confMonitoring
perl confMonitoring

PhP mem limit on a shared with dso goes into the public_html in the .htaccess

php_value memory_limit 64M

To veiw availiable php extensions

/scripts/phpextensionmgr list

To install php extensions

/scripts/phpextensionmgr install (name here)

PHP rpm's for coremanaged moxes. php rpms

PHPmyadmin

To update just phpmyadmin.

/usr/local/cpanel/bin/updatephpmyadmin --force