apache2 配置虚拟主机

查看 apache2 的配置位置: whereis apache2

 

我的在:/etc/apache2

 

 

sites-available  文件夹下面放的就是 虚拟站点的配置文件:

 

随便复制一个改改: cp ebgback.conf  test.conf

 

<VirtualHost *:9000>
    DocumentRoot "/var/www/html/ebgback"
</VirtualHost>

  

 

修改端口和 文件目录

VirtualHost *:9000  改制你想要的占用 的端口。  比如 2080。
DocumentRoot "/var/www/html/ebgback"  改成你放 静态文件的目录。 比如:DocumentRoot "/var/www/html/test"


去创建对应的 目录:mkdir /var/www/html/test

加入端口: vi ports.conf

 

然后 apache2 就可以了 :service apache2 restart 

 

实测: 2080 端口不能用,可能端口太低 不让用.  改成14000 就可以了。

 





引用一片别人的一篇 关于 apache2的 配置:https://www.cnblogs.com/starof/p/4278370.html



配置首页: DirectoryIndex index index.html ,就是 什么都 不带的 时候默认访问的 首页地址。
  <Directory "/var/www/html/slb-pay">
                #<IfModule mod_rewrite.c>
                  RewriteEngine On
                  RewriteBase /
                  RewriteRule ^index\.html$ - [L]
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule . /index.html [L]
                #</IfModule>
                AllowOverride All
                #Options +Indexes
                Options FollowSymLinks
                Order allow,deny
                Allow from all
                DirectoryIndex index index.html
        </Directory>

 






 

posted on 2018-10-10 12:01  zhangyukun  阅读(205)  评论(0编辑  收藏  举报

导航