CentOS配置虛擬主機virtualhost使服務器支持多網(wǎng)站多域名的方法
本文實例講述了CentOS配置虛擬主機virtualhost使服務器支持多網(wǎng)站多域名的方法。分享給大家供大家參考,具體如下:
如何讓centos(redhat)配置虛擬主機,讓服務器支持多個網(wǎng)站,針對Apache,只需要你修改apache配置文件/etc/httpd/conf/httpd.conf即可。
里面有個example文件,你只要對應配置即可。
#<VirtualHost *:80> # ServerAdmin webmaster@dummy-host.example.com # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #</VirtualHos>
你可以參照我的配置,在httpd.conf最底部添加:
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html ServerName www.yourweb.com #ErrorLog /var/log/httpd/yourweb/error_log #注意,這里我設(shè)置了以天為單位生產(chǎn)日志 ErrorLog "|rotatelogs /var/log/httpd/yourweb/error_log%Y_%m_%d.log 86400 480" #CustomLog /var/log/httpd/yourweb/access_log common CustomLog "|rotatelogs /var/log/httpd/yourweb/access_log%Y_%m_%d.log 86400 480" common </VirtualHost> <VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/blog ServerName blog.yourweb.com ErrorLog /var/log/httpd/blog/error_log CustomLog /var/log/httpd/blog/access_log common </VirtualHost>
如上我配置了兩臺虛擬主機:域名分別為www.yourweb.com blog.yourweb.com
注意,重啟apache后才生效(service httpd restart)
希望本文所述對大家CentOS服務器管理有所幫助。
相關(guān)文章
MIME類型大全(response.setContentType中MIME參數(shù)類型總結(jié))
MIME類型就是設(shè)定某種擴展名的文件用一種應用程序來打開的方式類型,當該擴展名文件被訪問的時候,瀏覽器會自動使用指定應用程序來打開。多用于指定一些客戶端自定義的文件名,以及一些媒體文件打開方式2017-07-07
使用Keepalived如何實現(xiàn)SFTP服務的高可用
這篇文章主要介紹了使用Keepalived如何實現(xiàn)SFTP服務的高可用問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-04-04
php.ini 啟用disable_functions提高安全
如果想保證服務器的安全,請將這個函數(shù)加到disable_functions里或者將安全模式打開吧,在安全模式下dl函數(shù)是無條件禁止的2009-07-07

