Ubuntu上apache2多端口配置虚拟主机

329 阅读1分钟

 1:添加监听端口

cd /etc/apache2

在文件里添加

NameVirtualHost *:8080
Listen 8080

2:配置虚拟目录

#cp只是备份

vim /default-ssl.conf

文件内容如下

<VirtualHost *:8080>

    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/8080

   

        Options FollowSymLinks

        AllowOverride None

   

    <Directory /var/www/8080/>

        Options Indexes FollowSymLinks MultiViews

        AllowOverride None

        Order allow,deny

        allow from all

   

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,

    # alert, emerg.

    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

3:重启服务

/etc/init.d/apache2

最后80和8080端口都可以访问了

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Ubuntu上更改apache访问端口

进入apache

修改配置文件

将此处改为想更改的端口

保存退出

重启服务

访问成功

 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

不同端口不同内容

编辑配置文件

在最后追加内容

进入/var/www

cd /var/www

并创建对应的文件夹

并创建index.html写上想写的内容

 如果页面中文乱码

在index.html开头加上

<meta http-equiv="Content-Type" content="textml;charset=utf-8"/>