1. Start the server
macbook-air:~ wgyp$ sudo apachectl start
Password:
macbook-air:~ wgyp$ sudo apachectl-v
Server version:apache/2.2.26 (Unix)
Server Built:dec 10 2013 22:09:38
2. enter http://localhost in the browser and the IT works! will appear The page
Note: If the IT works! does not appear Enter 127.0.0.1 in the browser, if it appears, the host binding is wrong.
3. Open in/etc/apache2/httpd.conf with VI
LoadModule Php5_module libexec/apache2/libphp5.so
The comment code, with: w save,: Q Exit Edit.
note: The ReadOnly permission appears, you can right-click on the file and choose Introduction (Get Info) share permission (shareing& permissions) Open Select the small lock in the lower right corner. You can edit the file read and write permissions.
4. Restart Apache, the terminal input sudo apachectl restart php can be used.
5. edit php file. Copy the file/library/webserver/documents/index.html.en, rename info.php, modify the content to <?php phpinfo ();? >
6. Restart the Apache server and enter http://localhost/info.php in the browser. You can see the effect.
note: If you press to appear: <?php phpinfo ();?> is the third step is not done.
7.documentroot,apache default read-in root change.
macbook-air:~ wgyp$ open/etc/apache2/
has just changed the read and write permissions of httpd.conf. Find DocumentRoot, change/library/webserver/documents all to the folder you want to point to, and enter sudo apachectl restart on the terminal . Then just write the code in the folder you point to, and you can preview it by typing the localhost+ file name in the browser.
PHP Environment setup under Mac