Yosemite+ 启用apache、php
参考链接: https://discussions.apple.com/docs/DOC-3083
PHP is not enabled in recent versions of OS X. To enable it, do:
1 | sudo vi /etc/apache2/httpd.conf |
Uncomment the following lines:
1 | #LoadModule php5_module libexec/apache2/libphp5.so |
继续修改配置
1 | sudo vi /etc/apache2/extra/httpd-userdir.conf |
Uncomment the following lines:
1 | #Include /private/etc/apache2/users/*.conf |
While you are in /etc/apache2, double-check to make sure you have a user config file. It should exist at the path: /etc/apache2/users/
1 | sudo vi /etc/apache2/users/<your short user name>.conf |
1 | "/Users/<your short user name>/Sites/"> |
重启apache
1 | sudo apachectl restart |
My site works
Now try PHP. Create a PHP info file with:
1 | echo "echo phpinfo(); " > ~/Sites/info.php |
And test it by entering the following into Safari’s address bar:
1 | http://<your local host>/~<your short user name>/info.php |