服务器 频道

打造Linux下超级安全的LAMP服务器(上)

再加一个系统用户,这个用户是我们等会chroot要用的

  [root@debian /]adduser --home /chroot/apache --shell /dev/null --no-create-home --system --group chrapax

  接着我们编辑httpd.conf文件并做一些修改,删除多余的apache模块并激活php模块

  [root@debian /]vi /etc/apache/httpd.conf

  注释掉除了mod_access,mod_auth,mod_dir,mod_log_config,mod_mime,mod_alias之外的所有模块

  去掉注释LoadModule php4_module /usr/lib/apache/1.3/libphp4.so以支持PHP (如图apache_mod.jpg )

  设置ServerAdmin fatb@zzu.edu.cn

  设置ServerName secu.zzu.edu.cn

  把下面的Options Indexes Includes FollowSymLinks MultiViews的Indexes去掉,这样避免被别人索引目录把用户和组改成chrapax

  User chrapax

  Group chrapax

  在下面加上index.php如下

  DirectoryIndex index.php index.html index.htm index.shtml index.cgi

  默认使用中文字符集

  AddDefaultCharset gb2312

  加出错重定向,这样当出现下面的错误的时候,用户就会被重顶向到到你指定的页面

  ErrorDocument 404 http://secu.zzu.edu.cn/index.php

  ErrorDocument 402 http://secu.zzu.edu.cn/index.php

  ErrorDocument 403 http://secu.zzu.edu.cn/index.php

  ErrorDocument 500 http://secu.zzu.edu.cn/index.php

  把signature关掉

  ServerSignature Off

  如果signature打开的话,当有人访问到一个被禁止或者不存在的页面的话,会出现一些错误信息的这样的信息,不好,去掉他

如果不需要cgi支持的话,删除

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

   AllowOverride None

   Options ExecCGI -MultiViews

      Order allow,deny

      Allow from all

  这行的注释去掉,因为我们需要PHP支持

  把AddType application/x-httpd-php .php

  最后把多余的Alias,Directory,Location都去掉,保存退出

  OK,apache算是配置完毕,我比较喜欢干净的配置文件,下面的命令可以去掉httpd.conf里#打头的行

  [root@debian /]mv httpd.conf httpd.conf.bak

  [root@debian /]grep -v ''#'' httpd.conf.bak > httpd.conf

  到此为止,apache配置文件编辑完毕

0
相关文章