1.增加端口映射目录配置,这里在 /var/www/目录下增加static文件夹作为静态资源存放目录,并在/etc/apache2/sites-available/目录下创建端口映射配置文件static.conf
sudo mkdir /var/www/static
sudo vim /etc/apache2/sites-available/static.conf
2.static.conf 设置映射端口,例如8888
<VirtualHost *:8888>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/static
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- /etc/apache2/sites-enabled/目录下创建端口配置文件软链接
sudo ln -s ../sites-available/static.conf static.conf
- /etc/apache2/ports.conf 增加Listen端口
sudo vim /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
Listen 8888 #增加8888端口监听
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
5.修改完成,重启apache2服务
sudo service apache2 reload
网友评论