Apache

Apache基本配置

安裝apache軟件包:

     yum install -y httpd httpd-manual

啓動apache服務:

    # systemctl start httpd ; systemctl enable httpd

查看監聽端口:

wKioL1hJBBDCHZ0nAADFxHmVsis832.png-wh_50


 

 

##1.修改默認訪問文件

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

        164     DirectoryIndex file index.html##優先訪問前者

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

wKioL1hJBD-DB6XKAAB6CDQTLJ4813.png-wh_50

 

##2.修改默認訪問路徑

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

wKiom1hJBFbjiDhTAAC-4yxzJnU049.png-wh_50

[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

wKiom1hJBITip0PxAABvIL0bYtw767.png-wh_50

 

 

 

 

 

##3.設置黑白名單

 

 

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

wKioL1hJBJ3w47WOAADlovIGPkQ391.png-wh_50

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

wKioL1hJBLaDhqV-AACemLKrLMU047.png-wh_50

 

 

 


 

##4.登陸帳號密碼驗證


wKioL1hJBNfQwuWSAAEtnnS1Hxc255.png-wh_50

[root@linux conf]# vim httpd.conf

wKiom1hJBO-S-_pLAACribasslE824.png-wh_50

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

 

測試:

wKioL1hJBSSg1ILyAAHgc44Uskc075.png-wh_50

 

 

 

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

wKioL1hJBT7iMfPfAACcKj6_h84167.png-wh_50

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

wKiom1hJBVeS8vUHAACiIGOGBvQ023.png-wh_50

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

wKioL1hJBWuBjLefAACeP4eDj5c150.png-wh_50

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

 

測試:

wKiom1hJBZbgWIxNAABzZ_hW-fQ516.png-wh_50

wKioL1hJBZeSGatdAABxvDjf7Ro484.png-wh_50

wKiom1hJBZnQmo14AAB4Nkm3Yag352.png-wh_50


 

 

 

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

wKioL1hJBdKg0TyLAAFhhJq24Dw397.png-wh_50

wKiom1hJBdPztGnGAAFh1_HmF54301.png-wh_50


 

wKiom1hJC2fj473JAAFUB6BBWxM277.png-wh_50

wKioL1hJC2mSd5qUAADSgDzcxlw384.png-wh_50

wKiom1hJC2yR6e4FAADo_ffNmuQ113.png-wh_50


 

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

wKioL1hJC4fQFx2VAADsJIdqqpg997.png-wh_50

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

 

 

測試:

wKiom1hJC5ewQd3IAAGPtiBHSBE031.png-wh_50

wKioL1hJC5nh2jOpAAEwJK3iqlM598.png-wh_50



 

 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章