First, modify the configuration file
- modifying configuration files and restarting services
[[email protected] ~]# cd/etc/httpd/conf[[email protected] conf]# vim httpd.conf Modify configuration file
change user and group to root:
[[Email protected] conf]# service httpd restartstopping httpd: [ OK ]starting httpd:syntax error on line 244 Of/etc/httpd/conf/httpd.conf:error:\tapache have not been designed to serve pageswhile\n\trunning as root. There Areknown race conditions That\n\twill allow any local user to read any file on thesystem.\n\tif you still desire to Serve pages as root Then\n\tadd-dbig_security_holeto the CFLAGS env Variable\n\tand then rebuild the server.\n\tit is str Onglysuggested that's instead modify the user\n\tdirective in your httpd.conf fileto list a non-root\n\tuser.\n < Span style= "color: #ff6666;" >[failed]</span>[[email protected] conf]#
There was an error restarting the service.
Error:\tapache have not been designed to serve pageswhile\n\trunning as root. There Areknown race conditions That\n\twill allow any local user to read any file on thesystem.\n\tif you still desire to Serve pages as root Then\n\tadd-dbig_security_holeto the CFLAGS env Variable\n\tand then rebuild the server.\n\tit is str Onglysuggested that's instead modify the user\n\tdirective in your httpd.conf fileto list a non-root\n\tuser.\n
from the error message, the meaning is: if you want to use the root user to run the Apache service, you need to add "-dbig_security_hole" to the CFLAGS environment variable, and then recompile the source code.
Second, download the source code, modify, recompile 1. Clean up the environment
[Email protected] software]# Rpm-qa |grep aprapr-1.3.9-5.el6_2.x86_64apr-util-1.3.9-3.el6_0.1.x86_ 64apr-util-ldap-1.3.9-3.el6_0.1.x86_64[[email protected] software]# rpm-e aprerror:failed dependencies: libapr-1.so.0 () (64bit) is needed by (installed) apr-util-1.3.9-3.el6_0.1.x86_64libapr-1.so.0 () (64bit) are needed by ( Installed) httpd-tools-2.2.15-39.el6.centos.x86_64libapr-1.so.0 () (64bit) is needed by (installed) Httpd-2.2.15-39.el6.centos.x86_64[[email protected] software]# rpm-e--nodeps Apr "--nodeps means do not rely on check" [Email Protected] software]# rpm-e--nodeps apr-util[[email protected] software]# rpm-qa |grep aprapr-util-ldap-1.3.9-3.el6_0. 1.x86_64[[email protected] software]#
2. Download the source code compilation installation
[Email protected] software]# wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz [[email protected] software]# wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz [[email protected] software]# wget/http Jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip[[email protected] software]# lsapr-1.4.5.tar.gz apr-util-1.3.12.tar.gz pcre-8.10.zip[[email protected] apr-1.4.5]#./configure--prefix=/usr/local/apr[[ Email protected] apr-1.4.5]# make && make Install[[email protected] apr-util-1.3.12]#./configure--prefix=/usr/ Local/apr-util-with-apr=/usr/local/apr/bin/apr-1-config[[email protected] apr-util-1.3.12]# make && make Install[[email protected] pcre-8.10]#/configure--prefix=/usr/local/pcre[[email protected] pcre-8.10]# make & & Make Install
Download Apache and modify the source code:
<p>[[email protected] software]# wgethttp://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.10.tar.gz</p> <p>[[email protected] software]# tar-xvf httpd-2.4.10.tar.gz </p><span style= "Color:windowtext;" >[[email protected] software]# CD httpd-2.4.10</span>
Modify the Code include/http_config.h, add the file header
#ifndefBIG_SECURITY_HOLE #definebig_security_hole#endif
Recompile:
[Email protected] httpd-2.4.10]#/configure--prefix=/usr/local/httpd--enable-ssl--enable-cgi-- Enable-mods-shared=allable-ssl--enable-cgi--enable-mods-shared=all --enable-track-vars--enable-rewrite < strong>--with-apr-util=/usr/local/apr-util/--WITH-APR=/USR/LOCAL/APR--with-pcre=/usr/local/pcre</strong >[[email protected] httpd-2.4.10]# make && make install
3. Modify the configuration file restart service
at this point, if the service is started, the corresponding user is the default User:deamon or Apache in the configuration file. Then modify the configuration file now:
[Email protected] httpd-2.4.10]# vim/usr/local/httpd/conf/httpd.conf
change user and group to root.
Restart Service:
[[email protected] httpd-2.4.10]#/usr/local/httpd/bin/apachectl startAH00558:httpd:Could not reliably determine the SE RVer ' s fully qualified domain name, using Localhost.localdomain. Set the ' ServerName ' directive globally to suppress this message: Modify ServerName in the configuration file
Modify the servername in the configuration file to: ServerName localhost:80. Restart Service:
[Email protected] httpd-2.4.10]#/usr/local/httpd/bin/apachectl start[[email protected] httpd-2.4.10]# ps-ef |grep Httpdroot 9919 1 0 16:02? 00:00:00/usr/local/httpd/bin/httpd-k startroot 9920 9919 0 16:02? 00:00:00/usr/local/httpd/bin/httpd-k startroot 9921 9919 0 16:02? 00:00:00/usr/local/httpd/bin/httpd-k startroot 9922 9919 0 16:02? 00:00:00/usr/local/httpd/bin/httpd-k startroot 10005 12944 0 16:03 pts/2 00:00:00 grep httpd[[email Protected] httpd-2.4.10]#
If you perform Service httpd Restart a httpd:unrecognized service error occurred, copy/Usr/local/httpd/bin/apachectl to/ETC/INIT.D /HTTPD can be.
At this point, the Modify permission succeeds. Applause ^ ^
Addederror conditions that may be encountered when installing Pcre):
./libtool:line 990:g++: Command not found
MAKE[1]: * * * [Pcrecpp.lo] Error 1
MAKE[1]: Leaving directory '/root/software/pcre-8.10 '
Make: * * * [ALL] Error 2
Workaround:yum install gcc+ gcc-c++
- Error when making && make install:
Libtool:link:unsupported HardCode Properties
Libtool:link:See the Libtool documentation for moreinformation.
Libtool:link:Fatal configuration error.
Solution: Recompile after Yum install gcc+ gcc-c++./configure, then make.
Other Link:
- httpd unrecognised:http://blog.sina.com.cn/s/blog_701300bc0100nzuu.html
- Run apache:http://www.linuxidc.com/linux/2013-02/78967.htm root identity
- Compile and install Apache problems encountered: http://xtony.blog.51cto.com/3964396/836508
Modify Apache's httpd service as root