修改apache2的默认端口,默认网站目录和默认主页文档

通过Ubuntu 搭建WEB服务器,必须首先修改apache2的默认80端口,因为这个端口往往会被电信商以保护用户网络完全为由而关闭掉,

值得注意的时,8080端口也有可能被封掉,我就遇到了这个问题,导致我在apache2配置上找了半天原因,可气的服务商!


不管怎样,只要你选择合适的端口(电信商没有封的),进行如下的设置即可:

1, 修改 /etc/apache2/ports.conf 将

NameVirtualHost *:80
Listen 80

改为自己需要的端口

NameVirtualHost *:9000
Listen 9000
2,修改/etc/apache2/sites-available/default 将第一行的
<VirtualHost *:80>

改为自己需要的端口

<VirtualHost *:9000>
3,修改 /etc/init.d/apache2/httpd.conf 添加
Servername localhost

否则重启时会报如下错误

 * Restarting web server apache2                                                
 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
                                                                         [ OK ]
4,重启apache
sudo /etc/init.d/apache2 restart

端口修改完毕。apache的端口修改为9000了。


###########################################

修改默认网站目录:

/etc/apache2/sites-available/default 

将/var/www 修改位你的路径: /var/www/GMG/

修改默认主页文档:

/etc/apache2/mods-available/dir.conf

将 index.* 替换为 xxx.* 


不过随apache2的版本不同 文件的放置位置不一样  
输入这个命令 grep -iR DirectoryIndex /etc/apache2
查看 DirectoryIndex 在apache2哪个文件里面。
我的Ubuntu 12.04是这样的
/etc/apache2/mods-enabled/dir.conf:          DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
/etc/apache2/mods-available/dir.conf:          DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值