Apache 2.4.x手册在RHEL 6.4上构建和安装

Aar*_*ryn 17 apache redhat apache2 rhel

操作系统:红帽企业Linux服务器版本6.4(圣地亚哥)

此操作系统上当前的yum安装apache是​​2.2.15.我需要最新的2.4.x分支,所以已经手动安装它.我已经注意到我完成的完整程序,包括事先将解包aprapr-util源代码输入到apache源中,但我想以下是该过程中最重要的部分:

GATHER LATEST APACHE AND APR
$ cd ~
$ mkdir apache-src
$ cd apache-src
$ wget http://apache.insync.za.net//httpd/httpd-2.4.6.tar.gz
$ tar xvf httpd-2.4.6.tar.gz
$ cd httpd-2.4.6
$ cd srclib
$ wget http://apache.insync.za.net//apr/apr-1.5.0.tar.gz
$ tar -xvzf apr-1.5.0.tar.gz
$ mv apr-1.5.0 apr
$ rm -f apr-1.5.0.tar.gz
$ wget http://apache.insync.za.net//apr/apr-util-1.5.3.tar.gz
$ tar -xvzf apr-util-1.5.3.tar.gz 
$ mv apr-util-1.5.3 apr-util

INSTALL DEVEL PACKAGES
yum update --skip-broken (There is a dependency issue with the latest Chrome needing the latest libstdc++, which is not available for RHEL and CentOS)
yum install apr-devel
yum install apr-util-devel
yum install pcre-devel

INSTALL
$ cd ~/apache-src/httpd-2.4.6
$ ./configure --prefix=/etc/httpd --enable-mods-shared="all" --enable-rewrite --with-included-apr
$ make
$ make install
Run Code Online (Sandbox Code Playgroud)

注意:运行上述操作时,/etc/http为空.

在我尝试启动httpd服务之前,这似乎已经很好了.似乎每个模块都包含httpd.conf失败,并显示与此类似的消息mod_rewrite:

httpd: Syntax error on line 148 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/mod_rewrite.so into server: /etc/httpd/modules/mod_rewrite.so: undefined symbol: ap_global_mutex_create
Run Code Online (Sandbox Code Playgroud)

我已经浏览了已启用模块的列表,httpd.conf并一次一个地对它们进行了评论.所有都触发了如上所述的错误,但"未定义的符号:值"通常是不同的(因此并非总是如此ap_global_mutex_create).

我错过了一步吗?虽然我在Google上发现了该错误的一部分,但大多数解决方案都围绕着.so无法访问的文件.这似乎不是一个问题,模块存在于/etc/http/modules.

注意:运行上述操作时,/etc/http为空.

Ant*_*bit 27

你有正确的程序,但它不完整.

安装后,您必须在httpd.conf中启用S​​SL .并生成server.crtserver.key文件.在完整的程序下面:

1.下载Apache

cd /usr/src
wget http://www.apache.org/dist/httpd/httpd-2.4.23.tar.gz
tar xvf httpd-2.4.23.tar.gz
Run Code Online (Sandbox Code Playgroud)

2.下载APR和APR-Util

cd /usr/src
wget -c http://mirror.cogentco.com/pub/apache/apr/apr-1.5.2.tar.gz
wget -c http://mirror.cogentco.com/pub/apache/apr/apr-util-1.5.4.tar.gz
tar xvf apr-1.5.2.tar.gz
tar xvf apr-util-1.5.4.tar.gz
Run Code Online (Sandbox Code Playgroud)

现在将您下载的APR和APR-Util放入您的apache源文件中.

mv apr-1.5.2 /usr/src/httpd-2.4.23/srclib/apr
mv apr-util-1.5.4 /usr/src/httpd-2.4.23/srclib/apr-util
Run Code Online (Sandbox Code Playgroud)

3.Compile

cd /usr/src/httpd-2.4.23
./configure --enable-so --enable-ssl --with-mpm=prefork --with-included-apr --with-included-apr-util
make
make install
Run Code Online (Sandbox Code Playgroud)

正如您在./configure命令中看到的,我们指定命令行选项以包含apr和apr-utils.

4.在httpd.conf中启用SSL

Apache配置文件httpd.conf位于/ usr/local/apache2/conf下.

