Thursday 28 July 2011 10:17:37 am
Recently, Apple release a new Mac OSX version named Lion. There are a lot of new stuff, but for this tutorial, we'll see some updates for Apache and Php version. Macport will not be necessary to configure your AMP service.
This article is available in french at http://www.pheelit.fr/HighTech/Developpement/Installation-Apache-PHP-Mysql-sur-Mac-OS-X-Lion
You could check your apache version typing :
Edit /etc/apache2/httpd.conf. (You need probably to use root rights). Find line
LoadModule php5_module libexec/apache2/libphp5.so
and check that # is correctly remove. Same for the line
(this ll enable custom directory outside your www folder)
Save and restart apache service :
sudo apachectl restart
With your favorite browser check http://localhost if you obtain "It's work" message.
I decide to change User and Group for Apache on http.conf file with my current login and staff group :)
Download from http://dev.mysql.com/downloads/mysql , Mac OS X ver. 10.6 (x86, 64-bit), DMG Archive.
Installation order is really simple :
To run MySQL, go to System Settings and you ll have a new prefpane named MySQL. Just open it and clic on start server.
Check if MySQL run properly :
Just a tip is, edit your ~/.bash_profile and add
Reload bash profile via
Last step with MySQL is to secure installation. Just type :
First step download it from http://www.phpmyadmin.net/home_page/downloads.php, and extract it on ~/Sites
sudo mkdir /var/mysql sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
to prevent error code 2000, then
mkdir ~/Sites/phpmyadmin/config chmod o+w ~/Sites/phpmyadmin/config
With your browser run http://localhost/~username/phpmyadmin/setup/ . Click on button "new server" then "Authentication" tab and fll "Password for config auth" field. Save twice : one on this page and one on the other page. Try your config on page http://localhost/~username/phpmyadmin/
Mcrypt isn't install by default on Mac OS X Lion, you need to do it. So download libmcrypt on http://sourceforge.net/project/showfiles.php?group_id=87941 .
You need to download php source file. Normally you have php version 5.3.6. So download it from http://us.php.net/get/php-5.3.6.tar.gz/from/a/mirror
You need to have Xcode 4.1 to compile source code. You could download it from free on Mac App Store.
Note : i moved and extract files on /usr/local/src/
Unzip files and place yourself on libmcrypt folder. Run command line :
MACOSX_DEPLOYMENT_TARGET=10.7 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --disable-dependency-tracking make -j6 sudo make install
Run command line on php-5.3.6/ext/mcrypt
/usr/bin/phpize MACOSX_DEPLOYMENT_TARGET=10.7 CFLAGS='-O3 -fno-common -arch i386 -arch x86_64' LDFLAGS='-O3 -arch i386 -arch x86_64' CXXFLAGS='-O3 -fno-common -arch i386 -arch x86_64' ./configure --with-php-config=/Developer/SDKs/MacOSX10.7.sdk/usr/bin/php-config make -j6 sudo make install
If php file not exists :
sudo cp /etc/php.ini.default /etc/php.ini
Some modification to do on this file :
memory_limit = 256M display_errors = On html_errors = On enable_dl = On
Don't remove semicolon on ;extension_dir = "./"
And check your phpinfo page if you see correctly mcrypt library.
Apple already installed xdebug. So to enable it just remove semicolon on line:
on /etc/php.ini file.
For unknown reasons, Apple has not installed it by default. To fix this problem, go on /usr/lib/php and type
sudo php install-pear-nozlib.phar
edit your php.ini and replace line ;include_path = ".:/php/includes" by include_path = ".:/usr/lib/php/pear"
sudo pear channel-update pear.php.net sudo pecl channel-update pecl.php.net sudo pear upgrade-all
now you could install phpunits, zeta components, etc :)
Just edit /etc/apapche2/httpd.conf and in end on file add
NameVirtualHost *:80 Include /private/etc/apache2/other/*.conf
Just create your vhost on /private/etc/apache2/other/
That's all :)