lnmp 塗鴉

<directory /data/www/mmm>
allowoverride none
options none
order allow,deny
allow
</directory>
<filesmatch "(.*)php(.*)">
order allow ,deny
allow from all
<filesmatch>
禁用useragent
rewritecond %{http_user_agent} ".*curl.*"[nc,or]
rewritecond %{http_user_agent} ".*chrome.*"[nc]
rewriterule .* - [f]php


禁止解析php
php_admin_flag engine off
rewritecond %{request_uri} ^.*/data/www/mmmcss


php-fpm的配置文件:
[global]
pid=/usr/local/php/var/run/php-fpm.pid
error_log=/usr/local/php/var/log/php-fpm.log
[www]
listen=/tmp/www.sock
listen.owner=nobody 解決502問題
listen.group=nobody 解決502問題
user=php-fpm
group=php-fpm
pm=dynamic
pm.max_children=50
pm.start_servers=20
pm.min_spare_servers=6
pm.max_spare_servers=35
pm.max_requests=500
rlimit_files=1024
slowlog=/tmp/slow.log
request_slowlog_timeout=1
php_admin_value[open_basedir]=/data/www:/tmp
新建網站的文件存放處:
server {
       listen 80;
       server_name cisco.com;
       index index.html index.htm index.php;
       root /data/www;
location ~\.php$ {
       include fastcgi_params;
       fastcgi_pass unix:/tmp/www.sock;
       fastcgi_index index.php;
       fastcgi_param SCRITP_FILENAME /data/www$fastcgi_script_name;html


       }
}
常見的502錯誤:在php-fpm配置文件中加
               listen.owner=nobody
               listen.gruop=nobody
php-fpm.conf的配置文件:檢測網站性能
                       slowlog=/tmp/slow_log
                       request_slowlog_timeout=1nginx



虛擬配置文件的用戶認證:location ~.*admin\.php$ {
                                 auth_basic "cisco"
                                 auth_basic_user_file /usr/local/nginx/conf/ps.ps;
                                 include fastcgi_params;
                                 fastcgi_pass unix:/tmp/www.sock;
                                 fastcgi.index index.php;
                                 fastcgi-param script-filename /tmp/www&fastcgi_script_name;
}chrome


虛擬配置文件301 的跳轉: if ($host != 'www.swcaac.com')
                    {
                      rewrite ^/(.*)$ http://www.swcaac.com/$1 paramanent;
}
1.9 指定不記錄文件的類型:
1。在nginx.conf中修改日誌名:如cisco
2。在虛擬配置文件中加入:access_log /tmp/access_log cisco;
location ~.*\.(png|gif|jpeg|swf|bmp|jpg)$
{
access_log off;
}
location ~(static|cache)
{
access_log off;
}
2.0 nginx的日誌切割腳本:
1.找好腳本存放的地方/etc/logrotate.sh
2.寫腳本。vi /etc/logrotate.sh
!#/bin/bash
d=`date -d "-1 day" +%f`
[ -d /tmp/nginx_log ] || mkdir /tmp/nginx_log
mv /tmp/cisco.log /tmp/nginx_log/$d.log
/etc/init.d/nginx/reload > /dev/null
cd /tmp/nginx_log/
gzip -f $d.log
2.1 nginx 配置靜態文件的過時時間
在指定不記錄文件類型中添加
access_log off;
expires 2d;
location ~ \.(js|css)
{
access_log off
expires 2h;
}
2.2nginx 的防盜連接
1.在靜態緩存文件下加入:valid_referers none blocked *.swcaac.com *.cisco.com;
if ($invalid_referer)
{
return 403;
}
                  curl -e 指定你的referer
 
2.3nginx的訪問控制數據庫


1.在全局模式下:deny ip/地址段;表示不容許地址訪問目錄
2.在目錄認證模式下加:allow ip;deny all; 表示目錄只容許指定的ip訪問apache


2.4nginx的user-agent禁用
if ($http_user_agent ~* 'curl|baidu|sina|360')   ~*表示不區分大小寫
{
return 403;
}
2.5 nginx的代理  多個地址
vim proxy
upstream cisco {
server 代理服務器ip;
server 代理服務器ip;
}
server {
listen 80;
server_name 代理服務器;vim


location / {
proxy_pass http://cisco/;
proxy_set_header host $host;必須和多個代理服務器ip;連用
proxy_set_header x-real-ip $remote_addr;無關緊要
}
}
nginx的代理   單個ip
server {
listen 80;
server_name 代理服務器;緩存


location / {
proxy_pass http://cisco/;
#proxy_set_header host $host;必須和多個代理服務器ip;連用
}
}bash



key_buffer_size = 384M
log-bin 用於主從複製 記錄數據庫操做記錄
server-id =1 用於主從複製
關閉innodb是一種數據庫引擎。
apache的三種模式
prefork 小訪問量
worker 大訪問量
event

ldd查看加載的模塊是否正常

相關文章
相關標籤/搜索