apache 配置网站目录,虚拟目录,新端口

1 配置网站目录,以ubuntu为例

   1)打开apache的默认配置文件夹:cd /etc/apache2/sites-available  

   2)打开配置文件,本机为sudo vi  000-default.conf

   3) 修改路径

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /data/test

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

</VirtualHost>

2 配置虚拟目录,以windows为例

1)打开httpd.conf,新增一行代码

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "D:/cgi-bin/"
    # 设置站点别名,别名与访问路径是相关的,取任何名称都可以(除特殊)  
    Alias /test "E:/test "  
    
</IfModule>

2) 接着添加下面几行代码

<Directory E:/test>  
    Options Indexes FollowSymLinks     
    AllowOverride None     
    Order allow,deny     
    Allow from all  
</Directory>  

3 配置新端口,以ubuntu为例

1)打开apache的默认配置文件夹:cd /etc/apache2/

2)修改端口文件 sudo vi ports.conf 新增一行

Listen 80
Listen 83

3)切换配置默认目录 cd /etc/apache2/sites-available  

4)配置新增的端口映射sudo vi  000-default.conf 添加几行代码

<VirtualHost *:83>

        ServerAdmin webmaster@localhost
        DocumentRoot /data/newtest

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

</VirtualHost>

4 以上操作之后,均需要重启apache,以ubuntu为例

  sudo /etc/init.d/apache2 restart

 

转载于:https://www.cnblogs.com/mengsx/p/5066706.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值