分类: LINUX
2013-12-20 11:01:33
原文地址:Fedora安装apache 作者:fly123456789
1.1使用yum进行安装:
# yum install httpd
1.2配置Apache能够随系统启动而启动
#chkconfig –levels 235 httpd on
1.3启动/关闭Apache服务:
#service httpd start
#service httpd stop
或者命令启动/关闭Apache:
#/etc/init.d/httpd start
#/etc/init.d/httpd stop
1.4查看80端口是否启动:
#cat /etc/services |grep 80
1.5开通80端口:
#vi /etc/sysconfig/iptables
在22端口下面加入80端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
然后保存退出vi.
开机启动
继续折腾 Fedora 16 ,这次是 httpd。
通过 VirtualBox 安装完 Fedora 16 ,本想继续安装 Apache ,然后
# rpm -qa | grep httpd
发现已经安装了。
于是我想让她开机自启动:
# systemctl is-enabled httpd.service
有这个服务,但没有自启动,屏幕显示
disabled
于是,让她开机自启动
# systemctl enable httpd.service
再查看
# systemctl is-enabled httpd.service
屏幕显示
enabled
成功,重启一下:
# reboot
问题来了,重启之后,依然无法启动 Apache
# systemctl start httpd.service
Job failed. See system logs and 'systemctl status' for details.
查寻日志 /var/log/message
Unit httpd.service entered failed state
查寻 systemctl status:
# systemctl status httpd.service
有以下信息:
ExecStart=/usr/sbin/httpd $OPTIONS -k start (code=dumped, signal=SEGV)
果断上网搜索,似乎是 Apache 的配置文件有问题,
httpd.service 会检测配置文件,配置文件没有错误后方可启动 httpd 。
而且出问题的应该是
mod_perl.so
# vi /etc/httpd/conf.d/perl.conf
将
LoadModule perl_module modules/mod_perl.so
前面添加 # 注释。
:wq 保存退出。
如此 Apache 便不会加载 mod_perl 模块,测试一下:
# systemctl start httpd.service
# systemctl status httpd.service
httpd.service - The Apache HTTP Server (prefork MPM)
Loaded: loaded (/lib/systemd/system/httpd.service; enabled)
Active: active (running) since Fri, 11 Nov 2011 14:50:12 +0800; 55s ago
Process: 1752 ExecStop=/usr/sbin/httpd $OPTIONS -k stop (code=exited, status=0/SUCCESS)
Process: 1825 ExecStart=/usr/sbin/httpd $OPTIONS -k start (code=exited, status=0/SUCCESS)
Main PID: 1826 (httpd)
CGroup: name=systemd:/system/httpd.service
├ 1826 /usr/sbin/httpd -k start
├ 1828 /usr/sbin/httpd -k start
├ 1829 /usr/sbin/httpd -k start
├ 1830 /usr/sbin/httpd -k start
├ 1831 /usr/sbin/httpd -k start
├ 1832 /usr/sbin/httpd -k start
├ 1833 /usr/sbin/httpd -k start
├ 1834 /usr/sbin/httpd -k start
└ 1835 /usr/sbin/httpd -k start
成功,重启之后
netstat -tnl | grep 80
果然看到 80 端口已经开启。
如果还不行,请执行:
#restorecon -R -v /var