This shows you the differences between two versions of the page.
|
install:performance:nginx [2014/01/29 04:33] Alia created |
install:performance:nginx [2014/02/11 09:41] (current) Alia |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | c apache | + | Configure nginx with Apache |
| - | без апаче | + | |
| - | и сздесь вывести эти config файлы в друх вариациях | + | <code php> server { |
| + | listen 80; | ||
| + | |||
| + | location / { | ||
| + | proxy_pass http://123.45.67.89:85/; | ||
| + | proxy_redirect off; | ||
| + | |||
| + | |||
| + | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| + | proxy_set_header Host $host; | ||
| + | proxy_set_header X-Real-IP $remote_addr; | ||
| + | |||
| + | |||
| + | } | ||
| + | }</code> | ||
| + | |||
| + | Configure nginx without Apache | ||
| + | |||
| + | <code php>server { | ||
| + | |||
| + | listen 123.45.67.89:80; | ||
| + | |||
| + | root /home/user/public_html; | ||
| + | |||
| + | server_name example.com; | ||
| + | |||
| + | |||
| + | ####################################################################### | ||
| + | |||
| + | #RewriteCond %{REQUEST_URI} !^/index\.php | ||
| + | #RewriteCond %{REQUEST_URI} !/ow_updates/index\.php | ||
| + | #RewriteCond %{REQUEST_URI} !/ow_updates/ | ||
| + | #RewriteCond %{REQUEST_URI} !/ow_cron/run\.php | ||
| + | #RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$ [NC] | ||
| + | #RewriteRule (.*) index.php | ||
| + | |||
| + | if ($uri !~ "^/index.php"){ | ||
| + | set $rule 1$rule; | ||
| + | } | ||
| + | if ($uri !~ "/ow_updates/index.php"){ | ||
| + | set $rule 2$rule; | ||
| + | } | ||
| + | if ($uri !~ "/ow_updates/"){ | ||
| + | set $rule 3$rule; | ||
| + | } | ||
| + | if ($uri !~ "/ow_cron/run.php"){ | ||
| + | set $rule 4$rule; | ||
| + | } | ||
| + | if ($uri ~ "(/|.php|.html|.htm|.xml|.feed|robots.txt|.raw|/[^.]*)$"){ | ||
| + | set $rule 5$rule; | ||
| + | } | ||
| + | if ($rule = "54321"){ | ||
| + | rewrite /(.*) /index.php last; | ||
| + | } | ||
| + | |||
| + | |||
| + | location / { | ||
| + | index index.php; | ||
| + | } | ||
| + | |||
| + | location ~ \.php$ { | ||
| + | include fastcgi_params; | ||
| + | try_files $uri $uri/ /index.php; | ||
| + | # fastcgi_pass 127.0.0.1:9000; | ||
| + | fastcgi_pass unix:/var/run/php5-fpm.sock; | ||
| + | fastcgi_index index.php; | ||
| + | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
| + | fastcgi_param HTTP_HOST $host; | ||
| + | } | ||
| + | |||
| + | # Cache static content | ||
| + | location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|mp3|zip|tgz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|flv|bmp|rtf|js|swf)$ { | ||
| + | access_log off; | ||
| + | root /home/user/public_html; | ||
| + | expires 720h; | ||
| + | add_header Last-Modified: $date_gmt; | ||
| + | } | ||
| + | |||
| + | location ~ \.(js.gz|js.gzip)$ | ||
| + | { | ||
| + | access_log off; | ||
| + | add_header Content-Type ‘text/javascript’; | ||
| + | add_header Content-Encoding ‘gzip’; | ||
| + | expires max; | ||
| + | } | ||
| + | |||
| + | location ~ \.(css.gz|css.gzip)$ | ||
| + | { | ||
| + | access_log off; | ||
| + | add_header Content-Type ‘text/css’; | ||
| + | expires max; | ||
| + | } | ||
| + | } </code> | ||