首页 > 代码库 > Apache
Apache
Apache基本配置
安装apache软件包:
yum install -y httpd httpd-manual
启动apache服务:
# systemctl start httpd ; systemctl enable httpd
查看监听端口:
##1.修改默认访问文件
[root@linux thunderbird]# vim /etc/httpd/conf/httpd.conf
164 DirectoryIndex file index.html##优先访问前者
[root@linux html]# systemctl restart httpd.service
##2.修改默认访问路径
[root@linux html]# vim /etc/httpd/conf/httpd.conf
[root@linux html]# mkdir /www/westos -p
[root@linux html]# semanage fcontext -a -t httpd_sys_content_t ‘‘
[root@linux html]# semanage fcontext -a -t httpd_sys_content_t ‘/www/westos(/.*)?‘
[root@linux html]# restorecon -RvvF /www/
restorecon reset /www context unconfined_u:object_r:default_t:s0->system_u:object_r:default_t:s0
restorecon reset /www/westos context unconfined_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0
[root@linux westos]# vim file
[root@linux westos]# ls -Z
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 file
[root@linux westos]# systemctl restart httpd.service
##3.设置黑白名单
[root@linux westos]# vim /etc/httpd/conf/httpd.conf
[root@linux westos]# systemctl restart httpd.service
##4.登陆帐号密码验证
[root@linux conf]# vim httpd.conf
[root@linux conf]# systemctl restart httpd.service
测试:
##5.制作多个同域名网站
客户端:
[root@foundation99 Desktop]# vim /etc/hosts
172.25.99.100 linux.com linux.linux.com music.linux.com news.linux.com
主机端:
[root@linux conf]# mkdir -p /var/www/virtual/music.linux.com/html
[root@linux conf]# mkdir -p /var/www/virtual/news.linux.com/html
[root@linux conf]# cd /etc/httpd/conf.d/
[root@linux conf.d]# vim default.conf
[root@linux conf.d]# vim news.conf
[root@linux conf.d]# vim music.conf
[root@linux conf.d]# systemctl restart httpd.service
测试:
##6.https:安全证书修改
主机端:
[root@linux html]# yum install mod_ssl.x86_64 -y
[root@linux html]# systemctl restart httpd.service
[root@linux html]# netstat -natlpe |grep 443
tcp6 0 0 :::443 :::* LISTEN 0 84700 6162/httpd
[root@linux html]# yum install crypto-utils.x86_64 -y
[root@linux html]# genkey www.linux.com
[root@linux conf.d]# vim ssl.conf
[root@linux conf.d]# systemctl restart httpd.service
测试:
本文出自 “12110289” 博客,谢绝转载!
Apache