/private/etc/apache2/httpd.conf First, start Apache
sudo apachectl start
sudo apachectl-v can view version information for Apache
When you enter http://localhost in the browser, the IT works! appears The page
sudo apachectl restart restart Apache
Second, run PHP
1, find the Apache configuration file, in the directory/etc/apache2/, open Finder, select "Go"-"Go to Folder", enter "/etc/apache2/", find the "httpd.conf" file, choose to open with the document to edit, Tap command+f, search #loadmodule php5_module libexec/apache2/libphp5.so,
The Blue Line of the # is removed, and then saved, if there is a text lock, unable to unlock the situation, there are two ways to solve
A) Select the file, right-click after selecting "Show Info", click on the lower right corner of the small lock icon, enter the computer password to unlock, and then select the left of the + sign key, select their current computer login user, set the permissions to read and write, if still not, will be the same level folder permissions again modified once.
b) Copy the file to the desktop, modify it, and then copy it to the original folder to replace the previous file.
2. Restart Apache at terminal input sudo apachectl restart
3. Enter sudo cp/library/webserver/documents/index.html.en/library/webserver/documents/info.php in the terminal
That is, copy the Index.html.en file and rename it to info.php in the root directory of Apache.
4. Open info.php, add <?php phpinfo () after it works, and then restart Apache again, enter http://localhost/info.php in the browser, and a page will appear with PHP information.
when configuring Apache under MacForbidden
You don't have permission to access/hellomac.htm on this server.
OS x After upgrading to Yosemite, the self-brought Apache has also been upgraded from 2.2 to 2.4, and the access rights are configured differently.
To configure the Alise alias directory as an example, /Users/redraiment/workspace/
map to the http://localhost/workspace/
following configuration information in version 2.2:
<ifmodule alias_module> Alias/workspace "/users/redraiment/workspace/" <Directory "/ users/redraiment/workspace/"> allowoverride All options Indexes multiviews followsymlinks execcgi order allow,deny allow from all directoryindex index.html index.php </directory></IFMODULE>
after upgrading to version 2.4: Order allow,deny
and Allow from all
to change Require all granted
, as follows:
<IfModule alias_module> Alias /workspace "/Users/redraiment/workspace/" <Directory "/Users/redraiment/workspace/"> AllowOverride All Options Indexes MultiViews FollowSymLinks ExecCGI Require all granted DirectoryIndex index.html index.php </Directory></IfModule>
Configure the PHP development environment under Mac: Apache+php+mysql