Compile and install httpd in centos
1. Install the component first.
[root@localhost~]
#yumgroupinstalladditionaldevelopment
[root@localhost~]
#yumgroupinstalldevelopmenttool
2. Install ap1.5.2r (Apache Portable Runtime) and apr-util 1.5.4
[root@localhost~]wgethttp:
//mirrors
.cnnic.cn
/apache//apr/apr-1
.5.2.
tar
.gz
[root@localhost~]
#tarxzvfapr-1.5.2.tar.gz
[root@localhostapr-1.5.2]
#./configure--prefix=/usr/local/apr/
If the error "rm: cannot remove 'libtoolt': No such file or directory" is reported, edit the configure file and comment out the line $ RM "$ folder file ".
[root@localhostapr-1.5.2]
#make&&makeinstall
Install apr-util
[root@ns2~]wgethttp:
//mirrors
.cnnic.cn
/apache//apr/apr-util-1
.5.4.
tar
.gz
Note the -- apr option for compiling options.
[root@localhost~]
#tarxfapr-util-1.5.4.tar.gz
[root@localhost~]
#cdapr-util-1.5.4
[root@localhostapr-util-1.5.4]
#./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr/
[root@localhostapr-util-1.5.4]
#make&&makeinstall
3. pcre is installed in centos by default, so you do not need to install pcre. Otherwise, install
4. Install httpd 2.4.12)
[root@localhost~]
#tarxfhttpd-2.4.12.tar.bz2
[root@localhost~]
#cdhttpd-2.4.12
Add the compilation option (if you are not clear about it, check./configure-h. Do not write it blindly. check whether there is a problem after you finish writing it)
Basic options, including installation path and configuration file path
-- Prefix =/usr/local/apache specifies the large installation path
-- Sysconfdir =/etc/httpd specifies the path of the configuration file
The module allows the option to be used by the module, and most of them dynamically allow mpm and so on.
-- Enable-so allows modular use
-- Enable-modules = most: add most modules
-- Enable-mod-shared = most
-- Enable-mpms-shared = all support all mpm Models
-- Enable-cgi -- enable-cgid supports cgi programs
-- Enable-ssl supports ssl to support https
-- Enable-rewrite supports url redirection.
Specify contact and binding with apr and apr-util
-- With-include-apr
-- With-apr =/usr/local/apr specify apr
-- With-apr-util =/usr/local/apr-util specify apr-util
12
[root@localhosthttpd-2.4.12]
#./configure--prefix=/usr/local/apache--sysconfdir=/etc/httpd--enable-so--enable-modules=most--enable-mods-shared=most--enable-mpms-shared=all--enable-cgi--enable-cgid--enable-ssl--enable-rewrite--with-include-apr--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util
[root@localhosthttpd-2.4.12]
#make&&makeinstall
Compiled and installed
Enter the directory after installation
[root@localhostbin]
#cd/usr/local/apache
[root@localhostapache]
#ls
binbuildcgi-binerrorhtdocsiconsincludelogs
man
manualmodules
[root@localhostapache]
#cdbin/
[root@localhostbin]
#./apachectl
Open the web page and enter the ip address of your VM.
If it cannot be opened, consider the following:
[root@localhostbin]
#serviceiptablesstop
[root@localhostbin]
#getenforce
Enforcing
[root@localhostbin]
#setenforce0
[root@localhostbin]
#vim/etc/selinux/config
Change to permissive
Modify folder attributes
[root@localhostbin]
#chmod755/usr/local/apache/
Refresh again
As mentioned above, it works appears on the webpage! After
We can copy the command to/etc/init. d/httpd to call the service. In short, all in order to achieve the habit of using the httpd rpm package
[root@localhostbin]
#cp/root/httpd-2.4.12/build/rpm/httpd.init/etc/init.d/httpd
[root@localhostbin]
#chmod+x/etc/init.d/httpd
Modify file
Three recommended items
Httpd =$ {HTTPD-/usr/local/apache/bin/httpd}
Pidfile =$ {PIDFILE-/var/run/httpd/$ {prog}. pid}
CONFFILE =/etc/httpd. conf
Don't rush to enable the Service
Create a directory
[root@localhostbin]
#mkdir/var/run/httpd/
To use commands such as httpd-t, modify ~ /. Bash_profile
Change to PATH = $ PATH: $ HOME/bin:/usr/local/apache/bin
[root@localhostbin]
#vim~/.bash_profile
[root@localhostbin]
#source~/.bash_profile
[root@localhostbin]
#httpd-t
SyntaxOK
Add this line to/etc/httpd. conf.
PidFile "/var/run/httpd. pid"
Create a link for the log file
[root@localhostbin]
#ln-s/usr/local/apache/logs/*/var/log/httpd/
Restart the service and check whether the service is OK.
If not, view log files.
[root@localhostbin]
#servicehttpdrestart
Stoppinghttpd:[OK]
Startinghttpd:[OK]
Check whether the webpage is normal again. The task of setting up the latest httpd2.4.12 has been completed!