apache1

Apache基本配置

安装apache软件包:

     yum install -y httpd httpd-manual

启动apache服务:

    # systemctl start httpd ; systemctl enable httpd

apache1_第1张图片

查看监听端口:

apache1_第2张图片

1.修改默认访问文件

[root@linux thunderbird]# vim /etc/httpd/conf/httpd.conf

        164     DirectoryIndex file index.html##优先访问前者

[root@linux html]# systemctl restart httpd.service

apache1_第3张图片

 

##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

apache1_第4张图片

 

 3.设置黑白名单

 

[root@linux westos]# vim /etc/httpd/conf/httpd.conf

apache1_第5张图片

[root@linux westos]# systemctl restart httpd.service

apache1_第6张图片

 

 

4.登陆帐号密码验证


apache1_第7张图片

[root@linux conf]# vim httpd.conf

apache1_第8张图片


[root@linux conf]# systemctl restart httpd.service

测试:

apache1_第9张图片

 

 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

apache1_第10张图片

[root@linux conf.d]# vim news.conf

apache1_第11张图片

[root@linux conf.d]# vim gongyi.conf

apache1_第12张图片

[root@linux conf.d]# systemctl restart httpd.service


测试:

apache1_第13张图片

apache1_第14张图片


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

apache1_第15张图片

apache1_第16张图片apache1_第17张图片


 

[root@linux conf.d]# vim ssl.conf

[root@linux conf.d]# systemctl restart httpd.service

 

 





你可能感兴趣的:(apache1)