Linux under Apache installation

Source: Internet
Author: User
Tags fully qualified domain name

Before I introduced Apache Abtest to do stress tests (http://www.cnblogs.com/super-d2/p/3831155.html)

But how to install Apache under Linux, in general Linux under the installation of Apache need source code installation;

First, to Apache 's official website to download the Apache Source Package:

Http://httpd.apache.org/download.cgi#apache22

#chmod 755 httpd-2.0.54.tar.gz (Description:give more Permissions)

#./configure--prefix=/usr/local/apache--enable-module=most--enable-shared=max
(Description:ConfigurationApache. Here I have the default can be generated by"httpd"changed it."Apache"the directory,purpose in order to facilitate the search)

#make (Description:compilingApache)

#make Install (Description:installationApache)

#/usr/local/apache/bin/apachectl Start ( description : launch Apache service, see Apache Whether the service can start normally )
If this problem is initiated: Httpd:could not reliably determine the server ' s fully qualified domain name

, you can use Notepad to open the httpd.conf, the inside of the #servername localhost:80 annotation can be removed, and then execute httpd

#/usr/local/apache/bin/apachectl Stop ( description : stop Apache service, see Apache Whether the service can be shut down properly )

Common tools are placed in the bin directory of their installation directory:

Cd/usr/local/apache/bin:

Apache configuration, the following I was excerpt from, not verified, we use it carefully:

Second, configure Apache1. Modify httpd.conf File # VI/usr/local/apache/conf/httpd.conf1The root directory where the root directory is set is the directory where Apache holds the configuration and log files, the configuration parameter is ServerRoot, and the default is "/usr/local/Apache. " The command is as follows:2set the listening IP address and port number to listen to the TCP80 port of the native IP address by default, the command is as follows: Listen theusers can also use multiple listen statements to listen for client requests on multiple addresses and ports at their own request. For example: Listen192.168.99.9: theLinsten172.16.0.20:80803) Set up system administrator E-Mail uses the serveradmin parameter to set the Administrator e-Mail, such as the administrator's email address is [email protected]:4set the server host name parameter servername is used to set the server's host name, if there is no domain name, fill in the server's IP address, such as the server's IP address is 192.168.99.9:5set the path to the home directory users can use the parameter documentroot to configure the default path for the server home directory, for example, the home directory path is:6set Default file Apache's default file name is Index.html, which can be configured using the directory index parameter, for example, to set index.php as the default file name:7) test: Open Browser, enter Address: http://192.168.99.9, you can open the site:2. Configure directory permissions to use<directory directory path > and </Directory>set permissions for the directory. For example:<directory "/var/www/icons ">Options Indexes multiviewsallowoverride noneorder allow,denyallow from All</Directory>Description:1define the Directory Properties options option parameter: Indexes: This attribute indicates that the directory allows "directory browsing"; MultiViews: This attribute indicates that the directory allows for multiple attempts at content negotiation; All: Contains all features except MultiViews ; execcgi: This attribute indicates that CGI scripts are allowed to execute in this directory; FollowSymLinks: This attribute indicates that symbolic connections are allowed under this directory. 2the. htaccess file can set permissions for the directory through the. htaccess file (access control file). Accessfilename. htaccess configuration Parameters allowoverride the type of directives in the. htaccess file for the specified directory, including all, none and options, FileInfo, Authconfig, Any combination of limit. The allowoverride is generally set to "None" and the. htaccess file is forbidden, and the. htaccess file can overwrite any previous configuration when the allowoverride parameter is all. 3set access control to use the Order option to define access rights. For example, the following statement indicates that access is allowed for all clients: Order Allow,denyallow fromall the following statements indicate that only the network segment is allowed to 192.168.99.0/24 Client access, but the IP address is 192.168.99. 254 Except for this client: Order allow,denyallow from  192.168.99.0/ -Deny from  192.168.99.254users can configure their own directory permissions as described above, as required. 3Create a virtual directory using the alias option to create a virtual directory, for example, creating a "/icons/"This virtual directory, its corresponding physical path is"/var/www/icons/": Alias/icons/"/var/www/icons/"4. User authentication For example, there is a virtual directory named MyWeb, and its corresponding physical path is "/usr/local/MyWeb ", the user authentication feature is now enabled, allowing access only to users Tonyguo and Wayne. 1) Establish the virtual directory and set up user authentication:2) Create a password file and set a password for the userThe-c option means that the file will be re-written and the original content deleted, regardless of whether the password file already exists. So the second user Wayne doesn't need to use-c option. 3the test is entered in the browser: http://192.168.99.9/myweb, you can see the following dialog box:after entering the user name and password, you can visit the website: Third, configure the virtual host1. Configuring IP-based virtual hosts1The IP address is the same, but the port number is different for a virtual host configuration such as using 192.168.99.9 of two different ports 80 and 8080 released two different sites, the corresponding directories for the virtual host are/USR/LOCAL/APACHE/HTDOCS/WEB1 and/usr/local/apache/htdocs/Web2:listen theListen8080<virtualhost192.168.99.9: the>serversignature Email DocumentRoot/usr/local/apache/htdocs/web1 directoryindex index.html index.htm LogLevel warm hostnamelookups off</virtualhost><virtualhost192.168.99.9:8080>serversignature Email DocumentRoot/usr/local/apache/htdocs/web2 directoryindex index.html index.htm LogLevel warm hostnamelookups off</VirtualHost>2Configure a domain-based virtual host such as a server with two IP address 192.168.99.9 and 192.168.99.Ten, use these two IP to create two virtual hosts, the corresponding directory for the virtual host is/USR/LOCAL/APACHE/HTDOCS/WEB1 and/usr/local/apache/htdocs/web2. The Setup method is as follows:<virtualhost192.168.99.9>ServerName192.168.99.9: theDocumentRoot/usr/local/apache/htdocs/web1 directoryindex index.html index.htm</virtualhost><virtualhost192.168.99.10>ServerName192.168.99.10: theDocumentRoot/usr/local/apache/htdocs/web2 directoryindex index.html index.htm</VirtualHost>2Configuring a domain-based virtual host For example, there are two domain names guoxuemin.cn and tonyguo.com need to use the same server 192.168.99.9, you can configure this: Namevirtualhost192.168.99.9<virtualhost www.guoxuemin.cn>ServerName www.guoxuemin.cn: theServerAdmin [email protected] documentroot/usr/local/apache/htdocs/web1 directoryindex index.html index.htm errorlog logs/web1/error_log Customlog Logs/web1/Access_log Combined</virtualhost><virtualhost www.tonyguo.com>ServerName www.tonyguo.com: theServerAdmin [Email protected]documentroot/usr/local/apache/htdocs/web2 directoryindex index.html index.htm errorlog logs/web1/error_log Customlog Logs/web1/Access_log Combined</VirtualHost>
View Code

&NBSP;

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.