Install Apache from source
1. Upload the required software packages for Apache source installation
2. Installation:
Installation order
apr—>apr-util—>pcre—>httpd
installation and compilation environment
yum -y install gcc gcc-c++
apr compile and install
tar xzf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
apr-util compile and install
tar xzf apr-util-1.5.1.tar.gz
cd apr-util-1.5.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make && make install
pcre compile and install
tar xzf pcre-8.32.tar.gz
cd pcre-8.32
./configure --prefix=/usr/local/pcre
make && make install
httpd compile and install
tar zxf httpd-2.4.41.tar.gz
cd httpd-2.4.41
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/ --enable-so --with-mpm=prefork
make && make install
Configure IP-based virtual hosting
Add IP to the host
Temporarily add (restart the network card invalid)
[root@localhost ~]# ifconfig eth0:0 192.168.153.155
[root@localhost ~]# ifconfig eth0:1 192.168.153.156
View the effect
Permanently add
Copy the network card configuration file and edit it
Restart the network card to view the result
creation The website root directory and test page of the two virtual hosts
[root@localhost ~]# mkdir /opt/1806A
[root@localhost ~]# mkdir /opt/1806B
[root@localhost ~]# echo “1806A”> /opt/ 1806A/index.html
[root@localhost ~]# echo “1806B”> /opt/1806B/index.html
Modify Apache's main configuration file
Location: /usr/local/apache/conf/httpd.conf
Authorize the two website root directories of the virtual host,
otherwise it will report an access denied error, the status code is 403
Uncomment the line containing the virtual host
Edit virtual host configuration file
Location: /usr/local/apache/conf/extra/httpd-vhosts.conf
Open Apache service to
see the effect