Apache Web server installation

1, the official sub-site to download from apache http stable version available for download at: http: //mirrors.hust.edu.cn/apache/httpd/httpd-2.4.37.tar.bz2

Rz uploaded to the system using the linux unzip the downloaded version correspondence: tar -xjvf httpd-2.4.37.tar.bz2

Into the extracted directory: cd httpd-2.4.37

Related portable library template installation arp: yum install apr apr-devel apr-util apr-util-devel -y

Install pcre pcre-deve solve the problem

Precompiled apache: ./configure --prefix = / usr / local / apache2 / --enable-rewrite --enable-so # Enable rewrite rules, initiate dynamic add-ons

make

make install

 

2, start apace service, shut down temporarily SElinux. firewall

/usr/ocal/apache2/bin/apachectl start

setenforce 0

systemctl stop firewalld.service

3, modify httpd configuration file

vim  /usr/local/apache2/conf/httpd.conf

ServerName modified as follows:

#ServerName www.example.com:80
ServerName localhost:80

The client then tested: Address: http: //192.168.87.100 test whether publishing success

Apache virtual host corporate applications

Based on a single IP port different domain name

Httpd-vhosts.conf modify the configuration file, this file in / usr / local / apache2 / conf / extra / directory, create a virtual host configuration files you need to / usr / local / apache2 / conf modify the httpd.conf file to this directory one of them

LoadModule vhost_alias_module modules / mod_vhost_alias.so and nclude conf / extra / httpd-vhosts.conf # cancel before these two statements.

Modify httpd-vhosts.conf configured as follows

NameVirtuaHost *: 80 # to open the virtual host and listening on port 80
<VirtualHost *: 80> # virtual host configuration starting
    ServerAdmin [email protected] # administrator mailbox
    DocumentRoot "/ usr / local / apache2 / htdocs / jf1" # virtual host publishing directory
    ServerName www.jf1.com # virtual host directory that were released
    ServerAlias www.jf1.com 
    ErrorLog "logs / www.jf1.com_error_log" # error log directory path and file name
    CustomLog "logs / www.jf1.com_access_log" common # access log path and file name
</ VirtualHost>

<VirtualHost *: 80>
    ServerAdmin [email protected]
    DocumentRoot "/ usr / local / apache2 / htdocs / JF2"
    ServerName www.jf2.com
    ErrorLog "logs / www.jf2. the error_log-COM "
    the CustomLog" logs / www.jf2.com-access_log "Common 
</ VirtualHost>

Create the corresponding directory create the corresponding file restart Apache service

mkdir -p /usr/local/apache2/htdocs/{jf1,jf2.}/

/usr/local/apache2/bin/apachectl  restart

Creating two sites Home

echo“<h1>www.jf1.com pages</h1>”>/usr/local/apache2/htdocs/jf1/index.html

echo“<h1>www.jf2.com pages</h1>”>/usr/local/apache2/htdocs/jf2/index.html

Modifying the local C: \ windows \ system32 \ drivers \ etc in the host file add the following code

192.168.87.100  www.jf1.com

192.168.87.100  www.jf2.com

Open a browser test page www.jf1.com and www.jf2.com

 

Guess you like

Origin www.cnblogs.com/key-l731/p/11427486.html