首页 > 技术文章 > Ubuntu18.4中Apache在加不同端口的虚拟主机

gispathfinder 2019-03-28 15:42 原文


1.添加监听端口

sudo vim /etc/apache2/ports.conf


Listen 80
Listen 6080
<IfModule ssl_module>
         Listen 443
</IfModule>

<IfModule mod_gnutls.c>
         Listen 443
</IfModule>


2.添加虚拟主机配置

sudo vim /etc/apache2/sites-available/gisas.conf


<VirtualHost *:6080>

        #ServerName www.example.com

        ServerAdmin webmaster@localhost
         DocumentRoot /var/www/html

       <Directory /var/www/html>
                   Options Indexes FollowSymLinks MultiViews
                   AllowOverride None
                   Order allow,deny
                   allow from all
         </Directory>

        #Rewrite
         RewriteEngine On


         ErrorLog ${APACHE_LOG_DIR}/error-gisas.log
         CustomLog ${APACHE_LOG_DIR}/access-gisas.log combined

        WSGIDaemonProcess gisas user=my group=my threads=5
         WSGIScriptAlias / /var/www/apps/gisas/gisas.wsgi
         <Directory "/var/www/apps/gisas/">
             WSGIProcessGroup gisas
             WSGIApplicationGroup %{GLOBAL}
             Order allow,deny
             Allow from all
         </Directory>


</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


3.应用虚拟主机配置

sudo a2ensite gisas


4.重启服务

sudo systemctl restart apache2

推荐阅读