Nginx 安装配置【必须把文件到放到机器上】
【必須把所有下載的gz文件到放到機器上;編譯】
1.安裝nginx之前的編譯軟件
yum -y install make zlib zlib-devel gcc-c++ libtool ?openssl openssl-develmake 命令安裝
zlib 和 zlib-devel 解壓命令安裝:
red hat:wget https://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz/download -o zlib-1.2.8.tar.gz
ubuntu:apt install zlib1g
gcc 的安裝
g++ 的安裝
libtool 通用庫工具的安裝 ubuntu:sudo apt install?libtool
Ubuntu:sudo apt-get install zlib1g-dev
Ubuntu:sudo apt-get install g++
openssl 一個安全套接字層密碼庫
二、首先要安裝 PCRE
PCRE 作用是讓 Nginx 支持 Rewrite 功能。
1、下載 PCRE 安裝包,下載地址:wget http://downloads.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
daokr#wget http://downloads.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz
2、解壓安裝包:
[root@dksrc]# tar zxvf pcre-8.33.tar.gz3、進入安裝包目錄
[root@dksrc]# cd pcre-8.334、編譯安裝?
[root@dkpcre-8.35]# ./configure --prefix=/usr/local/src/pcre-8.33 [root@dkpcre-8.35]# make?&& make install? ? 查找pcre 的默認安裝路徑?
root@VM-0-4-ubuntu:/# find -name pcre ./home/ubuntu/downfile/nginx-1.5.8/auto/lib/pcre?
如果報錯看下面鏈接:
ubuntu編譯PCRE時出現 line 81: aclocal-1.14: command not found錯誤
?5、查看pcre版本
[root@dkpcre-8.35]# pcre-config --version ?安裝openssl
1.下載地址?
root:wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz
2.編輯配置安裝路徑
root:./config --prefix=/usr/local/src/openss-1.0
3.輸入make && make install 安裝
make && make install
4.查看版本
daokr#openssl version -a安裝 Nginx
1、下載 Nginx,下載地址:http://nginx.org/download/nginx-1.5.8.tar.gz
[root@dk src]#wget?http://nginx.org/download/nginx-1.5.8.tar.gz2、解壓安裝包
[root@dksrc]# tar zxvf nginx-1.5.8.tar.gz3、進入安裝包目錄
[root@dksrc]# cd nginx-1.5.84、編譯安裝
[root@dknginx-1.6.2]# ./configure --prefix=/home/nginx --with-http_stub_status_module --with-http_ssl_module --with-openssl=/home/daokr/downfile/openssl-1.0.2h --with-pcre=/home/daokr/downfile/pcre-8.33 [root@dknginx-1.6.2]# make [root@dknginx-1.6.2]# make install在編譯的時候如果沒有出現 creating objs/Makefile 這行;說明哪里錯了;要按錯誤來修改
這里有個坑;就是
--with-openssl和--with-pcre 的路徑 是壓縮包解壓后源文件;千萬別搞錯了路徑
5、查看nginx版本
[root@dknginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v到此,nginx安裝完成。
Nginx 配置
創建 Nginx 運行使用的用戶 www:
添加用戶組www
添加用戶并賦予www的權限組
[root@dk conf]# groupadd www? [root@dk conf]# useradd -g www www配置nginx.conf ,將/usr/local/webserver/nginx/conf/nginx.conf替換為以下內容
默認配置:
?啟動地址:/usr/sbin/nginx 下面關閉
root@DK:/usr/sbin# ./nginx root@DK:/usr/sbin# ps -ef|grep nginx root 25113 1 0 10:15 ? 00:00:00 nginx: master process ./nginx www 25114 25113 0 10:15 ? 00:00:00 nginx: worker process root 25118 25074 0 10:15 pts/22 00:00:00 grep --color=auto nginx?
?
?
測試配置是否正確命令:
?
啟動和停用:
Nginx 其他命令 以下包含了 Nginx 常用的幾個命令: /usr/local/webserver/nginx/sbin/nginx -s reload # 重新載入配置文件 /usr/local/webserver/nginx/sbin/nginx -s reopen # 重啟 Nginx /usr/local/webserver/nginx/sbin/nginx -s stop # 停止 Nginx?
?安裝完成后簡單的修改下配置文件:
user www www; worker_processes 1;#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events {worker_connections 1024; }http {include mime.types;default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main; sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 1180;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;set $root_path "/home/daokr/web";root $root_path;index index.php index.html index.htm;location / {root html;index index.html index.htm;}#error_page 404 /404.html; # redirect server error pages to the static page /50x.html #error_page 500 502 503 504 /50x.html;location = /50x.html { root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1; #}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht { # deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}?
?
下面是工作的實際的nginx配置:
#user oracle.dba; worker_processes 8; worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; pid /home/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 65535;events {use epoll;worker_connections 10240; }http {include mime.types;default_type application/octet-stream;server_tokens off;server_names_hash_bucket_size 128;client_header_buffer_size 4k;large_client_header_buffers 4 32k;client_max_body_size 64m;sendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 60s;open_file_cache max=10240 inactive=20s;open_file_cache_valid 60s;open_file_cache_min_uses 1;fastcgi_connect_timeout 180s;fastcgi_send_timeout 180s;fastcgi_read_timeout 180s;fastcgi_buffer_size 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 128k;proxy_connect_timeout 180s;proxy_read_timeout 180s;proxy_send_timeout 180s;proxy_buffer_size 64k;proxy_buffers 4 64k;proxy_busy_buffers_size 128k;gzip on;gzip_min_length 1k;gzip_buffers 4 64k;gzip_http_version 1.0;gzip_comp_level 2;gzip_types text/plain application/x-javascript text/css application/xml;gzip_vary on;include server/*.txt;#access loger formatlog_format access '$remote_addr $http_x_forwarded_for $remote_user [$time_local] "$request" [$request_length/$bytes_sent] ''$status "$http_referer" "$http_user_agent"';access_log logs/access.log access;log_not_found off;open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;error_log /home/nginx/logs/error.log error;# limit_zone crawler; # $binary_remote_addr 10m;#WebSocket Upgrade#map $http_upgrade $connection_upgrade #{# default upgrade;# '' close;#}#server #{# #WebSocket Proxy Port# listen 12800;# server_name localhost;## location / # {# #PHP WebSocket port# proxy_pass http://localhost:12801;# proxy_set_header X-Real-IP $remote_addr;# proxy_set_header Host $host;# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;## proxy_http_version 1.1;# proxy_set_header Upgrade $http_upgrade;# proxy_set_header Connection "upgrade";# }#}server {##---xpass-1.0.0---##listen 20030;server_name localhost;charset utf-8;##ssl configure #ssl on; #ssl_certificate cert/lianyinggufen_com.crt;#ssl_certificate_key cert/lianyinggufen_com.key; #ssl_session_timeout 5m; #ssl_protocols SSLv3 TLSv1; #ssl_ciphers HIGH:!ADH:!EXPORT56:RC4+RSA:+MEDIUM; #ssl_prefer_server_ciphers on; ## phalcon-configset $root_path "/home/oracle/xpass-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(js|css|img|images|flv|swf|fonts|download)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|apk|ipa|plist)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}} server {##---xpay-1.0.0(http)---##listen 20031;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xpay-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(.+)/(js|css|img|images|flv|swf|fonts|download|product)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx|zip|uploads|xml|rar)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}} # # server # { # ##---wxqyh---## # listen 20038; # server_name localhost; # charset utf-8; # # ## phalcon-config # set $root_path "/home/oracle/wxqyh-1.0.0/public"; # # root $root_path; # index index.php index.html index.htm; # try_files $uri $uri/ @rewrite; # # #for document_root - ajax request # location / # { # rewrite ^(.*)$ /index.php?_url=$1; # } # # #for all others # location @rewrite # { # rewrite ^/(.*)$ /index.php?_url=$1; # } # # location ~ \.php # { # # try_files $uri = 404; # fastcgi_index index.php; # # # fastcgi_pass 127.0.0.1:9000; # fastcgi_pass unix:/tmp/php-cgi.sock; # # include fastcgi_params; # fastcgi_split_path_info ^(.+\.php)(/.+)$; # fastcgi_param PATH_INFO $fastcgi_path_info; # fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # } # # # cache folder # # location ~* ^/(.+)/(js|css|img|images|flv|swf|fonts|download|product)/(.+)$ # # # cache file type # location ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)$ # { # root $root_path; # access_log off; # expires 30d; # } # # location ~ \.ico # { # root $root_path; # access_log off; # expires 30d; # } # # location ~ /\.ht # { # deny all; # } # } #server {##---xmer-1.0.0---##listen 20033;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xmer-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(js|css|img|images|flv|swf|fonts|download)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {##---xagent-1.0.0---##listen 20034;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xagent-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(js|css|img|images|flv|swf|fonts|download)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {##---xserv-1.0.0---##listen 20035;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xserv-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(js|css|img|images|flv|swf|fonts|download)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {##---xfinance-1.0.0---##listen 20036;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xfinance-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(js|css|img|images|flv|swf|fonts|download)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {##---xapp-1.0.0 SSL---##listen 20037;server_name localhost;charset utf-8;##ssl configure ssl on; ssl_certificate ssl/boshang.crt;ssl_certificate_key ssl/boshang.key; ssl_session_timeout 5m; ssl_protocols SSLv3 TLSv1; ssl_ciphers HIGH:!ADH:!EXPORT56:RC4+RSA:+MEDIUM; ssl_prefer_server_ciphers on;## phalcon-configset $root_path "/home/oracle/xapp-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(js|css|img|images|flv|swf|fonts|download)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx|exe|app|appfile)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {##---xapp-1.0.0 not ssl---##listen 20042;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xapp-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(js|css|img|images|flv|swf|fonts|download)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {##---XOPEN-1.0.0---##listen 20041;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xopen-1.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(.+)/(js|css|img|images|flv|swf|fonts|download|product)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {##---XOPEN-1.0.0---##listen 20046;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xdemo";root $root_path;index index.php index.html index.htm;#try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{#rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {#rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(.+)/(js|css|img|images|flv|swf|fonts|download|product)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx|html|htm|http)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}#server #{# ##---xweixin-1.0.0---### listen 20041;# server_name localhost;# charset utf-8;## ## phalcon-config# set $root_path "/home/oracle/xweixin-1.0.0/public";# # root $root_path;# index index.php index.html index.htm;# try_files $uri $uri/ @rewrite;# # #for document_root - ajax request# location /# {# rewrite ^(.*)$ /index.php?_url=$1;# }# # #for all others# location @rewrite # {# rewrite ^/(.*)$ /index.php?_url=$1;# }# # location ~ \.php # {# # try_files $uri = 404;# fastcgi_index index.php;# # # fastcgi_pass 127.0.0.1:9000;# fastcgi_pass unix:/tmp/php-cgi.sock;# # include fastcgi_params;# fastcgi_split_path_info ^(.+\.php)(/.+)$;# fastcgi_param PATH_INFO $fastcgi_path_info;# fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;# }# # # cache folder# # location ~* ^/(.+)/(js|css|img|images|flv|swf|fonts|download|product)/(.+)$# # # cache file type# location ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)$# {# root $root_path;# access_log off;# expires 30d; # }## location ~ \.ico# {# root $root_path;# access_log off;# expires 30d; # }## location ~ /\.ht # {# deny all;# }#}##server #{# ##---xca-1.0.0---### listen 20044;# server_name localhost;# charset utf-8;## ## phalcon-config# set $root_path "/home/oracle/xca-1.0.0/public";# # root $root_path;# index index.php index.html index.htm;# try_files $uri $uri/ @rewrite;# # #for document_root - ajax request# location /# {# rewrite ^(.*)$ /index.php?_url=$1;# }# # #for all others# location @rewrite # {# rewrite ^/(.*)$ /index.php?_url=$1;# }# # location ~ \.php # {# # try_files $uri = 404;# fastcgi_index index.php;# # # fastcgi_pass 127.0.0.1:9000;# fastcgi_pass unix:/tmp/php-cgi.sock;# # include fastcgi_params;# fastcgi_split_path_info ^(.+\.php)(/.+)$;# fastcgi_param PATH_INFO $fastcgi_path_info;# fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;# }# # # cache folder# # location ~* ^/(.+)/(js|css|img|images|flv|swf|fonts|download|product)/(.+)$# # # cache file type# location ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)$# {# root $root_path;# access_log off;# expires 30d; # }## location ~ \.ico# {# root $root_path;# access_log off;# expires 30d; # }## location ~ /\.ht # {# deny all;# }#}server {##---xwebs---##listen 20044;server_name localhost;charset utf-8;## phalcon-configset $root_path "/home/oracle/xwebs/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(.+)/(js|css|img|images|flv|swf|fonts|download|product)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {##---xcar-1.0.0 SSL---##listen 20050;server_name localhost;charset utf-8;##ssl configure ssl on; ssl_certificate ssl/xcar.cer;ssl_certificate_key ssl/xcar.pem; ssl_session_timeout 5m; ssl_protocols SSLv3 TLSv1; ssl_ciphers HIGH:!ADH:!EXPORT56:RC4+RSA:+MEDIUM; ssl_prefer_server_ciphers on;## phalcon-configset $root_path "/home/oracle/xcars-1.0.0/public";root $root_path;index index.php index.html index.htm;try_files $uri $uri/ @rewrite;#for document_root - ajax requestlocation /{rewrite ^(.*)$ /index.php?_url=$1;}#for all otherslocation @rewrite {rewrite ^/(.*)$ /index.php?_url=$1;}location ~ \.php {# try_files $uri = 404;fastcgi_index index.php;# fastcgi_pass 127.0.0.1:9000;fastcgi_pass unix:/tmp/php-cgi.sock;include fastcgi_params;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param PATH_INFO $fastcgi_path_info;fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}# cache folder# location ~* ^/(js|css|img|images|flv|swf|fonts|download)/(.+)$# cache file typelocation ~* .(js|css|jpg|jpeg|gif|png|flv|swf|ttf|svg|eot|woff|download|xlsx|exe|app|appfile)${root $root_path;access_log off;expires 30d; }location ~ \.ico{root $root_path;access_log off;expires 30d; }location ~ /\.ht {deny all;}}server {listen 5601;server_name localhost;charset utf8;location / {auth_basic "Restricted Access";auth_basic_user_file /home/nginx/conf/htpasswd.users; proxy_pass http://10.8.21.124:5601$request_uri;proxy_set_header Host $http_host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;} }} tcp { timeout 1d; proxy_read_timeout 1d; proxy_send_timeout 1d; proxy_connect_timeout 14400;# ------ 192.168.2.11(oracle proxy) ------upstream oracle_11521 {server localhost:21521;check interval=3000 rise=4 fall=5 timeout=3000 type=tcp;} server {listen 11521;proxy_pass oracle_11521;so_keepalive on; tcp_nodelay on;} }?
?轉載于:https://www.cnblogs.com/wanglijun/p/8693814.html
總結
以上是生活随笔為你收集整理的Nginx 安装配置【必须把文件到放到机器上】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: hdu--5135--贪心
- 下一篇: SortedDictionaryTKey