This article mainly tests the Redhat 6 installation configuration Apache httpd 2.2.31, which includes: install the Apache 2.2.31, Configure the domain-based virtual host, Configure the port-based virtual host, Configure the virtual directory, modify the default page, and set the boot up.
Test environment:
Operating system version: Red Hat Enterprise Linux Server release 6.5 (Santiago), minimized installation
GCC version: gcc-4.4.7-4.el6.x86_64 (with operating system Media)
Apache Version: httpd-2.2.31.tar.gz
Apr and Apr-util version: 1.3 (httpd-2.2.31.tar.gz)
I. Installation and Deployment
1, through the official website to check the installation of Apache 2.2 requirements (see) mainly: disk free space greater than 50M, ANSI-C compiler and compilation environment (such as gcc), to ensure accurate time (such as NTP time synchronization, in fact, does not configure or affect the installation), Perl5 (optional), Apr and Apr-util (1.2 and later). The official website shows that there are two ways to install APR and apr-util, which are forced to use the accompanying source code installation and manual installation, respectively, This article will be tested separately
650) this.width=650; "width=" 820 "height=" 643 "title=" 01.png "style=" width:725px;height:574px;float:none; "alt=" Wkiol1ft2icilsdkaafbmtbrcvw234.png "src=" http://s1.51cto.com/wyfs02/M00/88/48/wKioL1ft2iCiLsDKAAFbMtBRCVw234.png "/>
650) this.width=650; "width=" 822 "height=" 285 "title=" 02.png "style=" width:733px;height:215px;float:none; "alt=" Wkiom1ft2icc8-6qaaby-pxulwk667.png "src=" http://s1.51cto.com/wyfs02/M01/88/4B/wKiom1ft2iCC8-6QAABY-PxULwk667.png "/>
2. Installing GCC with yum
[email protected]tmp]# Yum Install gcc
650) this.width=650; "width=" 766 "height=" 390 "title=" 03-1.png "style=" width:741px;height:378px;float:none; "alt=" Wkiol1ft2ihhkw_jaabpuuxkalo721.png "src=" http://s3.51cto.com/wyfs02/M01/88/48/wKioL1ft2iHhKw_jAABpUuxkAlo721.png "/>
650) this.width=650; "width=" 759 "height=" 528 "title=" 04.png "style=" width:737px;height:510px;float:none; "alt=" Wkiom1ft2ihq0dslaacqeo9y9d4328.png "src=" http://s3.51cto.com/wyfs02/M02/88/4B/wKiom1ft2iHQ0dsLAACqEO9y9D4328.png "/>
3, the httpd-2.2.31.tar.gz upload to/tmp, using the command TAR-ZXVF httpd-2.2.31.tar.gz decompression, and then a snapshot of the virtual machine, easy to test the installation method after a rollback snapshot, Re-test Installation Method II
[[email protected]]# tar-zxvfhttpd-2.2.31.tar.gz
650) this.width=650; "title=" 05.png "style=" float:none; "alt=" wkiol1ft2ilascqcaaa4isr6k3y559.png "src=" http:/ S3.51cto.com/wyfs02/m01/88/48/wkiol1ft2ilascqcaaa4isr6k3y559.png "/>
A: Use installation method One: force the use of the accompanying Apr/apr-util source code
(1) Enter the extracted directory of Apache httpd-2.2.31, through the command./configure--with-included-apr for Apache httpd source code configuration
[[email PROTECTED]HTTPD-2.2.31]#./CONFIGURE--WITH-INCLUDED-APR
650) this.width=650; "title=" 06.png "style=" float:none; "alt=" wkiom1ft2ikztdjbaabca7-5xi4723.png "src=" http:/ S3.51cto.com/wyfs02/m00/88/4c/wkiom1ft2ikztdjbaabca7-5xi4723.png "/>
(2) compile Apache with command make
[[email protected]httpd-2.2.31]# Make
650) this.width=650; "title=" 07.png "style=" float:none; "alt=" wkiom1ft2ikgbkrqaabhab2pyic891.png "src=" http:/ S3.51cto.com/wyfs02/m02/88/4c/wkiom1ft2ikgbkrqaabhab2pyic891.png "/>
(3) install Apache via command make install
[[email protected] httpd-2.2.31]# make install
650) this.width=650; "title=" 08.png "style=" float:none; "alt=" wkiol1ft2ipckkgnaabl2crybra543.png "src=" http:/ S2.51cto.com/wyfs02/m02/88/48/wkiol1ft2ipckkgnaabl2crybra543.png "/>
(4) compile and install the default installation path is/usr/local/apache2, Modify the httpd.conf file under conf, modify servername for the server IP address: 80
650) this.width=650; "title=" 09.png "style=" float:none; "alt=" wkiom1ft2iobfxuyaaarwr3ic7e701.png "src=" http:/ S2.51cto.com/wyfs02/m01/88/4c/wkiom1ft2iobfxuyaaarwr3ic7e701.png "/>
650) this.width=650; "title=" 10-1.png "style=" float:none "alt=" wkiom1ft2ipjq9zdaabq_a2w5zu767.png "src=" http:/ S2.51cto.com/wyfs02/m00/88/4c/wkiom1ft2ipjq9zdaabq_a2w5zu767.png "/>
(5) execute the command to the bin Directory./apachectl-k start Apache Service
650) this.width=650; "title=" 11.png "style=" float:none; "alt=" wkiol1ft2iod5gyraaahewqvpe8421.png "src=" http:/ S2.51cto.com/wyfs02/m00/88/48/wkiol1ft2iod5gyraaahewqvpe8421.png "/>
(6) access to the server IP through the browser, the IT works! appears Indicates that the Apache server is up and running properly
650) this.width=650; "title=" 12.png "style=" float:none; "alt=" wkiom1ft2ithxn3raabked0aer0649.png "src=" http:/ S2.51cto.com/wyfs02/m02/88/4c/wkiom1ft2ithxn3raabked0aer0649.png "/>
B: installation Method Ii: separately compiled and installed apr, Apr-util
(1) through the snapshot rollback, the test is compiled to install the APR and apr-util, first into the extracted Apache source package Srclib directory, You can see the Apache httpd-2.2.31 source package comes with apr\apr-util, is version 1.3, of course, we can also download the latest version of the Apr\apr-util
650) this.width=650; "title=" 13.png "style=" float:none; "alt=" wkiol1ft2iswslr0aaalwkmpr4k039.png "src=" http:/ S2.51cto.com/wyfs02/m00/88/48/wkiol1ft2iswslr0aaalwkmpr4k039.png "/>
(2) Compile and install apr, enter the APR directory, and execute the command in turn./configure--prefix=/usr/local/apr-httpd, make, make install
650) this.width=650; "title=" 14.png "style=" float:none; "alt=" wkiol1ft2iszaucoaaba-jf7jg8048.png "src=" http:/ S2.51cto.com/wyfs02/m01/88/48/wkiol1ft2iszaucoaaba-jf7jg8048.png "/>
[[email protected]apr]#./configure--prefix=/usr/local/apr-httpd
[[email protected]apr]# Make
[[email protected]apr]# make Install
(3) Compile and install apr-util, enter the Apr-util directory and execute the command sequentially./configure--prefix=/usr/local/apr-util-httpd--with-apr=/usr/local/ apr-httpd, make, make Install
650) this.width=650; "title=" 15.png "style=" float:none; "alt=" wkiom1ft2iwjj3i5aabgyx-_5zy180.png "src=" http:/ S2.51cto.com/wyfs02/m01/88/4c/wkiom1ft2iwjj3i5aabgyx-_5zy180.png "/>
[[email protected]apr-util]#./configure--prefix=/usr/local/apr-util-httpd--with-apr=/usr/local/apr-httpd/
[[email protected]apr-util]# Make
[[email protected]apr-util]# make Install
(4) compile and install Apache and execute the command sequentially./configure--with-apr=/usr/local/apr-httpd/--with-apr-util=/usr/local/apr-util-httpd, make, Make install
[email protected]apr-util]# CD. /.. /
650) this.width=650; "title=" 16.png "style=" float:none; "alt=" wkiom1ft2ixrmceaaaa1_mdfm1o003.png "src=" http:/ S3.51cto.com/wyfs02/m00/88/4c/wkiom1ft2ixrmceaaaa1_mdfm1o003.png "/>
[[email protected]httpd-2.2.31]#./configure--with-apr=/usr/local/apr-httpd/--with-apr-util=/usr/local/ apr-util-httpd/
[[email protected]httpd-2.2.31]# Make
[[email protected]httpd-2.2.31]# make Install
(5) Compile and install the default installation path is/usr/local/apache2, Modify the httpd.conf file under conf, Modify the servername to the server IP address:
650) this.width=650; "title=" 17.png "style=" float:none; "alt=" wkiol1ft2iws4dexaaa-vgetr48214.png "src=" http:/ S2.51cto.com/wyfs02/m01/88/48/wkiol1ft2iws4dexaaa-vgetr48214.png "/>
(6) execute the command to the bin Directory./apachectl-k start Apache Service
650) this.width=650; "title=" 18.png "style=" float:none; "alt=" wkiol1ft2iwigyydaaae78cfp0i085.png "src=" http:/ S2.51cto.com/wyfs02/m02/88/48/wkiol1ft2iwigyydaaae78cfp0i085.png "/>
(7) access to server IP via browser, "It works! "indicates that the Apache server is up and running properly
650) this.width=650; "title=" 19-1.png "style=" float:none "alt=" wkiom1ft2ibhldvoaabn5fcuq70407.png "src=" http:/ S3.51cto.com/wyfs02/m02/88/4c/wkiom1ft2ibhldvoaabn5fcuq70407.png "/>
(8) command to start, stop, and restart Apache services
Start Service apachectl-k Start
Stop Service Apachectl-k Stop
Restart Service Apachectl-k Resar
Gracefully restarts Apachectl-k Graceful
Gracefully stop apachectl-k graceful-stop
second, Configure the domain-based virtual host
The original source of this article: Jiangjianrong technical blog http://jiangjianlong.blog.51cto.com/3735273/1858453
1, establish the directory/test1, and in which a index.html file is created, the content is welcome to jiangjianlong.blog.51cto.com
650) this.width=650; "title=" 21.png "style=" float:none; "alt=" wkiom1ft2ifbhpp8aaav3owfkzu794.png "src=" http:/ S3.51cto.com/wyfs02/m01/88/4c/wkiom1ft2ifbhpp8aaav3owfkzu794.png "/>
2. Set up Directory/test2 and create a index.html file in which the content is Hello World
650) this.width=650; "title=" 22.png "style=" float:none; "alt=" wkiom1ft2ied2thdaaaqphdxxj0210.png "src=" http:/ S4.51cto.com/wyfs02/m00/88/4c/wkiom1ft2ied2thdaaaqphdxxj0210.png "/>
3, Modify the conf/httpd.conf file, the include conf/extra/httpd-vhosts.conf this line to delete the comment, to enable conf/extra/httpd-vhosts.conf
650) this.width=650; "title=" 23.png "style=" float:none; "alt=" wkiol1ft2ifspz5iaaar8nrjhrm043.png "src=" http:/ S4.51cto.com/wyfs02/m00/88/48/wkiol1ft2ifspz5iaaar8nrjhrm043.png "/>
4. Modify the Conf/extra/httpd-vhosts.conf file to modify the two default examples as shown, configured as www.test1.com and www.test2.com two virtual hosts respectively
650) this.width=650; "title=" 20.png "style=" float:none; "alt=" wkiol1ft2ibzxxpoaaabatmmlkg896.png "src=" http:/ S3.51cto.com/wyfs02/m02/88/48/wkiol1ft2ibzxxpoaaabatmmlkg896.png "/>
ServerName www.test1.com
errorlog "logs/test1.com-error_log"
customlog "logs/ Test1.com-access_log "common
<directory"/test1 ";
allowoverride None
Options None
Order Allow,deny
Allow from all
</directory>
</virtualhost>
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/test2"
ServerName www.test2.com
Errorlog "logs/test2.com-error_log"
Customlog "logs/test2.com-access_log" Common
<directory "/test2" >
AllowOverride None
Options None
Order Allow,deny
Allow from all
</Directory>
</VirtualHost>
650) this.width=650; "title=" 24-1.png "style=" float:none "alt=" wkiom1ft2ieqoub4aabjko83lb4089.png "src=" http:/ S4.51cto.com/wyfs02/m02/88/4c/wkiom1ft2ieqoub4aabjko83lb4089.png "/>
5. Restart Service Bin/apachectl-k Graceful
650) this.width=650; "title=" 25.png "style=" float:none; "alt=" wkiol1ft2ijcayq8aaagrdlgeds351.png "src=" http:/ S3.51cto.com/wyfs02/m00/88/48/wkiol1ft2ijcayq8aaagrdlgeds351.png "/>
6, in the notebook to do the hosts parsing, www.test1.com and www.test2.com are resolved to the same server IP
650) this.width=650; "title=" 26.png "style=" float:none; "alt=" wkiom1ft2iizoygqaaan-esehtk442.png "src=" http:/ S3.51cto.com/wyfs02/m01/88/4c/wkiom1ft2iizoygqaaan-esehtk442.png "/>
7. Access to www.test1.com using a browser, successfully accessing the/test1/index.html page
650) this.width=650; "title=" 27.png "style=" float:none; "alt=" wkiol1ft2ijzimeuaabfylmdo6e766.png "src=" http:/ S3.51cto.com/wyfs02/m01/88/48/wkiol1ft2ijzimeuaabfylmdo6e766.png "/>
8. Access to www.test2.com using a browser, successfully accessing the/test2/index.html page
650) this.width=650; "title=" 28.png "style=" float:none; "alt=" wkiom1ft2inglyiuaaazpu0luig505.png "src=" http:/ S1.51cto.com/wyfs02/m00/88/4c/wkiom1ft2inglyiuaaazpu0luig505.png "/>
9, But if you use IP access, still access to the default page
650) this.width=650; "title=" 29.png "style=" float:none; "alt=" wkiol1ft2imiyfwvaabked0aer0358.png "src=" http:/ S1.51cto.com/wyfs02/m01/88/48/wkiol1ft2imiyfwvaabked0aer0358.png "/>
third, Configure the port-based virtual host
The original source of this article: Jiangjianrong technical blog http://jiangjianlong.blog.51cto.com/3735273/1858453
1, Modify the conf/httpd.conf file, increase monitoring 81 and 82 ports
650) this.width=650; "title=" 30.png "style=" float:none; "alt=" wkiom1ft2imsk2vmaaatloggoea037.png "src=" http:/ S1.51cto.com/wyfs02/m02/88/4c/wkiom1ft2imsk2vmaaatloggoea037.png "/>
2, Modify the conf/extra/httpd-vhosts.conf file, two virtual host *:80 respectively modified to *:81 and *:82650) this.width=650; "title=" 33-1.png "style=" float: none; "alt=" wkiom1ft2nmdyah9aablfsj89pc913.png "src=" http://s5.51cto.com/wyfs02/M00/88/4C/ Wkiom1ft2nmdyah9aablfsj89pc913.png "/>
3. Restart Apache Service
[email protected]extra]#/usr/local/apache2/bin/apachectl-k Restart
4, Access with IP address + port, successfully access to different pages
650) this.width=650; "title=" 32.png "style=" float:none; "alt=" wkiol1ft2nmypkm3aac02nvslti770.png "src=" http:/ S5.51cto.com/wyfs02/m02/88/48/wkiol1ft2nmypkm3aac02nvslti770.png "/>
5, using the domain name + different ports to access, but also successfully access to different pages, if not add the port to access to the default page
650) this.width=650; "title=" 34.png "src=" http://s5.51cto.com/wyfs02/M01/88/5A/wKiom1fxMyqgDabKAAF2cpjoC8M031.png "alt=" Wkiom1fxmyqgdabkaaf2cpjoc8m031.png "/>
Iv. Configuring virtual Directories
The original source of this article: Jiangjianrong technical blog http://jiangjianlong.blog.51cto.com/3735273/1858453
1, Create a subdirectory in/test1/test1/abc, and created a index.html page, the content is "abc"
650) this.width=650; "title=" 35.png "style=" float:none; "alt=" wkiom1ft2nqtrse9aaaql-xmdf4148.png "src=" http:/ S1.51cto.com/wyfs02/m01/88/4c/wkiom1ft2nqtrse9aaaql-xmdf4148.png "/>
2. Set up SUBDIRECTORY/TEST2/OPQ in/test2 and create a index.html page with the content "opq"
650) this.width=650; "title=" 36.png "style=" float:none; "alt=" wkiol1ft2nvdmwyyaaaqqz2arsq509.png "src=" http:/ S1.51cto.com/wyfs02/m00/88/48/wkiol1ft2nvdmwyyaaaqqz2arsq509.png "/>
3, Modify the conf/httpd.conf file, add 2 lines at the end of the file, respectively alias/abc "/test1/abc", ALIAS/OPQ "/test2/opq"
650) this.width=650; "title=" 37.png "style=" float:none; "alt=" wkiom1ft2nuqz3qxaaaomje_sro196.png "src=" http:/ S1.51cto.com/wyfs02/m01/88/4c/wkiom1ft2nuqz3qxaaaomje_sro196.png "/>
4. Restart Apache Service
[email protected] extra]#/usr/local/apache2/bin/apachectl-k Restart
5, respectively, using ip+ port + virtual directory or domain + port + virtual directory for access, can successfully access the corresponding page
650) this.width=650; "title=" 38.png "style=" float:none; "alt=" wkiol1ft2nzxzgujaadew98-acg250.png "src=" http:/ S4.51cto.com/wyfs02/m01/88/48/wkiol1ft2nzxzgujaadew98-acg250.png "/>
six, Modify the default page and set the boot start
The original source of this article: Jiangjianrong technical blog http://jiangjianlong.blog.51cto.com/3735273/1858453
1, create/www/index.html, content is Apache 2.2.31
650) this.width=650; "title=" 39-0.png "alt=" wkiol1fxlfvbe4izaaaydhnpnhu669.png "src=" http://s2.51cto.com/wyfs02/ M00/88/56/wkiol1fxlfvbe4izaaaydhnpnhu669.png "/>
2, Edit the conf/httpd.conf file, Modify the path of the red box is/www
650) this.width=650; "title=" 39-1.png "alt=" wkiol1fxksvz0iyxaacvbr--nec701.png "src=" http://s3.51cto.com/wyfs02/ M02/88/56/wkiol1fxksvz0iyxaacvbr--nec701.png "/>
3. Restart Apache Service
[email protected] extra]#/usr/local/apache2/bin/apachectl-k Restart
3, using the domain name or ip+ the default 80 port successfully access to the page under/www, indicating that the default page has been successfully modified, plus the port to access the corresponding other pages
650) this.width=650; "title=" 40.png "alt=" wkiol1fxk6tafpuqaaeemms-_i4320.png "src=" http://s2.51cto.com/wyfs02/M02/ 88/56/wkiol1fxk6tafpuqaaeemms-_i4320.png "/>
4, the command to start Apache added to the/etc/rc.d/rc.local file, enabling boot
650) this.width=650; "title=" 41.png "alt=" wkiol1fw31isfjhnaaagazh5wys454.png "src=" http://s3.51cto.com/wyfs02/M02/ 88/55/wkiol1fw31isfjhnaaagazh5wys454.png "/>
This article is from the "Jiangjianrong technology blog" blog, Make sure to keep this source http://jiangjianlong.blog.51cto.com/3735273/1858453
RedHat 6 Installation Configuration Apache 2.2