0
votes

I'm running a MacPro G5 w/ 10.5.8. I ran: sudo port selfupdate and then ran: sudo port upgrade outdated When it was all finished, I rebooted and apache2 was broken and would not serve PHP file any longer. If I replace the httpd.conf file, it will serve html files. I finally gave up and restored the backup and the machine is running again. The problem is I have a second machine that I did the same thing on and don't want to go through the same process. I've read several posts about uninstalling/reinstalling Macports like this one from Kirk Roybal How to do a clean reinstall with macports?, but it doesn't say if this process will destroy or reset the contents of the /opt/local/ directory. Especially the MySQL DBs and htdocs contents. Does anyone know if this process is linked or destructive? I'll make backups of everything, of course, before trying anything.

SOLUTION: I got it to work by making the php53 install work instead of going backwards. Here's what I did:

sudo port select --set php php53 (set MacPorts to use php53 instead of php5)

sudo port installed (Check to make sure php53-apache2handler is installed)

sudo port install php53-apache2handler (It wasn't and yours probably isn't either)

once that's done installing

php -v (check the version of PHP that's running)

cd /opt/local/apache2/modules

sudo /opt/local/apache2/bin/apxs -a -e -n php mod_php53.so (activates php within apache)

this should append

LoadModule php5_module modules/mod_php53.so

to your /opt/local/apache2/conf/httpd.conf file (check it now)

There will also be a line like this

LoadModule php5_module modules/mod_php5.so

Comment it out or remove it so is doesn't interfere with new install

It should also move a copy of mod_php53.so to

/opt/local/apache2/modules

If it's not there, see php53-apache2handler install above.

Check your httpd.conf file for errors

/opt/local/apache2/bin/httpd -S

Finally, create/edit php.ini file to tell apache2 how to connect to MySQL database

cd /opt/local/etc/php53

sudo cp php.ini-production php.ini (for production machine use development for dev machine)

sudo cp php.ini php.ini.bak

Add the default socket paths to php.ini

pdo_mysql.default_socket=/opt/local/var/run/mysql5/mysqld.sock (may vary based on MySQL version. Check the /opt/local/var/run directory if not sure)

mysql.default_socket=/opt/local/var/run/mysql5/mysqld.sock

mysqli.default_socket=/opt/local/var/run/mysql5/mysqld.sock

If you are having problems connecting to MySQL, check for typos in the above paths FIRST. Trust me it will save you tons of time! If all went according to plan, you should be able to restart the machine, test to make sure all ports started automatically and things should be working.

1
You might have had php5 installed, but it is deprecated and was recently automatically migrated to php53. However, you need to adjust your Apache configuration file if you want this to continue working. Alternatively, you can also get newer PHP versions in the other php5x ports. For mod_php, you need php5x-apache2handler.neverpanic
Turns out I was asking the wrong question. @neverpanic insight about php5 being deprecated made me realize I didn't need to reinstall the old, but figure out how to make the php53 install work.Tony J Miller

1 Answers

0
votes

The files that you add (eg: MySQL DBs) are not destroyed by an update. If you modify files that are managed by MacPorts (eg: they are listed in 'port contents '), then those modifications will be clobbered by an update.

Some projects install config files as examples and have the user make the real config file so as to not clobber it with an update. It looks like the apache2 port follows this pattern. It installs /opt/local/apache2/conf/original/httpd.conf and then copies it to the real location of /opt/local/apache2/conf/httpd.conf at activation time only if the file does not exist.