Configure Apache services under Mac

Source: Internet
Author: User

This article is mainly for Mac users, the first time to build a local development environment of the students, has been built by students can be ignored.

Is the Mac's own Apache or XAMPP?

That's a question. In fact, the Apache has enough, xampp may be more convenient. For example, when the local service restarts, you do not need to knock sudo apachectl restart in the terminal. Of course, there may be some other problems, such as when I used the CI framework to configure rewrite, the Apache has not been configured successfully, and then replaced by XAMPP. Also, installing XAMPP does not affect your own Apache, where the installation path is different. But in use, it is best to start only one, otherwise there will be conflicts. Here, we use the XAMPP as the local server, of course, the configuration of the Apache server is similar to XAMPP, but the installation path is different. First, let's download xampp first. Xampp:https://www.apachefriends.org/download.html. Download good xampp, install directly.


Modify Configuration

The default installation directory for XAMPP is:/APPLICATIONS/XAMPP,XAMPP's directory structure is as follows:

Modify Httpd.conf

The directory where the httpd.conf file is located is:/applications/xampp/etc
Open Httpd-conf,vim httpd-conf
Find the keyword ' rewrite ' and confirm that Rewrite_module is turned on
Find the keyword ' php ' and confirm that Php5_module is open
Locate the keyword ' Directory ' and modify it to the following statement:

Then save the httpd.conf and exit.

Configuring a virtual Host

In general, in order to facilitate local debugging, we also need to use a virtual host. For example, when debugging an asynchronous interface, we will configure the local domain name as ' local.xxx.com ' and so on, so that it is convenient to debug the interface locally.
To configure the virtual host, we need to turn on httpd-vhosts.conf
Open httpd-conf
Find keyword ' vhosts '
Then remove the ' # ' in front of the ' httpd-vhosts.conf ' statement, which removes the comment, such as:

Then save the httpd.conf and exit.

Modify Httpd-vhosts.conf

Now that you want to turn on the functionality of the virtual host, you need to modify httpd-vhosts.conf
Httpd-vhosts.conf is located in the directory:/applications/xampp/etc/extra
Open httpd-vhosts.conf
Insert a piece of code at the bottom as shown in:


The domain name I configured here is: ' local.design.com ', you can customize Oh.
DocumentRoot, here is the path where your code is located, typically placed in the Sites directory under your personal directory. Note that the path here to write absolute path, before the classmate configuration path when the relative path written, there is no success oh.
For convenience, Directory can be set to allowoverride All,allow from all
Then save the httpd-vhosts.conf and exit.

Modify hosts

In order for the virtual domain to take effect, the hosts file needs to be modified
Mac can use ihosts, gas mask and other tools to modify the hosts
In the hosts add: 127.0.0.1 local.desgin.com can
Last save hosts, restart XAMPP

Verify

Access local.design.com in the browser, if you can see the directory under Sites, it means that the development environment has been successfully configured.
However, if your own Apache service is turned on, you may be prompted with a 404 error. This is the time to stop the service that comes with Apache. Command: sudo apachectl stop
If you enter the above command, the prompt fails, you can force the kill process, namely: sudo kill httpd, and then restart XAMPP.
At this point, the local environment is set up, if you are developing a page, then directly to the warehouse code clone into the Sites directory. If you do not use XAMPP, to use your own Apache service, in addition to the directory location of etc, the rest of the configuration steps are almost the same as above oh. Believe that the smart you, will be comprehend by analogy, extrapolate.

Configure Apache services under Mac

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.