在 RHEL 6.4 上手动构建和安装 Apache 2.4.x [英] Apache 2.4.x manual build and install on RHEL 6.4
问题描述
操作系统:红帽企业 Linux 服务器 6.4 版(圣地亚哥)
目前在这个操作系统上 yum 安装的 apache 是 2.2.15.我需要最新的 2.4.x 分支,所以手动安装它.我已经记下了我进行的完整过程,包括事先将 apr
和 apr-util
源代码解包到 apache 源代码中,但我想以下是该过程中最重要的部分:
收集最新的 APACHE 和 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安装开发包yum update --skip-broken(最新的 Chrome 存在依赖问题,需要最新的 libstdc++,RHEL 和 CentOS 不可用)yum 安装 apr-develyum 安装 apr-util-develyum 安装 pcre-devel安装$ cd ~/apache-src/httpd-2.4.6$ ./configure --prefix=/etc/httpd --enable-mods-shared="all" --enable-rewrite --with-included-apr$ make$ 安装
<块引用>
注意:上面运行时,/etc/http
为空.
这似乎很顺利,直到我尝试启动 httpd 服务.似乎 httpd.conf
中包含的每个模块都失败了,并显示与 mod_rewrite
类似的消息:
httpd:/etc/httpd/conf/httpd.conf 的第 148 行语法错误:无法将/etc/httpd/modules/mod_rewrite.so 加载到服务器:/etc/httpd/modules/mod_rewrite.so:未定义符号:ap_global_mutex_create
我已经仔细浏览了 httpd.conf
中启用的模块列表,并一次将它们注释掉.全部触发上述错误,但是未定义符号:值"通常不同(因此并不总是ap_global_mutex_create
).
我错过了一步吗?尽管我在 Google 上发现了该错误的一部分,但大多数解决方案都围绕着无法访问 .so
文件.这在这里似乎不是问题,模块存在于 /etc/http/modules
中.
注意:上面运行时,/etc/http
为空.
您有正确的程序,但它不完整.
安装后,您必须在 httpd.conf 中启用 SSL.并生成 server.crt 和 server.key 文件.下面是完整的程序:
1.下载 Apache
cd/usr/srcwget http://www.apache.org/dist/httpd/httpd-2.4.23.tar.gztar xvf httpd-2.4.23.tar.gz
2.下载 APR 和 APR-Util
cd/usr/srcwget -c http://mirror.cogentco.com/pub/apache/apr/apr-1.5.2.tar.gzwget -c http://mirror.cogentco.com/pub/apache/apr/apr-util-1.5.4.tar.gztar xvf apr-1.5.2.tar.gztar xvf apr-util-1.5.4.tar.gz
现在将您下载的 APR 和 APR-Util 放入您的 apache 源文件中.
mv apr-1.5.2/usr/src/httpd-2.4.23/srclib/aprmv apr-util-1.5.4/usr/src/httpd-2.4.23/srclib/apr-util
3.编译
cd/usr/src/httpd-2.4.23./configure --enable-so --enable-ssl --with-mpm=prefork --with-included-apr --with-included-apr-util制作进行安装
正如您在 ./configure
命令中看到的,我们指定命令行选项以包含 apr 和 apr-utils.
4.在 httpd.conf 中启用 SSL
Apache 配置文件 httpd.conf 位于 /usr/local/apache2/conf 下.
nano/usr/local/apache2/conf/httpd.conf
取消注释 /usr/local/apache2/conf/httpd.conf 中的 httpd-ssl.conf Include 行和 LoadModule ssl_module
行em> 文件:
# LoadModule ssl_module modules/mod_ssl.so# 包含 conf/extra/httpd-ssl.conf
查看 httpd-ssl.conf 以查看所有默认 SSL 配置.
大多数情况下,您无需修改此文件中的任何内容.
nano/usr/local/apache2/conf/extra/httpd-ssl.conf
在我们启动 Apache 之前需要 SSL 证书和密钥.
httpd-ssl.conf 中提到的 server.crt 和 server.key 文件需要在我们继续之前创建.
cd/usr/local/apache2/conf/extraegrep 'server.crt|server.key' httpd-ssl.confSSLCertificateFile "/usr/local/apache2/conf/server.crt"SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
5.生成 server.crt 和 server.key 文件
首先,使用 openssl 生成 server.key.
cd/usr/srcopenssl genrsa -des3 -out server.key 1024
上面的命令会要求输入密码.请务必记住此密码.稍后启动 Apache 时需要它.
接下来,使用上述 server.key 文件生成证书请求文件(server.csr).
openssl req -new -key server.key -out server.csr
最后,使用上述 server.key 和 server.csr 文件生成自签名 ssl 证书 (server.crt).
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
将 server.key 和 server.crt 文件复制到适当的 Apache 配置目录位置.
cp server.key/usr/local/apache2/conf/cp server.crt/usr/local/apache2/conf/
6.启动 Apache
/usr/local/apache2/bin/apachectl start
如果您收到以下错误消息:
AH00526:/usr/local/apache2/conf/extra/httpd-ssl.conf 第 51 行的语法错误:命令SSLCipherSuite"无效,可能拼写错误或由服务器配置中未包含的模块定义
确保在 httpd.conf 中取消注释下面显示的行:
vi/usr/local/apache2/conf/httpd.conf# LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
最后,这将提示您在启动 apache 之前输入您的私钥的密码.验证 Apache httpd 进程是否在后台运行.
ps -ef |解析 http
你应该看到类似的东西:
root 29529 1 0 13:08 ?00:00:00/usr/local/apache2/bin/httpd -k 开始安托万 29530 29529 0 13:08 ?00:00:00/usr/local/apache2/bin/httpd -k 开始安托万 29531 29529 0 13:08 ?00:00:00/usr/local/apache2/bin/httpd -k 开始安托万 29532 29529 0 13:08 ?00:00:00/usr/local/apache2/bin/httpd -k 开始根 29616 18260 0 13:09 pts/0 00:00:00 grep http
默认情况下,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/
OS: Red Hat Enterprise Linux Server release 6.4 (Santiago)
The current yum installation of apache on this OS is 2.2.15. I require the latest 2.4.x branch so have gone about installing it manually. I have noted the complete procedure I undertook, including unpacking apr
and apr-util
sources into the apache sources beforehand, but I guess the following is the most important part of the procedure:
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
NOTE: At the time of running the above,
/etc/http
is empty.
This seems to have gone fine until I attempt to start the httpd service. It seems that every module include in httpd.conf
fails with a message similar to this one for 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
I've gone right through the list of enabled modules in httpd.conf
and commented them out one at a time. All trigger an error as above, however the "undefined symbol: value" is often different (so not always ap_global_mutex_create
).
Am I missing a step? Although I find a some portion of that error on Google, most of the solutions centre around the .so
files not being reachable. That doesn't seem to be an issue here and the modules are present in /etc/http/modules
.
NOTE: At the time of running the above,
/etc/http
is empty.
You have the correct procedure but it's incomplete.
After the installation you have to enable SSL in httpd.conf. and generate server.crt and server.key file. Below the complete procedure :
1. Download 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
2. Download APR and 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
Now put the APR and APR-Util you downloaded into your apache source files.
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
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
As you can see in the ./configure
command we specify command line options to include apr and apr-utils.
4. Enable SSL in httpd.conf
Apache configuration file httpd.conf is located under /usr/local/apache2/conf.
nano /usr/local/apache2/conf/httpd.conf
Uncomment the httpd-ssl.conf Include line and the LoadModule ssl_module
line in the /usr/local/apache2/conf/httpd.conf file :
# LoadModule ssl_module modules/mod_ssl.so
# Include conf/extra/httpd-ssl.conf
View the httpd-ssl.conf to review all the default SSL configurations.
For most cases, you don’t need to modify anything in this file.
nano /usr/local/apache2/conf/extra/httpd-ssl.conf
The SSL certificate and key are required before we start the Apache.
The server.crt and server.key file mentioned in the httpd-ssl.conf needs to be created before we move forward.
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"
5. Generate server.crt and server.key file
First, Generate the server.key using openssl.
cd /usr/src
openssl genrsa -des3 -out server.key 1024
The above command will ask for the password. Make sure to remember this password. You need this while starting your Apache later.
Next, generate a certificate request file (server.csr) using the above server.key file.
openssl req -new -key server.key -out server.csr
Finally, generate a self signed ssl certificate (server.crt) using the above server.key and server.csr file.
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Copy the server.key and server.crt file to appropriate Apache configuration directory location.
cp server.key /usr/local/apache2/conf/
cp server.crt /usr/local/apache2/conf/
6. Start Apache
/usr/local/apache2/bin/apachectl start
If you are getting the below error message :
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
Make sure to uncomment the line shown below in httpd.conf :
vi /usr/local/apache2/conf/httpd.conf
# LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Finally, this will prompt you to enter the password for your private key before starting up the apache. Verify that the Apache httpd process is running in the background.
ps -ef | grep http
You should see something like that :
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
By default Apache SSL runs on 443 port. Open a web browser and verify that you can access your Apache using https://{your-ip-address}
I hope this help, else I advise you to go see : http://jasonpowell42.wordpress.com/2013/04/05/install-apache-2-4-4-on-centos-6-4/
这篇关于在 RHEL 6.4 上手动构建和安装 Apache 2.4.x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!