欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

Ubuntu Server 10.04修改Apache的默认目录的方法

程序员文章站 2023-11-23 16:12:58
在ubuntu server 10.04中默认由apt方式安装的apache,指定网页主目录位于:/var/www。而我需要将其更改为: /home/www。因为我的系统/...

在ubuntu server 10.04中默认由apt方式安装的apache,指定网页主目录位于:/var/www。而我需要将其更改为: /home/www。因为我的系统/var所分到的空间太少,而我又有提供通过web方式提供网络存储的需要。比较糟糕的是:我的/etc /apache2/sites-enabled/000-default文件在修改后消失掉了。结果导致apache服务出现错误,网站不能运行了。在最后一部分我记录了如何解决这个问题。

一、查找apache的配置文件

# cd /etc/apache2/
发现apache2.conf和httpd.conf文件,没有找到关于目录修改的配置,且http.conf为空文件。

二、上网搜索

apache2.conf里并没有documentroot项,httpd.conf又是空的,www.linuxidc.com因此肯定在其他的文件中。经过搜索,发现在/etc /apache2/sites-enabled/000-default中,里面有这样的内容:

复制代码 代码如下:

<virtualhost *:80>
serveradmin webmaster@localhost

documentroot /var/www
<directory />
options followsymlinks
allowoverride none
</directory>
<directory /var/www />
options indexes followsymlinks multiviews
allowoverride none
order allow,deny
allow from all
</directory>

scriptalias /cgi-bin/ /usr/lib/cgi-bin/
<directory “/usr/lib/cgi-bin”>
allowoverride none
options +execcgi -multiviews +symlinksifownermatch
order allow,deny
allow from all
</directory>

修改方法:将上面的/var/www修改为/home/www即可。

三、找回丢失的/etc /apache2/sites-enabled/000-default文件

不知何种原因,000-default竟然丢了,apache服务也不能正常运行了。还好我有一个备用服务器,经查000-default实际上是一个软链接,指向../sites-available/default文件。

# cd /etc /apache2/sites-enabled/
# ln -s ../sites-available/default 000-default
# /etc/init.d/apache2 restart

* 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
…done.
===由上面apache启动的反馈信息,可以看到apache还是有一点小问题的,不过不影响。

下表为空间分配。

filesystem size used avail use% mounted on
/dev/sda5 1.9g 36m 1.8g 2% /tmp
/dev/sda9 209m 21m 177m 11% /boot
/dev/sda1 276g 7.0g 255g 3% /home
/dev/sda6 8.6g 670m 7.5g 9% /usr
/dev/sda3 1.9g 186m 1.6g 11% /var