nano /usr/local/apache2/conf/httpd.conf
Run Code Online (Sandbox Code Playgroud)

取消注释httpd-ssl.conf Include行和/usr/local/apache2/conf/httpd.conf文件中的LoadModule ssl_module行:

# LoadModule ssl_module modules/mod_ssl.so
# Include conf/extra/httpd-ssl.conf
Run Code Online (Sandbox Code Playgroud)

查看httpd-ssl.conf以查看所有默认的SSL配置.
在大多数情况下,您无需修改​​此文件中的任何内容.

nano /usr/local/apache2/conf/extra/httpd-ssl.conf
Run Code Online (Sandbox Code Playgroud)

在我们启动Apache之前,需要SSL证书和密钥.在我们继续之前,需要创建httpd-ssl.conf中提到
server.crtserver.key文件.

cd /usr/local/apache2/conf/extra
egrep 'server.crt|server.key' httpd-ssl.conf

SSLCertificateFile "/usr/local/apache2/conf/server.crt"
SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
Run Code Online (Sandbox Code Playgroud)

5.生成server.crt和server.key文件

首先,使用openssl 生成server.key.

cd /usr/src
openssl genrsa -des3 -out server.key 1024
Run Code Online (Sandbox Code Playgroud)

以上命令将要求输入密码.请务必记住此密码.稍后启动Apache时需要这样做.

接下来,使用上面的server.key文件生成证书请求文件(server.csr).

openssl req -new -key server.key -out server.csr
Run Code Online (Sandbox Code Playgroud)

最后,使用上面的server.keyserver.csr文件生成自签名的ssl证书(server.crt).

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Run Code Online (Sandbox Code Playgroud)

server.keyserver.crt文件复制到适当的Apache配置目录位置.

cp server.key /usr/local/apache2/conf/
cp server.crt /usr/local/apache2/conf/
Run Code Online (Sandbox Code Playgroud)

6.启动Apache

/usr/local/apache2/bin/apachectl start
Run Code Online (Sandbox Code Playgroud)

如果您收到以下错误消息:

AH00526: Syntax error on line 51 of /usr/local/apache2/conf/extra/httpd-ssl.conf:
Invalid command 'SSLCipherSuite', perhaps misspelled or defined by a module not included in the server configuration
Run Code Online (Sandbox Code Playgroud)

确保取消注释httpd.conf中显示的以下行:

vi /usr/local/apache2/conf/httpd.conf

# LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Run Code Online (Sandbox Code Playgroud)

最后,这将提示您在启动Apache之前输入私钥的密码.验证Apache httpd进程是否在后台运行.

ps -ef | grep http
Run Code Online (Sandbox Code Playgroud)

你应该看到类似的东西:

root    29529 1     0 13:08 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
antoine 29530 29529 0 13:08 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
antoine 29531 29529 0 13:08 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
antoine 29532 29529 0 13:08 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
root    29616 18260 0 13:09 pts/0 00:00:00 grep http
Run Code Online (Sandbox Code Playgroud)

默认情况下,Apache SSL在443端口上运行.打开Web浏览器并验证您是否可以使用https:// {your-ip-address}访问Apache

我希望这有帮助,否则我建议你去看看:http://jasonpowell42.wordpress.com/2013/04/05/install-apache-2-4-4-on-centos-6-4/

  • @AntoineSubit很棒的帖子.我跟着RedHat,它运作良好.在步骤3中进行一次小修正.编译`./configure --enable-so --enable-ssl --with-mpm = prefork --with-included-apr --with-included-apr-util` (2认同)

Cap*_*orn 6

baprutil-1.la /usr/src/httpd-2.4.27/srclib/apr/libapr-1.la -lrt -lcrypt -lpthread -ldl -lcrypt
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ParserCreate'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ParserFree'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetUserData'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_StopParser'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_Parse'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_ErrorString'
/usr/src/httpd-2.4.27/srclib/apr-util/.libs/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/usr/src/httpd-2.4.27/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/httpd-2.4.27/support'
make: *** [all-recursive] Error 1
Run Code Online (Sandbox Code Playgroud)

make如果--with-included-apr-util未在步骤中指定,则会在步骤中收到此错误./configure