RedHat 7 安装HTTPD
1.查看操作系统版本
2.首先安装apr,本例子是1.6.3版本
下载之后就是解压
进入apr目录,执行configure命令,该命令本例就一个参数 ,设置安装目录
配置好之后,执行make和make install
3.安装
apr-util
,本例的版本是1.6.1
在解压的时候有可能遇到报错:
解决的办法是:
接下来和安装apr一样,先运行configure命令
然后执行安装命令:
在安装过程中可能遇到如下错误:
解决办法是安装expat库
4.安装
httpd
本例用的是2.4.29的版本
同样下载后就是解压
进入目录,执行configure命令
-
-
enable
-
so的意思是启用DSO,也就是把某些功能以模块(so)的形式展现出来
- - enable - mods - shared = most表示以共享的方式安装大多数功能模块,安装后会在modules目录下面看到。
如果遇到下面的报错:
解决办法是:
最后编译和安装
以上两个步骤都可以用命令echo $?来检查是否执行成功。
在make的时候可能会报错如下:
解决办法是:
5.至此httpd就安装完成了
可以用下面的命令查看安装了那些模块:
其中带有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.找到如下内容
c.再搜索下面这一行
d.找到下面这一段
7.启动之前检查配置文件是否正确,出现Syntax OK,说明没有问题
8.启动httpd的命令如下:
9.查看是否启动的命令如下:
10.做个简单测试,出现It works说明测试成功
欢迎访问我的另一篇文章,RedHat 7 安装PHP
http://blog.itpub.net/20893244/viewspace-2151185/
- [root@aws srclib]# cat /etc/redhat-release
- Red Hat Enterprise Linux Server release 7.4 (Maipo)
- wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
- tar -xzvf apr-1.6.3.tar.gz
- cd /usr/local/src/apr-1.6.3
- ./configure --prefix=/usr/local/apr
- make && make install
- 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
- ./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
- #include <expat.h>
- ^
- compilation terminated.
- make[1]: *** [xml/apr_xml.lo] Error 1
- make[1]: Leaving directory `/usr/local/src/apr-util-1.6.1
- yum install expat-devel
本例用的是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 --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 - 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 pcre pcre-devel
- make
- make install
在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:
- core_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)
动态和静态的区别是静态模块直接和主程序(/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.找到如下内容
- <Directory />
- AllowOverride none
- Require all denied
- </Directory>
- 修改为
- <Directory />
- AllowOverride none
- Require all granted
- </Directory>
- AddType application/x-gzip .gz .tgz
- 在上面这行下面添加
- AddType application/x-httpd-php .php
- <IfModule dir_module>
- DirectoryIndex index.html
- </IfModule>
- 修改为
- <IfModule dir_module>
- DirectoryIndex index.html index.php
- </IfModule>
- [root@aws php-5.6.30]# /usr/local/apache2.4/bin/apachectl -t
- Syntax OK
- /usr/local/apache2.4/bin/apachectl start
- [root@aws srclib]# netstat -lnp | grep httpd
- tcp6 0 0 :::80 :::* LISTEN 30298/httpd
- [root@aws srclib]# curl localhost
- <html><body><h1>It works!</h1></body></html>
欢迎访问我的另一篇文章,RedHat 7 安装PHP
http://blog.itpub.net/20893244/viewspace-2151185/
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20893244/viewspace-2151184/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/20893244/viewspace-2151184/