问题
i'm your average college student interested in using PHP. Could anyone give me a 101 on how to install/enable it on a mac version 10.7.2 using simple, plain language? I will appreciate any and all help!!
Cheers
回答1:
No Need to Install PHP or Apache, They already ship with Mac 10.7
These are the basic steps you need to take for PHP and Apache to work together:
- Enable PHP in you httpd.conf file located - /etc/apache2/httpd.conf
- Setup your php.ini - sudo cp /etc/php.ini.default /etc/php.ini
- Enable the Apache web server located in the Sharing > Web Sharing
Enable PHP in Apache
Find this setting in your httpd.conf file
#LoadModule php5_module libexec/apache2/libphp5.so
And, uncomment it like
LoadModule php5_module libexec/apache2/libphp5.so
This guide explains setting up MySQL and VirtualHost on Mac. I have been using this setup for over six months. Also, worked on the 10.7 early releases just fine. http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/
Shell Commands to Start and Stop Apache on Mac
Start Apache
sudo apachectl start
Restart Apache
sudo apachectl restart
(edited to remove typo in restart command)
回答2:
PHP5 should be already installed, it's just disabled. Open the Apache config file with a text editor it's at /private/etc/apache2/httpd.conf
Now find the line which reads: "#LoadModule php5_module libexec/apache2/libphp5.so" and delete the comment (hash) from the beginning of the line and save the file (you'll need admin permissions to do this)
Now restart Apache - from the Terminal app type: sudo apachectl graceful It will ask for your admin password
PHP should now be working..
来源:https://stackoverflow.com/questions/8440948/how-to-install-use-php-on-mac-v-10-7-2