Build Apache, php, and osx10.9.2apache on MAC OSX10.9.2

Source: Internet
Author: User
Tags url forwarding

Build Apache, php, and osx10.9.2apache on MAC OSX10.9.2

Mac osx10.9. * comes with apache and php

Apache configuration

1-start

Sudo apachectl start

After the startup, access http: // localhost/and you will be able to see "It works! "Initial page,

Vi/etc/apache2/httpd. conf

The following code snippet is displayed in Row 3:

<Directory "/Library/WebServer/Documents">    #    # Possible values for the Options directive are "None", "All",    # or any combination of:    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews    #    # Note that "MultiViews" must be named *explicitly* --- "Options All"    # doesn't give it to you.    #    # The Options directive is both complicated and important.  Please see    # http://httpd.apache.org/docs/2.2/mod/core.html#options    # for more information.    #    Options Indexes FollowSymLinks MultiViews    #    # AllowOverride controls what directives may be placed in .htaccess files.    # It can be "All", "None", or any combination of the keywords:    #   Options FileInfo AuthConfig Limit    #    AllowOverride None    #    # Controls who can get stuff from this server.    #    Order allow,deny    Allow from all</Directory>

Cd/Library/WebServer/Documents ents

The content of It Works is in index.html. en. This is the apache Development page.

2-Stop/restart

Sudo apachectl stop

Sudo apachectl restart

3-create a personal site directory

Cd ~

Mkdir Sites

Echo "helloWorld"> index.html

Sudo apachectl restart

Then access http: // localhost /~ Shelley/should be able to see the "helloWorld" personal directory initial Page (note:~ ShelleyChange~ Your username)

If it fails

Sudo vi/etc/apache2/users/Guest. conf

<Directory "/Users/shelley/Sites">    Options Indexes MultiViews    AllowOverride None    Order allow,deny    Allow from all</Directory>

Why must it be the Sites directory name,

Vi/etc/apache2/extra/httpd-userdir.conf

10th rows

# Settings for user home directories## Required module: mod_userdir## UserDir: The name of the directory that is appended onto a user's home# directory if a ~user request is received.  Note that you must also set# the default access control for these directories, as in the example below.#UserDir Sites## Users might not be in /Users/*/Sites, so use user-specific config files.#Include /private/etc/apache2/users/*.conf<IfModule bonjour_module>       RegisterUserSite customized-users</IfModule>

4-start the VM

By default, apache's Vm function is disabled.

Sudo vi/etc/apache2/httpd. conf

Release comments

#Virtual hosts#Include /private/etc/apache2/extra/httpd-vhosts.conf

Modify file

Sudo vi/etc/apache2/extra/httpd-vhosts.conf

Similar content

NameVirtualHost *:80<VirtualHost *:80>    DocumentRoot "/Users/shelley/Sites"    ServerName www.shelleymyl.com    ErrorLog "/Users/shelley/Sites/log/error.log"    CustomLog "/Users/shelley/Sites/log/access.log" common    <Directory />                Options Indexes FollowSymLinks MultiViews                AllowOverride None                Order deny,allow                Allow from all      </Directory></VirtualHost> 

  

5-URL forwarding

Open httpd. conf first to make sure the following two lines are not commented out:

LoadModule proxy_module libexec/apache2/mod_proxy.soLoadModule proxy_http_module libexec/apache2/mod_proxy_http.so

Add

ProxyPass /HelloWorldApp http://localhost:8080/HelloWorldApp/
ProxyPassReverse /HelloWorldApp http://localhost:8080/HelloWorldApp/

In this way, access http: // localhost/HelloWorldApp, http: // ip/HelloWorldApp, http://www.shelleymyl.com/HellpWorldApp are equivalent to access http: // localhost: 8080/HelloWorldApp

6-port forwarding

If there is an application http://x.x.x.x on the server: 8080/, if you want to access directly through a domain name similar to the http://www.shelleymyl.com, You Need To Do port forwarding, still open httpd. conf

LoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.so

Based on "5. URL forwarding ",

Then modify

Sudo vi/etc/apache2/extra/httpd-vhosts.conf

NameVirtualHost *:80<VirtualHost *:80>        ProxyPreserveHost On        ServerName www.yjmyzz.com        ProxyPass / http://www.yjmyzz.com:8000/        ProxyPassReverse / http://www.yjmyzz.com:8000/                    ServerAdmin webmaster@localhost</VirtualHost>

This is equivalent to forwarding port 80 to port 8080.

PHP configuration

PHP configuration is very simple.

Vi/etc/apache2/httpd. conf

LoadModule php5_module libexec/apache2/libphp5.so

Release comments

Then restart sudo apachectl restart and create an index. php file under the Sites folder in the user directory. echo phpinfo () to see the effect:

 

Reference:

Http://www.cnblogs.com/yjmyzz/p/3920361.html

 

  

 

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.