Control PHP Error Logging From .htaccess
Here’s a great article: http://perishablepress.com/advanced-php-error-handling-via-htaccess/ It covers all the different options for PHP logging from .htaccess.
Here’s a great article: http://perishablepress.com/advanced-php-error-handling-via-htaccess/ It covers all the different options for PHP logging from .htaccess.
It’s easy to upgrade between PHP version is you’re using the IUS repository: http://iuscommunity.org Start by determining which version and modules you have already installed:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
[root@acme ~]# yum list | grep php | grep installed php52.x86_64 5.2.17-1.ius.el5 installed php52-bcmath.x86_64 5.2.17-1.ius.el5 installed php52-cli.x86_64 5.2.17-1.ius.el5 installed php52-common.x86_64 5.2.17-1.ius.el5 installed php52-devel.x86_64 5.2.17-1.ius.el5 installed php52-gd.x86_64 5.2.17-1.ius.el5 installed php52-imap.x86_64 5.2.17-1.ius.el5 installed php52-ioncube-loader.x86_64 4.0.8-1.ius.el5 installed php52-ioncube-loader-debuginfo.x86_64 4.0.8-1.ius.el5 installed php52-ldap.x86_64 5.2.17-1.ius.el5 installed php52-mbstring.x86_64 5.2.17-1.ius.el5 installed php52-mysql.x86_64 5.2.17-1.ius.el5 installed php52-ncurses.x86_64 5.2.17-1.ius.el5 installed php52-pdo.x86_64 5.2.17-1.ius.el5 installed php52-pear.noarch 1:1.9.2-1.ius.el5 installed php52-xml.x86_64 5.2.17-1.ius.el5 installed php52-xmlrpc.x86_64 5.2.17-1.ius.el5 installed |
So in this case we have the “php52” packages. Next decide which package set you want to upgrade to. Right no in IUS the choices are: php52 php53u php54 IUS provides a great extension for yum which allows for replacing packages:
|
1 2 3 |
yum install yum-plugin-replace |
Now you can replace the PHP version with something like this:
|
1 2 3 |
yum replace php52 --replace-with php53 |
Just change php52 and php53 to the original and new version that you want to replace. After the install completes run “yum list | grep php | grep installed” again and make sure that you have all the extensions that you need.
For a server using Plesk add the following lines to a .htaccess file to stop execution of PHP scripts in the folder:
|
1 2 3 4 5 |
RemoveHandler .php .phtml .php3 RemoveType .php .phtml .php3 php_flag engine off |
I like to use this to protect cache and image upload folders that are writable by the web server but should not be able to execute code. As a further precaution, chown the .htaccess to root, so it can’t be overwritten by Apache or FTP, and “chattr +i” to be sure about it.
Here’s a basic loop in Bash:
|
1 2 3 4 5 6 7 8 |
SERVERS="s1 s2 s3 s4" for S in $SERVERS do echo "Server: $S" # ... do something ... done |
Notice that it iterates over a space delimited string of values. If you have a comma delimited list then you can do something like this:
|
1 2 3 4 5 6 7 8 9 10 11 |
SERVERS="s1,s2,s3,s4" OLDIFS=$IFS IFS=',' for S in $SERVERS do echo "Server: $S" # ... do something ... done IFS=$OLDIFS |
IFS is the “internal field separator” which defaults to a blank space. We save the original IFS and change it to a comma. Then once we’re done we restore the original IFS. Here are some links to additional examples: http://www.cyberciti.biz/faq/bash-for-loop/ http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-7.html http://www.thegeekstuff.com/2011/07/bash-for-loop-examples/
There are two common causes to this error: 1. You have an actual syntax error in you code that needs to be fixed. 2. Your code is expecting the PHP “short_open_tags” setting to be turned on and it is not. This second case is common when you’re moving a site between servers – the old server has short_open_tags turned on and the code works but the new site has it turned off and the code breaks. The solution to the second case is to either (a) modify the code to remove the dependency on short_open_tags or (b) turn on short_open_tags in php.ini or your .htaccess file.
Reliable Penguin provides managed web hosting, systems administration, website and server migrations, and expert consulting.
Submit the form—or for immediate service call 866-649-7984.