Skip to content

Instantly share code, notes, and snippets.

@suziewong
Last active March 2, 2018 07:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suziewong/4440677 to your computer and use it in GitHub Desktop.
Save suziewong/4440677 to your computer and use it in GitHub Desktop.
Apache 知识经验整理

Apache

安全方面

1.勤打补丁[没经验,能先用好就不错了]

2.伪装版本

修改httpd.conf

ServerSignature off
ServerTokens Prod

然后这类的话就不见了

Apache/2.2.14 (Ubuntu) Server at 210.32.200.* Port 11***

3.安全的目录结构

/opt/www
/etc/apache2/site-enabled
/var/log

经验1

在site-available中写好网站配置文件,然后
cd ../site-enabled
ln -s ../site-available/xxx.conf

4.Apache 用户组

配置文件httpd.conf 里面的User和Group 设置单独的用户和用户组,比如www-data,不要用系统预定义的账号,比如nobody

5.Apache配置文件

6.网站配置

最简单的配置文件

    <VirtualHost 127.0.0.1:11063>
    DocumentRoot /opt/www/recruit
    ServerName suzie.com
    </VirtualHost>

经验

    例子:从当前目录开始查找所有扩展名为.in的文本文件,并找出包含”thermcontact”的行
    find . -name "*.in" | xargs grep "thermcontact"

7.访问权限

所有目录755 所有文件755

Web目录的访问策略

修改配置文件httpd.conf或者xxx.conf

1.禁止目录访问

Options -Indexes FollowSymLinks

2.禁止默认访问 Apache禁止目录访问 Apache的Order Allow,Deny 详解

Order deny,allow
Allow from all

3.禁止用户重载

AllowOverride None

在配置news 语义化连接SEO接触过,因为要开启Apache的 mod_rewirte,由drupal处理url的重写。

4.服务器访问控制

Order deny,allow
deny from all
allow from pair 192.168.1.0/255.255.255.0

Apache服务器的密码保护

.htaccess

1.建立.htpasswd文件 2.htaccess文件实现保护 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment