天天看点

docker centos7 httpd的小坑

我的寄主机是centos6.7  3.10的内核  今天下了个镜像做docker docker容器竟然是centos7  我也是醉了

这里说下在apache简单配置里面的坑  , 由于是验证没有较多的配置 只是想实现echo hello的效果

apache是yum安装的   完事没有发现/etc/init.d/httpd脚本 也是 7都改版了  可是

systemctl start httpd.service也是不好用的

我发现安装了个命令 httpd  在/usr/sbin 下

执行httpd  报错

[root@d9706c29a233 /]# httpd

AH00526: Syntax error on line 119 of /etc/httpd/conf/httpd.conf:

DocumentRoot must be a directory

<a href="http://s1.51cto.com/wyfs02/M01/76/25/wKioL1ZL9oaRdmoWAAEjFf4tra0241.jpg" target="_blank"></a>

119行是 DocumentRoot "/var/www/html"  没有路径

解决办法

mkdir -p /var/www/html

chown apache:apache !$

然后执行报错:

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.6. Set the 'ServerName' directive globally to suppress this message

(2)No such file or directory: AH02291: Cannot access directory '/etc/httpd/logs/' for main error log

AH00014: Configuration check failed

<a href="http://s2.51cto.com/wyfs02/M02/76/28/wKiom1ZL9kjig6-XAAK9QKlVFfw861.jpg" target="_blank"></a>

大概意思是servername不对  和 没有路径 /etc/httpd/logs

sed -i 's@#ServerName www.example.com@ServerName localhost@' /etc/httpd/conf/httpd.conf  

/etc/httpd/logs -&gt; /var/log/httpd  软连接  只需要创建/var/log/httpd 就可以了

mkdir /var/log/httpd 

echo 'hello' &gt; /var/www/html/index.html

再次启动

httpd  

curl 127.0.0.1

访问成功

本文转自    憬薇   51CTO博客,原文链接:http://blog.51cto.com/welcomeweb/1713948