Click the icon mark for Star tag thing mac modify the default Apache site root location

Source: Internet
Author: User

In Mac OS X, it's easy to enable the Apache service by turning on web sharing:
The Setup method is as follows:

Open Web share (Web sharing), System settings Preferences (Preferences), share (sharing), select to

Launch Apache

There are two ways of doing this:

  1. Open Web share (Web sharing), System settings Preferences (Preferences), sharing (sharing)
  2. Open terminal (terminal), then (note: sudo requires a password that is the root account password of the system)
    1. Run " sudo apachectl start ", then enter the account password so that Apache runs.

This allows you to enter "http://localhost" in the browser, and you can see that a content "It works!" appears Page, which is located under "/library (Resource Library)/webserver/documents/", which is the default root directory for Apache.

NOTE: When Apache is turned on, "web sharing" is turned on, and the networked user accesses the "/library (library)/webserver/documents/" directory via "http://[local ip]/", via "http://[local IP" /~[user Name] "To access the/users/[user name]/sites/directory, you can disable this access by setting the" Firewall (Firewall) "in" Security "in System preferences.

The system defaults to the current user's access directory is the form of http://localhost/~username, pointing to the user's home directory under the Sites directory. In many cases, we would like to have direct access to the root directory (http://localhost/) to directly access our own sites directory instead of the system default directory.


Make the following changes:
1. Open /etc/apache2/httpd.conf file

sudo vim/etc/apache2/httpd.conf

2. Find

/library/webserver/documents

Replaced by

/users/{username}/sites

where {username} is your login username, such as:

/users/liangc/sites

3. Restart the Web share (Web sharing) (remove the tick and select it again)

or run " sudo apachectl restart "

Once the reboot is successful, you can use http://localhost/to directly access the contents of your sites directory without adding a username.

Thanks.

Click the icon mark for Star tag thing mac modify the default Apache site root location

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.