apache單ip配置多連接埠多網站

來源:互聯網
上載者:User

標籤:

1.修改 /etc/httpd/conf/httpd.conf

添加一個Listen,如:

Listen 80Listen 8001Listen 8002

 

2.添加一個VirtualHost

#vim /etc/httpd/conf.d/vhost.confNameVirtualHost *:8001<VirtualHost *:8001>    DocumentRoot /var/www/html/public_html    ServerName localhost    ServerAdmin [email protected]    #ErrorLog "| /usr/sbin/rotatelogs /var/www/html/log/public_html_error_%Y_%m_%d.log 86400 480"    #CustomLog "| /usr/sbin/rotatelogs /var/www/html/log/public_html_access_%Y_%m_%d.log 86400 480" common    ErrorLog "/var/www/html/log/error.log"    CustomLog "/var/www/html/log/access.log" common</VirtualHost>NameVirtualHost *:8002<VirtualHost *:8002>    DocumentRoot /var/www/html/phpmyadmin    ServerName localhost    ServerAdmin [email protected]    #ErrorLog "| /usr/sbin/rotatelogs /var/www/html/log/public_html_error_%Y_%m_%d.log 86400 480"    #CustomLog "| /usr/sbin/rotatelogs /var/www/html/log/public_html_access_%Y_%m_%d.log 86400 480" common    ErrorLog "/var/www/html/log/error.log"    CustomLog "/var/www/html/log/access.log" common</VirtualHost>

 

3.為新連接埠添加防火牆規則

iptables -I INPUT -p tcp --dport 8001 -j ACCEPT/etc/rc.d/init.d/iptables save

 

4.禁用selinux(如果不禁用,會無法重新啟動apache)

方法1.關閉selinux

vim /etc/selinux/config

首先將SELINUX=enforcing添加註釋

#SELINUX=enforcing

然後在檔案末尾添加如下代碼

SELINUX=disabled

方法2.修改selinux規則
首先查看現在支援http的連接埠有哪些

semanage port -l | grep http

然後為http服務新的連接埠號碼

semanage port -a -t http_port_t -p tcp 8001

查看添加的結果

semanage port -l | grep http

 

5.重啟httpd服務

service httpd restart

 

apache單ip配置多連接埠多網站

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.