MacOSX10.9.4mavericks enables the Apache and PHP services of the system

Source: Internet
Author: User

MacOSX10.9.4mavericks enables the Apache and PHP services of the system

As we all know, Mac OSX has built in Apache http server and php, and can use the php environment with just a simple configuration. It is good to perform local tests.

1. Enable Apache Http Server (sudo apachectl start)

Remember the following command:

// Terminal input: sudo apachectl start // start the service sudo apachectl stop // close the service sudo apachectl restart // restart the service
You can use the preceding command to operate the system's built-in Apache server. Enter http: // localhost/in the browser/

After starting the service, you can see "It Works !", It indicates that the startup is successful. The corresponding path is shown in:

The It Works you saw just now! Create a new login.html test file (authorization required). Click http: // localhost/login in the address bar to display the following page:

It indicates that Apache is successfully started.

2. Enable PHP

Next we will start the PHP service. PHP is disabled by default in 10.9.4. Before starting PHP, we can test whether PHP has been started. To determine whether the PHP file is enabled, you only need to check whether the PHP file can be parsed.

In the resource library/WebServer/Documents/, create a test. php file and write a simple sentence:

<?phpecho phpinfo();
The following results are output:

It is output as is, indicating that it is not parsed, indicating that the PHP parsing service is not started.

Let's start it. It's very simple. Just cancel the comments in one sentence.

Go to the file path:/etc/apache2/find the httpd. conf file. You can use tools such as Vi to edit it. The following describes a simple method for editing.

Right click --> open mode --> others and select a text editing tool in the recommendation. sublime is used to open the tool. See:

Search for "php", remove the # in front of "# LoadModule php5_module libexec/apache2/", and then restart Apache, and enter the address http: // localhost/test. php becomes the following interface:

This indicates that php is enabled successfully.

However, you will find that authorization is often required to add files in the Document. We can create a directory named Sites as the root directory of the personal site to share and test files.

3. Set personal Sites

First ~ Create a directory under your user name/directory, and create a new test file a.html, which is written into: abcdefg

Then ~ Create a file named. conf under/etc/apache2/users/, copy a file named Guest. conf, and write the following content into it:

<Directory "/Users/your username/Sites/"> Options Indexes MultiViews AllowOverride All Order allow, deny Allow from all </Directory>
Enter sudo chmod 755/etc/apache2/users/the file name you just created. conf authorization in the terminal.

Finally, enter http: // localhost/~ in the browser /~ Your User Name/a.html will display the following interface:

If your lan ip address is and you want to share a file with your friends on the LAN, you can drag the file into the Sites directory and access http: // /~ You can see the resource with your username.

Click the other party to download the package.

4. Install Mysql

The method for installing Mysql is super simple. It is not described in detail here. Only two download connections are provided.

There are a lot of versions in the, select your own download.

Remember to install MySqlStartupItem. pkg in the software so that you do not need to start it manually every time. The figure is as follows:

In this way, the entire environment is ready.

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: 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.