CentOS7中使用httpd搭建文件服务器

1.安装httpd

yum -y install httpd


2.修改配置文件

vim /etc/httpd/conf/httpd.conf 


<Directory />

    Options FollowSymLinks

    AllowOverride none

    Require all denied

</Directory>


<Directory "/var/www">

    Options Indexes FollowSymLinks

    AllowOverride None

    # Allow open access:

    Require all granted

</Directory>


<Directory "/var/www/html">

    #

    # Possible values for the Options directive are "None", "All",

    # or any combination of:

    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

    #

    # Note that "MultiViews" must be named *explicitly* --- "Options All"

    # doesn't give it to you.

    #

    # The Options directive is both complicated and important.  Please see

    # http://httpd.apache.org/docs/2.4/mod/core.html#options

    # for more information.

    #

    #

    # AllowOverride controls what directives may be placed in .htaccess files.

    # It can be "All", "None", or any combination of the keywords:

    #   Options FileInfo AuthConfig Limit

    #

    AllowOverride None



    #

    # Controls who can get stuff from this server.

    #

    Require all granted

</Directory>


3.配置文件中默认用户名与分组

User apache

Group apache


授权

chmod -R 775 /var/www/html/

chown -R apache:apache /var/www/html/


4.删除欢迎页面

rm -rf /etc/httpd/conf.d/welcome.conf


5.重启服务

systemctl restart httpd


6.关闭selinux

vim /etc/selinux/config
SELINUX=disabled
# 临时关闭
setenforce 0


注意:如果遇到错误 centos7 You don't have permission to access / on this server. 仔细检查上面配置,不要漏掉了,本人漏配置了一个就造成了这个error。


 

展开阅读全文