Enable Mac self-bring Apache & Virtual Host Configuration

Source: Internet
Author: User
Tags phpinfo
enable Mac self-bring Apache & Virtual Host Configuration 1. Start Apache

Mac with Apache, under the system's private directory/private/etc

sudo apachectl start

Start Apache, enter http://localhost in the browser, see "It Works" description started successfully

Apache Default virtual host (site root directory) directory:/library/webserver/documents/ 2. Open php in Apache

Back up-> Httpd.conf.bank before modifying httpd.conf

sudo vim/etc/apache2/httpd.conf

Locate and remove the annotation symbol (#)

#LoadModule Php5_module libexec/apache2/libphp5.so
3. View Phpinfo ()

Duplicate a copy of/library/webserver/documents/index.html.en, named info.php

 

Enter http://localhost/info.php in the browser 4. Set up the virtual host and virtual directory

1. Configure the Apache main configuration file--httpd.conf

Set IP address and port for listening network card

#Listen 12.34.56.78:80

Listen 80

Specifies the IP address and port on which the virtual host can be accessed, where the IP address must be the IP address of its own network adapter

Namevirtualhost *:80
Include conf/vhosts.conf

2. Configure Apache Virtual host--vhosts.conf

3. Configure local DNS file--hosts

Set the root directory of your own Web site (virtual host)

sudo vim/etc/apache2/httpd.conf

Locate and remove the annotation symbol (#)

#LoadModule authn_core_module libexec/apache2/mod_authn_core.so
#LoadModule authz_host_module libexec/apache2/ mod_authz_host.so
#LoadModule authz_core_module libexec/apache2/mod_authz_core.so
#LoadModule dir_module libexec/apache2/mod_dir.so
#LoadModule userdir_module libexec/apache2/mod_userdir.so
#LoadModule Alias_ Module libexec/apache2/mod_alias.so

Find and modify

DocumentRoot "/library/webserver/documents"
<directory "/library/webserver/documents" >

For

DocumentRoot "/users/sunshine/workspace"
<directory "/users/sunshine/workspace" >

Locate and remove the annotation symbol (#)

#Include/private/etc/apache2/extra/httpd-userdir.conf
#Include/private/etc/apache2/extra/httpd-vhosts.conf
#Include/private/etc/apache2/other/*.conf

Creating a virtual Host

sudo vim/etc/apache2/extra/httpd-vhosts.conf

Locate and remove the annotation symbol (#)

#Include/private/etc/apache2/users/*.conf

Use # to comment out the original two virtualhost and add

<virtualhost *:80>
    documentroot "/users/sunshine/workspace" ServerName phpworkspace
    " Private/var/log/apache2/phpworkspace-error_log "
    Customlog"/private/var/log/apache2/phpworkspace-access_log "Common
    <directory/>
        Options Indexes followsymlinks multiviews
        None
        order Deny, Allow
        allow from all
    </Directory>
</VirtualHost>

Apache Configuration Description:

1. Listen command

Listen    ///80-Port Request for all IP addresses of this machine
Listen 192.168.3.100   //monitor access to all ports of the specified IP address 192.168.3.100
of this computer Listen 192.168.18.89:8080  //monitor access to port 8080 of the local IP address 192.168.18.89

2.

Set external (client) access rights for the Web site's root directory

Options: Specify which server features the server will enable. Values: None, all, Indexes
  None: Disable Enable server features
  all: Turn on all server features
  Indexes: If the first file does not exist, display the directory list Order
: Specify Allow (Allow) and Deny (Forbidden) execution order
  Allow,deny   first allow access, and then disallow IP access orders
  deny,allow   First to disable all access, and then to turn on the specified IP access
Deny: Disallow which IP access host
  deny  from all prohibits all IP access hosts, including their own
  deny from 192.168.18.76 192.168.18.74    Prohibit the designation of IP access to your host. Prohibit the client's IP address
  Deny from 192.168.18    prohibit all IP access between the network segments between 192.168.18.0~192.168.18.255
Allow: Which IP access hosts
  are allowed Allow  from all allows all IP access hosts, including their own
  Allow from 192.168.18.76  192.168.18.74 to allow the   specified IP access host
  Allow From 192.168.18   allows all IP access between the network segments between 192.168.18.0~192.168.18.255
5. Add DNS resolution
sudo vi/etc/hosts

Add to

127.0.0.1        Phpworkspace

Copy the previously created info.php to the root of the Web site, and enter the host name created in the browser http://phpworkspace/info.php 6. Problems encountered

Open the website error code 403, check the root site there is no paging file, if there are files, try to set the default page, if there are problems, try to modify directory permissions

Modify Httpd.conf

DirectoryIndex index.html index.php index.jsp index.htm

Modify Directory Permissions

sudo chmod-r 775/users/sunshine/workspace

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.