Under Tiger I had WordPress installed with PHP 5 (an installation from Entropy.ch) and MySQL 5 (from the MySQL web site). After upgrading to Leopard, my configuration went sour. Here's the behavior I was seeing:
If I requested http://localhost (or http://127.0.0.1) in Safari I would correctly get the page confirming Apache was configured correctly. However, if I requested any of my previously created web sites in my Sites directory (or even my default page http://localhost/~smcandrew), I would get a Forbidden message. It sounded like a permissions error, but that wasn't what turned out to be the problem. It turned out to be a handful of easy to fix configuration settings.
Here's what I did to get everything back on track.
ENABLING LEOPARD'S PHP 5 ENVIRONMENT
PHP 5 installs with Leopard. The problem: it's disabled by default.
* Note that Apache's .conf file has been moved to a new location (it used to be at /private/etc/httpd/httpd.conf and is now located at /private/etc/apache2/httpd.conf).
* Open the httpd.conf file located at /private/etc/apache2/httpd.conf with your text editor of choice and find the following line:
# LoadModule php5_module libexec/apache2/libphp5.so
Uncomment the line, changing it to:
LoadModule php5_module libexec/apache2/libphp5.so
* If you use virtual hosting, find the following line:
# Include /private/etc/apache2/extra/httpd-vhosts.conf
Uncomment the line, changing it to:
Include /private/etc/apache2/extra/httpd-vhosts.conf * Save the file
As a side note, if you are using virtual hosts, you may need to go set them up as you had before in your virtual hosts file (/private/etc/apache2/extra/httpd-vhosts.conf). The Upgrade of Leopard did not modify my virtual hosts, but if you find yourself having issues this is where you should look next.
RELOCATE YOUR .CONF FILE
In Apache 2.2 the .conf file for your user is stored in a new location. It's easy enough to move it.
* The old location of your .conf file is /etc/httpd/users/[yourUserName].conf
* The location it needs to be in for Apache 2.2 is /etc/apache2/users/[yourUserName].conf
* To move the file:
Open Terminal and type the following command inserting your user name where I have 'smcandrew' (my user name):
cp /etc/httpd/users/smcandrew.conf /etc/apache2/users/smcandrew.conf
BE SURE YOUR .CONF FILE HAS WHAT IT NEEDS FOR WORDPRESS
My .conf file got lost in the shuffle when I upgraded. I'm not sure if this was due to my plodding around or if it was a victim of the Leopard upgrade. I had saved an older version of my .conf file and used the same settings it had in the new .conf file and everything was fine. To check your .conf file:
* With your favorite text editor, open your .conf file from the following directory (as mentioned above, yours will be called [yourUserName].conf):
/etc/apache2/users/
* I had a stock .conf file (I'm assuming it was created during the upgrade). So, I changed the text in the .conf file to read:
Options Indexes MultiViews FollowSymLinks AllowOverride All Order allow,deny Allow from all
Again, exchange 'smcandrew' for your user name * Save the file
WHERE'S MY MYSQL SOCKET?
During the Leopard upgrade it looks as though Tiger's MySQL setup wasn't mucked with at all. But, the location of the MySQL socket isn't where it was in Tiger. So, I had to modify my php.ini file.
* Open up any text editor you like and open:
/private/etc/php.ini
* Find the line that reads:
mysql.default_socket =
and change it to:
mysql.default_socket = /private/tmp/mysql.sock
* Find the line that reads:
mysqli.default_socket =
and change it to:
mysqli.default_socket = /private/tmp/mysql.sock * Save the php.ini file
Note: if you have no php.ini file in the aforementioned directory, you should have a 'php.ini.default' file. Make a copy of this file, naming it php.ini, then execute the steps above.
RESTART APACHE AND PHP AND GET STARTED!
If your upgrade woes were the same as mine, everything should be back on track now. You can restart Apache, which will enable your new PHP settings. If you like Terminal, you likely already know the command (sudo apachectl restart). If you prefer not to use Terminal, you can open System Preferences > Sharing and uncheck the check beside "Web Sharing." Then, check it again to restart.
That's it. Things should be back up and running. Hope this helps!
Thursday, December 13, 2007
How I fixed PHP and MySQL for WordPress after upgrading to Leopard
Labels: NEWS
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment