今天是: 收藏本站 设为主页
网站首页 >  技术专栏  >  apache  > 

Apache 服务之 Chroot 环境设置

日期:2011-03-14  点击率:1439



Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/


# ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
#
# AllowOverride None
# Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
# Order allow,deny
# Allow from all
#


ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined
ServerSignature On

# Alias /doc/ "/usr/share/doc/"
#
# Options Indexes MultiViews FollowSymLinks
# AllowOverride None
# Order deny,allow
# Deny from all
# Allow from 127.0.0.0/255.0.0.0 ::1/128
#



做完了之后,来个$sudo /etc/init.d/apache2 force-reload 重新引导Apache2,成功!高兴,再打开Firefox,地址栏中输入localhost,回答拒绝。??!!

$more /var/log/apache2/error.log
>[Sun Jul 17 11:41:35 2005] [error] (2)No such file or directory: could not create /var/run/apache2.pid
>[Sun Jul 17 11:41:35 2005] [error] apache2: could not log pid to file /var/run/apache2.pid
原来在Apache启动时,由于mod-chroot最后生效,所以apache2.pid的路径是对的,但在mod-chroot生效之后,根已指向了/var/www,那所谓的 /var/run/apache2.pid实际上指的是/var/www /var/run/apache2.pid了,而这个目录是不存在的。这个好办,没有的话创建好了!

$sudo mkdir -p /var/www/var/run
$sudo chown -R root.root /var/www/var/run
$sudo ln -s /var/www/var/run/apache2.pid /var/run/apache2.pid
第三步很重要,为的是保持一致性!同样的,对`LockFile`也做相同处理

$sudo mkdir -p /var/www/var/lock/apache2
$sudo chown -R root.root /var/www/var/lock/apache2
$sudo ln -s /var/www//var/lock/apache2/accept.lock /var/lock/apache2/accept.lock
如果你还要用到其他的,请参照上面自行修改然后创建网站的缺省目录

$sudo mkdir /var/www/htdocs
然后来重启一次:

$sudo /etc/init.d/apache2 force-reload
运行正常!





下一篇:Apache虚拟主机指南   上一篇:RSYNC的简单配置