安装
首先安装httpd
yum -y install httpd
配置
修改欢迎页面
vim /etc/httpd/conf.d/welcome.conf
将Options -Indexes
改为Options +Indexes
如下:
<LocationMatch "^/+$">
#修改的地方
Options +Indexes
ErrorDocument 403 /.noindex.html
</LocationMatch>
<Directory /usr/share/httpd/noindex>
AllowOverride None
Require all granted
</Directory>
Alias /.noindex.html /usr/share/httpd/noindex/index.html
Alias /noindex/css/bootstrap.min.css /usr/share/httpd/noindex/css/bootstrap.min.css
Alias /noindex/css/open-sans.css /usr/share/httpd/noindex/css/open-sans.css
Alias /images/apache_pb.gif /usr/share/httpd/noindex/images/apache_pb.gif
Alias /images/poweredby.png /usr/share/httpd/noindex/images/poweredby.png
修改监听端口
先找到配置文件
vim /etc/httpd/conf/httpd.conf
找到Listen 80
将80修改为想要更换的端口,例如改为8000端口 如下
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 8000
重启httpd服务
systemctl restart httpd
添加文件
httpd的默认根文件夹路径为 /var/www/html
可以如下操作
cd /var/www/html
touch README.md
mkdir test
访问
浏览器打开{ip}:{端口号}
即可访问,例如localhost:8000