Installing php 5.3, apache2 and MySQL 5 on OS X using Macports
Par NiKo le vendredi 17 juillet 2009, 14:40 - Libritudes
- Lien permanent -
11 commentaires -
Tags :
I wanted to test latest php 5.3 on my OSX box. So here’s a quick reminder on how to proceed to a full setup of apache2, mysql5 and php 5.3 using Macports.
First, get a fresh copy of the Macports installer for OSX. Install macports, then in a shell prompt, type:
$ sudo port install mysql5 +server $ sudo port install php5 +apache2 +debug +pear +sqlite +mysql5
You have now the time to have lunch, dinner, sex or to watch an episode of Derrick[1].
To enable the php module for apache:
$ cd /opt/local/apache2/modules $ sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
Then, add this line in the /opt/local/apache2/conf/httpd.conf file:
Include conf/extras-conf/*.conf
Copy one of the standard php.ini files proposed by the default installation:
$ sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php5/php.ini
To start apache automatically at system startup:
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist
Or manually:
$ sudo /opt/local/apache2/bin/apachectl start
To initialize, configure and start MySQL automatically:
$ sudo -u mysql mysql_install_db5 $ sudo /opt/local/bin/mysql_secure_installation5 $ sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start $ sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
Now launch your browser at http://localhost/: you’re done. Have some rest.
Notes
[1] Don’t try to do all that stuff at the same time, result cannot be guaranteed
11 commentaires (Ajouter un commentaire)
If you already used macports, you must update it. When I used "sudo port install php5", macports installed php 5.2.8.
If you want to install php 5.3, don't forget to update macports :
$ sudo port selfupdate
Thanks for your answer FABD but finally my problem is fixed thanks to a friend of mine. I didn't apply the 755 mode at the root directory of my web projects and missed one step in the configuration...
HUGO > Perhaps you've forgot the directive : "NameVirtualHost". Add it in your "httpd-vhost.conf" file like that :
NameVirtualHost *:80
<VirtualHost *:80>
...
</VirtualHost>
@N1K0 that does not work... This is what I've done :
# In httpd-vhosts.conf
<VirtualHost *:80>
ServerName toto
DocumentRoot "/Users/Hugo/Sites/toto"
DirectoryIndex index.php index.html index.htm
<Directory "/Users/Hugo/Sites/toto">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Then I created a "toto" and "index.php" files, chown both files with www and www and finally restarted my apache. I still have the same 403 error. Forbidden access to my index.php whereas I can access the localhost uri...
I don't know where is the problem...
Hugo> Try to chown www:www your file
Thanks for this tutorial N1K0. Apache 2 and PHP 5.3.0 are correctly installed on my macbook and everything is fine when I access localhost uri. But all my previous vhosts do not work now though I copied my previous vhosts configuration in the httpd-vhosts.conf file and added the Include in the httpd.conf file...
@Niko : ok, thanks for the information for macports
Variant @debug@ ? wtf ?
For MySQL Server installation, I remember that using "mysql5 +server" is the old manner (not deprecated ?), instead, you can used "mysql5-server" port.
Nico> Because at the time you tweeted me the link, it was down.
Ports puts everything under
/opt/localand allows you to define executable location precedence by setting your$PATHenvironment variable. Nothing intrusive here to me.So far I tried to avoid using macports. I see it as somewhat "intrusive" and fear some conflits with OSX bundled one (I may be wrong, I did not take a lot of time to evaluate macports).
Why not juste use the PHP 5.3 package from entropy.ch (I used the 5.2.9 package without troubles for the few php code I make).
http://www.entropy.ch/software/maco...
This way, you can still use the Apache bundled with OSX.