shell># cd /home/jinnan/tar
shell># tar -jxvf httpd-2.2.19.tar.bz2
shell># cd httpd-2.2.19
shell>#./configure --prefix=/usr/local/http2 \
--enable-modules=all \
--enable-mods-shared=all \
--enable-so
shell># make && make install
启动Apache
shell># /usr/local/http2/bin/apachectl start/stop/restart
报错:
[root@study http2]# bin/apachectl start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
解决方法:更改httpd.conf监听的端口为8080
重启httpd 服务 不报错,但是不执行
shell># service httpd restart
shell># /usr/local/http2/bin/apachectl restart 不报错
查看Apache的error_log日志
shell># cat /usr/local/http2/logs/error_log
报错内容如下:
[Wed Aug 29 15:33:51 2018] [alert] (EAI 3)Temporary failure in name resolution: mod_unique_id: unable to find IPv4 address of "study"
Configuration Failed
百度翻译:名称解析的临时失败:MMOTUnQuiGID:无法找到“study”的IPv4地址
解决方法:
vi /etc/hosts
#add line
127.0.0.1 name #我这里的name是study
Linux系统打开浏览器,输入127.0.0.1:8080,显示it works!
系统内部可以访问,虚拟机外却不可以访问,执行shell>#Service iptables status
检查发现linux系统的8080端口未开放
1.开放Linux的8080端口
shell># vi /etc/sysconfig/iptables
进入编辑页面,在指定位置新增以下配置
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
这句要放在 -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT 后面
2.修改完保存退出,重启网卡服务
shell>#service iptables restart
3.查看端口开放信息
shell>#Service iptables status
非虚拟机系统,可以用站长工具的端口扫描查看端口是否开发
站长工具地址:http://tool.chinaz.com/port/
修改Apache的默认访问目录
第一步打开配置文件
shell># vi /usr/local/http2/conf/httpd.conf
第二步修改配置内容
|
注:如果默认访问的新地址是在/home目录下,则要修改:
|
并且要注意访问的权限问题
第三步重启Apache服务器
shell># ./apachectl restart