CentOs7 搭建http服务器访问文件目录

## 1、安装http服务器

yum install httpd

2、检查版本

httpd -version

3、修改http文件服务器的文件目录配置文件

sudo vi /etc/httpd/conf/httpd.conf

例如要配置访问目录为: /appdata/logs

3.1、找到DocumentRoot "/var/www/html"

修改根目录为 /appdata/logs

3.2、找到Directory

一、修改 # Relax access 下的Directory

<Directory "/appdata">

二、修改 # Further relax access to the default document root: 下的Directory

<Directory "/appdata/logs">

4、httpd服务器开启目录

sudo vi /etc/httpd/conf.d/welcome.conf

把Options -Indexes中的减号改为加号

此处作用为访问目录的时候能显示目录结构

5、给开放的文件夹授权

# 755或者777均可 (二选一:最好是777,因为它具有写权限)
# 755: rwxr-xr-x
sudo chmod -R 755 /appdata/logs
# 777: rwxrwxrwx
sudo chmod -R 777 /appdata/logs

6、重启或启动服务

systemctl start httpd

重启systemctl restart httpd

卸载yum erase httpd.x86_64

6、地址栏访问公网地址

访问 http://115.30.149.34/ 即可看到对应的文件目录

7、重启后依旧无法访问http服务器

临时关闭SELINUX

#设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
setenforce 0

永久关闭SELINUX

vi /etc/selinux/config

将 SELINUX=enforcing 改为 SELINUX=disabled ,设置后需要重启才能生效。

参考链接:https://www.cnblogs.com/snake553/p/8856729.html

posted @ 2020-08-30 14:16  罗智炼  阅读(2700)  评论(0编辑  收藏  举报