Apache local server configuration process

Source: Internet
Author: User

Installing Apache

First, the purpose:

1. can have a test server, not all of the special network services can be found free!

second, why is "Apache"

1. The most widely used WEB server

2. mac comes with, only need to modify a few configuration can, simple, fast

3. some special server functions, Apache can be very good support

For example: HTTP put/delete operation, knowledge supplement involves the HTTPS service

Iii. Preparatory work

1. Set User password

Iv. Configuring the server

1. Configuring the server's work

1> Create a "Sites" folder in the Finder and create it directly under the/users/apple (current user name) directory

2> Modify the "Two paths" in the configuration file to point to the folder you just created

3> Copy a file

2. Configuring server Considerations

1> closing Chinese Input method

A "space" is required between the 2> command and the argument

3> Modifying system files Be sure to remember "sudo", otherwise there will be no permissions

4> directory to be/users/apple (current user name)

3. Configure the server

Tip: $ start, can be copied, but do not copy $

Switch working directory

$CD/etc/apache2

Common commands

1. CD Switch directory

2. PWD confirms the current directory

3. LS list displays the contents of the current directory

Backup files, safekeeping, just need to be executed once.

$sudo CP httpd.conf Httpd.conf.bak

Format CP (copy abbreviation) httpd.conf (source file) Httpd.conf.bak (destination file)

Tip: If there is an error in subsequent actions! You can use the following command to recover a backed up httpd.conf file

$ sudo cp httpd.conf.bak httpd.conf

Vim can only use the keyboard, can not use the mouse

Edit httpd.conf with Vim

$sudo Vim httpd.conf

Find DocumentRoot

*/documentroot

"Move cursor to First line"

Enter edit mode

* I

"Modify the path in quotation marks"

Enter Command mode

* ESC

Find DocumentRoot

* N

"Move cursor to First line"

Enter edit mode

* I

"Modify the path in parentheses"

Enter Command mode

* ESC

Find PHP

*/php

"Move cursor to First line"

Delete Line Comment #

* x

Save and exit

*: Wq

Do not save exit!!!!!!!!!

*: q!

Switch working directory

$CD/etc

# etc directory is somewhat similar to Windows/system32, the directory where the configuration files are stored

Copy php.ini file

$sudo CP Php.ini.default PHP.ini

Restarting the Apache server

$sudo apachectl-k Restart

The following error is normal if prompted:

Httpd:could not reliably determine the server ' s fully qualified domain name, using teacher.local for ServerName

HTTPd not running, trying to start

================================================================================

Problems:

1. If you click the info.php file, the download appears, or just a small paragraph of text appears

Workaround:

Enter the following two commands in the terminal:

Close Apache Server

$sudo apachectl-k Stop

Re-launch Apache again

$sudo apachectl-k Start

2. Each time you start the computer, the Apache server will not start automatically by default!

After you can start the computer, open the terminal and enter the following command:

Launch Apache

$sudo apachectl-k Start

3. The most common problems

The swap file already exists, directly by the letter "D", you can delete the swap file!

4. The Apache configuration of Mac 10.10 is slightly different!

Found in httpd.conf

"Options followsymlinks multiviews"

Add a word Indexes, the result of the modification is as follows:

"Options Indexes followsymlinks multiviews"

5. When executing the script, show no access Denied!

Here are the instructions to modify the file permissions in the terminal!

/**

* View file access permissions in the current folder

*/

$ ls-la

$ chmod 644 info.php (file name with no permissions)

$ chmod 644 * *

The brief steps are as follows:

Server Configuration steps:

1> opening the server configuration directory

cd/etc/apache2/

2> viewing the contents of the current directory

Ls

3> modifying the server root path

sudo vim httpd.conf//Enter server configuration file

/documentroot return//Find server default root path

Comment out the default root path DocumentRoot "/library/webserver/documents";

Add a new root path to a line below the commented-out root path

DocumentRoot "/users/likaining/sites"

<directory "/library/webserver/documents" > commented out;

Add a new <directory "/users/likaining/sites" >

Note: The Apache for MAC 10.10 adds the following action!

(see "Server Configuration Video \02-mac10.10 Apache configuration. mp4")

Found in httpd.conf

"Options followsymlinks multiviews"

Add a word Indexes, the result of the modification is as follows:

"Options Indexes followsymlinks multiviews"

}

4> Save exit

: Wq Enter

"Note": If you feel the change is wrong, you want to re-enter the changes, do not save the exit operation

Do not save exit

: q! Enter

Start the server

sudo apachectl-k start or sudo apachectl start

To shut down the server:

sudo apachectl-k stop or sudo apachectl stop

Restarting the server

sudo apachectl-k restart or $sudo apachectl restart

Apache local server configuration process

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.