Linux 下安装 apache

 1、检查是否已经安装过 apache (linux 中 apache 的名字是 httpd)

     rpm -qa  httpd

   

2、如果没有安装过,运行如下命令

    yum install httpd -y

   安装完成后再次运行 rpm -qa httpd

   

    安装完 apache 后需要知道的一些常识,比如服务目录、配置文件、日志文件等的目录

    服务主目录: /etc/httpd

    配置文件目录: /etc/httpd/conf/httpd.conf

    网站数据目录:/var/www/html

    访问日志:/var/log/httpd/access_log

    错误日志:/var/log/httpd/error_log

3、启动服务

   报下面这种错误,两个问题:

    1)httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

    2)Address already in use:make_sock:could not bind to address [::]:80

解决第一个问题:修改配置文件(默认路径为 /etc/httpd/conf/httpd.conf),设置 ServiceName localhost:80

    vi  /etc/httpd/conf/httpd.conf

   设置 ServiceName  localhost:80 ,保存后再次运行,只剩下第二种报错

  解决第二个问题:

   1)查看 SELINUXTYPE 是否为 targeted

    cat  /etc/selinux/config/grep SELINUXTYPE

   

   2)修改 SELINUX=enforcing 为 disabled

    vi /etc/selinux/config

   

   修改成功之后,重启,再次启动 httpd 服务,如果还是报这种错误,修改 (/etc/httpd/conf/httpd.conf )监听端口。最好不要用 95 端口

    

   修改完之后,再次重启,查看是否启动成功

    

     噔噔,启动成功啦~ ,浏览器输入地址访问

 

posted @ 2019-03-22 21:21  biubiubiu83  Views(132)  Comments(0Edit  收藏  举报