The following will make your Mac like a web-server by Installing Apache, PHP, and MySQL on Mac OS X 10.11 El Capitan.
This post work correctly on the Particular El Capitan only.
Run Commands with Root permission
Launch Terminal ̣̣̣(Found in Application folder), then enter the following command line
sudo su -
Enable Apache on Mac OS X 10.11
Use the following command line
You can access the following url to make sure it works: http://localhost
Activate PHP for Apache
- Edit the Apache configuration with “vi” by the following
- The move the # in font of the following line
LoadModule php5_module libexec/apache2/libphp5.so
- Restart Apache by the following command line
How to check if the PHP does work on your El Capitan?
Firstly, create a phpinfo.php into DocumentRoot (/Library/WebServer/Documents)
echo ‘<?php phpinfo();’ > /Library/WebServer/Documents/phpinfo.php
Then, you can access the following url if the PHP working: http://localhost/phpinfo.php
Steps to Install MySQL on Mac OS X El Capitan
Download then install MySQL.DMG for Mac from this official page: http://dev.mysql.com/downloads/mysql/
The README recommend creating aliases for mysql and mysqladmin. However there are other commands that are helpful such as mysqldump. Instead, you can update your path to include /usr/local/mysql/bin.
Note: To run the above command lines for your path to update, you will have to open a new Terminal windows.
If you need to do something else complicated to secure your Database, you should run mysql_secure_installation.
How to Connect PHP and MySQL
Enter the following command lines.
ln -s /tmp/mysql.sock mysql.sock
Leave your comments if having further information. Cheers!