Ubuntu 20.04 Apache2 增加不同端口站点

概述

在这里插入图片描述
       Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器软件,可以在大多数电脑操作系统中运行。由于其跨平台和安全性[注 1],被广泛使用,是最流行的Web服务器软件之一。它快速、可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中。

 
     装好apache2后,默认会有一个80端口的默认站点,可以通过浏览器访问localhost, 在此基础上,如何增加一个9501端口的站点?

步骤

  1. 增加站点

创建文件:/etc/apache2/sites-available/video.conf

<VirtualHost *:9501>
	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html/video/
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  1. 使能站点
sudo a2ensite video.conf
  1. 增加监听端口9501
cat /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 9501

<IfModule ssl_module>
	Listen 443
</IfModule>

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

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

增加一行:Listen 9501

  1. 重启:
systemctl restart apache2

访问:localhost:9501
在这里插入图片描述

参考

Install and Configure Apache
How to Configure Multiple Sites with Apache
Make Apache Web Server Listen on Two Different Ports
Ubuntu下apache2启动、停止、重启、配置

猜你喜欢

转载自blog.csdn.net/ansondroider/article/details/131108657