首页 > 开发 > Apache > 正文

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

2020-04-16 19:27:14
字体:
来源:转载
供稿:网友

在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

您可能感兴趣的文章:

详解CentOS7安装配置Apache HTTP Serverapache You don''t have permission to access /test.php on this server解决方法Apache2.4.x版wampserver本地php服务器如何让外网访问及启用.htaccessWin2003+apache+PHP+SqlServer2008 配置生产环境WampServer设置apache伪静态出现404 not found及You don''t have permission to access / on this server解决方法分析Apache中启用Server Status配置示例Moon_LServer Linux下一键搭建Apache+PHP+MySQL+Zend+PHPMyAdmin+GD库的软件Apache实现Web Server负载均衡详解(不考虑Session版)WampServer下安装多个版本的PHP、mysql、apache图文教程Linux下Apache HTTP Server 2.4.26安装教程
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表