I thought it would be a simple process to install Apache under Linux. Three commands can be done, JXVF decompression, make compilation, made install installation is OK. I didn't expect the process to be quite a hassle. It might have something to do with the environment. Let's talk about my environment first.
---------------------------
linux:cenos6.2
apache:httpd-2.4.110
---------------------------
[[Email protected] apache]# tar jxvf httpd-2.4.1.tar.bz2//extract Apache compression pack
[[Email protected] apache]# CD httpd-2.4.1//Navigate to httpd-2.4.1 folder
[[email protected] httpd-2.4.1]# ls//View Show httpd-2.4.1 folder contents
[Email protected] httpd-2.4.1]#./configure--help | More//View install Apache configuration parameters
[[email protected] httpd-2.4.1]#./configure--prefix=/usr/local/apache--enable-so//Configure Apache path, followed by--enable-so parameter indicates that the Apache core is loaded with DSO
[[email protected] httpd-2.4.1]# make//compile Apache
Something went wrong! Tips:
Configure:error:APR not found. Please read the documentation
can be downloaded to apr-1.4.6.tar.gz on the Apache official website
Solve Apr not found >>>>
Apr and Apr-util: http://apr.apache.org/download.cgi
[Email protected] apache]# TAR-ZXF apr-1.4.6.tar.gz
[Email protected] apache]# CD apr-1.4.6
[Email protected] apr-1.4.6]#/configure--PREFIX=/USR/LOCAL/APR
[[email protected] apr-1.4.6]# make
[[email protected] apr-1.4.6]# make install
Once the installation is complete, then compile Apache.
[[email protected] httpd-2.4.1]# make
It's another mistake! Tips:
Configure:error:apr-util not found. Please read the documentation
All right! Or the above Apache official address and download apr-util-1.4.1.tar.gz
Resolve Apr-util not found issues >>>>
[Email protected] apache]# TAR-ZXF apr-util-1.4.1.tar.gz
[Email protected] apache]# CD apr-util-1.4.1
[Email protected] apr-util-1.4.1]#/configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr/bin/ Apr-1-config
[[email protected] apr-util-1.4.1]# make
[[email protected] apr-util-1.4.1]# make install
To compile Apache again, error again! Tips:
configure:error:pcre-config for Libpcre not found. PCRE are required and available from http://pcre.org/ , the correlation between my x!linux installation software can sometimes be a crash.
.. /configure still prompts Apr-util not found, adding--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util after the appearance of >>> >>
[[email protected] apache]#./configure–help | grep pcre
--with-pcre=path Use external Pcre library
: http://ftp.exim.llorien.org/pcre/
Download Pcre-8.30.zip, List files more, General browser will have a search function, you can ctrl+f search location after download.
[[email protected] Apache] #unzip-o pcre-8.35.zip
[[email protected] Apache] #cd pcre-8.35
[Email protected] pcre-8.35]#./configure--prefix=/usr/local/pcre
[[email protected] pcre-8.35] #make
[[email protected] pcre-8.35] #make Install
Compiling Apache
[Email protected] httpd-2.4.10]# /configure--prefix=/usr/local/apache2--with-apr=/usr/local/apr-- with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
Note that the parameters followed here must be consistent with the path of the APR and Apr-util installed earlier.
[[email protected] httpd-2.4.1]# make
[[email protected] httpd-2.4.1]# make install
This compile and install should not report any errors. Ha ha!!
Launch Apache
[Email protected] bin]# pwd
/usr/local/apache/bin
[[email protected] bin]# Apachectl stop Stop
[[email protected] bin]# apachectl start
See if Port 80 is occupied
[[email protected] conf] #netstat-an | Grep:80
To see if the Apache boot service is started
[Email protected] bin]# Ps-aux | grep httpd
Warning:bad syntax, perhaps a bogus '-'? See/usr/share/doc/procps-3.2.7/faq
Root 2866 0.0 1.2 25164 9556? Ss 22:45 0:00/usr/sbin/httpd-k Start
Apache 2867 0.0 0.7 25300 5556? S 22:45 0:00/usr/sbin/httpd-k Start
Apache 2868 0.0 0.6 25300 5444? S 22:45 0:00/usr/sbin/httpd-k Start
Apache 2869 0.0 0.6 25300 5444? S 22:45 0:00/usr/sbin/httpd-k Start
Apache 2870 0.0 0.7 25300 5556? S 22:45 0:00/usr/sbin/httpd-k Start
Apache 2871 0.0 0.6 25164 4796? S 22:45 0:00/usr/sbin/httpd-k Start
Apache 2872 0.0 0.6 25164 4796? S 22:45 0:00/usr/sbin/httpd-k Start
Apache 2873 0.0 0.6 25164 4796? S 22:45 0:00/usr/sbin/httpd-k Start
Apache 2874 0.0 0.6 25164 4796? S 22:45 0:00/usr/sbin/httpd-k Start
Root 3141 0.0 0.0 4244 676 pts/1 r+ 22:48 0:00 grep httpd
Below you can access the Apache default page to open. Http://ip:80/index.html
The error is also indicated:
is the port occupied? Modify the Apache configuration file
/usr/local/apache/conf/httpd.conf configuration file
[[email protected] conf] VI httpd.conf
Locate the following line:
ServerName www.example.com:80 Change the cost machine IP port number, such as: 192.168.0.105:80
Port changed to change, has been reported that the error. Since there was no previous experience installing Apache under Linux, I was looking for a page that Apache runs by default. So, found, ...../apache/htdocs/index.html file (misled by Tomcat)! Actually, the files that are running in the/var/www/html directory
You don't have permission to access/index.html on this server
The real mistake is on the tip of the line. Because the file permissions in my location are not sufficient. Then give the file a permission!
Create a file in/var/www/html index.html
[Email protected] html]# chmod 766 index.html
Ok! again to the location of Apache, the page has been opened properly! The process is very tangled, the outcome is very good!
-----------Summary--------------
Files that need to be installed:
apr-1.4.6
apr-util-1.4.1.tar.bz2
Pcre-8.30.zip
/usr/local/apache Apache installation directory
/usr/local/apache/conf/httpd.conf configuration file
/usr/local/apache/bin/apachectl Stop/start Stop/Start program
/var/www/html/Create accessible pages under this folder
Install unzip zip command yum install-y unzip/zip
Because I am installed on the virtual machine after the installation of the outside of the computer can not access the first suspicion is the service did not get up later to view the port service is up and also bound 80 port finally suspected is no open 80 port finally through the following command to open the 80 port out of the result test OK finally succeeded!
So on the Internet to find the next iptable command, and the TCP port 80 is set to allow any IP access:
- Iptables-i input-p TCP--dport 80-j ACCEPT
It is then accessed under Windows and the Web page is displayed properly.
So let's share it here.
If you don't want to have access to another computer, you can change this rule to be a limiting function:
- Iptables-i input-p TCP--dport 80-j DROP
And with this command, you can also restrict access to specific IPs, as follows:
- Iptables-i input-s 192.168.1.18-p TCP--dport 80-j DROP
The process of installing Apache under Linux