Pc-nginx-apache (fortestinstalleasy) http {upstreammyapp1 {region; serversrv2.example.com; serversrv3.example.com;} server {listen80; location {proxy_passmyapp1 ;}} server {location
Pc-nginx-apache (for test install easy) http {upstream myapp1 {// --- for balance server srv1.example.com; server srv2.example.com; server srv3.example.com;} server {listen 80; location/{proxy_pass http: // myapp1 ;}} server {location
Pc-> nginx-> apache (for test install easy)
http { upstream myapp1 { //---for balance server srv1.example.com; server srv2.example.com; server srv3.example.com; } server { listen 80; location / { proxy_pass http://myapp1; } }}
server { location / { proxy_pass http://localhost:8080/; //---to apache } location ~ \.(gif|jpg|png)$ { //---to local root /data/images; }}
-------------------------------------------
Env
Kernel: 3.10.0-123. el7.x86 _ 64
Nginx version: nginx/1.4.7. /configure -- prefix =/usr/local/nginx/-- with-pcre =/usr/local/pcre-7.9/(source code path) -- with-zlib =/usr/local/zlib-1.2.8/(source code path)
Php version: 5.5.20 auto enable fastcgi./configure -- prefix =/usr/local/php -- enable-debug -- enable-fpm
Config
1 #user nobody; 2 worker_processes 1; 3 4 #error_log logs/error.log; 5 #error_log logs/error.log notice; 6 #error_log logs/error.log info; 7 8 #pid logs/nginx.pid; 9 10 11 events {12 worker_connections 1024;13 }14 15 16 http {17 include mime.types;18 default_type application/octet-stream;19 20 #log_format main '$remote_addr - $remote_user [$time_local] "$request" '21 # '$status $body_bytes_sent "$http_referer" '22 # '"$http_user_agent" "$http_x_forwarded_for"';23 24 #access_log logs/access.log main;25 26 sendfile on;27 #tcp_nopush on;28 29 #keepalive_timeout 0;30 keepalive_timeout 65;31 32 #gzip on;33 34 server {35 listen 80;36 server_name localhost;37 38 #charset koi8-r;39 40 #access_log logs/host.access.log main;41 42 location / {43 root html;44 index index.php index.html index.htm;45 }46 47 #error_page 404 /404.html;48 49 # redirect server error pages to the static page /50x.html50 #51 error_page 500 502 503 504 /50x.html;52 location = /50x.html {53 root html;54 }55 56 # proxy the PHP scripts to Apache listening on 127.0.0.1:8057 #58 #location ~ \.php$ {59 # proxy_pass http://127.0.0.1;60 #}61 62 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:900063 #64 location ~ \.php$ {65 root /usr/local/nginx/html;66 fastcgi_pass 127.0.0.1:9000;67 fastcgi_index index.php;68 include fastcgi.conf;69 }70 71 # deny access to .htaccess files, if Apache's document root72 # concurs with nginx's one73 #74 #location ~ /\.ht {75 # deny all;76 #}77 }78 }
Nginx. conf
/Usr/local/php/sbin/php-fpm
/Usr/local/nginx/sbin/nginx
Sysctl stop firewalld. service
Systemctl stop firewalld. service
Result
[Root @ localhost conf] # curl 127.0.0.1 | head
% Total % Received % Xferd Average Speed Time Current
Dload Upload Total Spent Left Speed
100 56014 0 56014 0 9.8 M 0 --: -- 10.6 M