RedHat 7怎样安装HTTPD
温馨提示:这篇文章已超过518天没有更新,请注意相关的内容是否还可用!
[root@aws srclib]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.4 2.首先安装apr,本例子是1.6.3版本。tar -xzvf apr-1.6.3.tar.gz进入apr目录,执行configure命令,该命令本例就一个参数 ,设置安装目录。cd /usr/local/src/apr-1.6.3 ./configure –prefix=/usr/local/apr配置好之后,执行make和make install. [root@aws src]# tar -jxvf apr-util-1.6.1.tar.bz2 tar : bzip2: Cannot exec: No such file or directory tar : Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now解决的办法是:。^ compilation terminated. make[1]: *** [xml/apr_xml.lo] Error 1 make[1]: Leaving directory `/usr/local/src/apr-util-1.6.1解决办法是安装expat库。false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/解决办法是:。make make install以上两个步骤都可以用命令echo $?来检查是否执行成功。
这篇文章给大家介绍RedHat 7怎样安装HTTPD,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
1.查看操作系统版本
[root@aws srclib]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)
2.首先安装apr,本例子是1.6.3版本
wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz下载之后就是解压
tar -xzvf apr-1.6.3.tar.gz进入apr目录,执行configure命令,该命令本例就一个参数 ,设置安装目录
cd /usr/local/src/apr-1.6.3
./configure –prefix=/usr/local/apr配置好之后,执行make和make install
make && make install
3.安装
apr-util
,本例的版本是1.6.1
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2在解压的时候有可能遇到报错:
[root@aws src]# tar -jxvf apr-util-1.6.1.tar.bz2
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now解决的办法是:
yum -y install bzip2接下来和安装apr一样,先运行configure命令
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr然后执行安装命令:
make && make install在安装过程中可能遇到如下错误:
pr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
#incl开发云主机域名ude
^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/usr/local/src/apr-util-1.6.1解决办法是安装expat库
yum install expat-devel
4.安装
httpd
本例用的是2.4.29的版本
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz同样下载后就是解压
tar -xvzf httpd-2.4.29.tar.gz进入目录,执行configure命令
./configure –prefix=/usr/local/apache2.4 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –enable-so –enable-mods-shared=most –with-included-apr
–enable-so的意思是启用DSO,也就是把某些功能以模块(so)的形式展现出来
–enable-mods-shared=most表示以共享的方式安装大多数功能模块,安装后会在modules目录下面看到。
如果遇到下面的报错:
checking for gcc option to accept ISO C99… -std=gnu99
checking for pcre-config… false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/解决办法是:
yum install -y p开发云主机域名cre pcre-devel最后编译和安装
make
make install以上两个步骤都可以用命令echo $?来检查是否执行成功。
在make的时候可能会报错如下:
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode’
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler’
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate’
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler’
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserFree’
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetUserData’
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser’
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse’
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString’
/usr/local/apr-util/lib/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/local/src/httpd-2.4.29/support’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.29/support’
make: *** [all-recursive] Error 1解决办法是:
cp -rf /usr/local/src/apr-1.6.3 /usr/local/src/httpd-2.4.29/srclib/apr
cp -rf /usr/local/src/apr-util-1.6.1 /usr/local/src/httpd-2.4.29/srclib/apr-util
5.至此httpd就安装完成了
可以用下面的命令查看安装了那些模块:
[root@aws srclib]# /usr/local/apache2.4/bin/apachectl -M
Loaded Modules:
c开发云主机域名ore_module (static)
so_module (static)
http_module (static)
mpm_event_module (static)
authn_file_module (shared)
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (shared)
auth_basic_module (shared)
reqtimeout_module (shared)
filter_module (shared)
mime_module (shared)
log_config_module (shared)
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
unixd_module (shared)
status_module (shared)
autoindex_module (shared)
dir_module (shared)
alias_module (shared)
php5_module (shared)其中带有shared字样的,表示该模块为动态共享模块;static为静态模块。
动态和静态的区别是静态模块直接和主程序(/usr/local/apache2.4/bin/httpd)绑定在一起,我们是看不到的;而动态的模块都是一个个独立存在的文件,也就是modules目录下的.so文件
6.配置httpd支持php
a.编辑httpd.conf文件(/usr/local/apache2.4/conf/httpd.conf),搜索ServerName,把ServerName www.example.com:80前面的#去掉
b.找到如下内容
AllowOverride none
Require all denied
修改为
AllowOverride none
Require all granted
c.再搜索下面这一行
AddType application/x-gzip .gz .tgz
在上面这行下面添加
AddType application/x-httpd-php .phpd.找到下面这一段
DirectoryIndex index.html
修改为
DirectoryIndex index.html index.php
7.启动之前检查配置文件是否正确,出现Syntax OK,说明没有问题
[root@aws php-5.6.30]# /usr/local/apache2.4/bin/apachectl -t
Syntax OK
8.启动httpd的命令如下:
/usr/local/apache2.4/bin/apachectl start
9.查看是否启动的命令如下:
[root@aws srclib]# netstat -lnp | grep httpd
tcp6 0 0 :::80 :::* LISTEN 30298/httpd
10.做个简单测试,出现It works说明测试成功
[root@aws srclib]# curl localhost
关于RedHat 7怎样安装HTTPD就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
本文从转载,原作者保留一切权利,若侵权请联系删除。
《RedHat 7怎样安装HTTPD》来自互联网同行内容,若有侵权,请联系我们删除!
