这LNMPA环境搭建,大家有人配过没?
我先说下我的想法:
nginx在前端做负载均衡并处理一些静态文件,比如js,css等.将动态文件丢给后端的apache
数据库这边的就先不说了,因为公司要用的postgresql,在另外的FWQ上安装的。
然后PHP用的是5.3.10,要安装php-fpm
apache2.2在后端处理nginx丢过来的PHP动态文件.
另外,PHP还要安装eaccelerator来加速。
现在问题是我已经配置好了php5.3.10+php-fpm+apache+fastcgi了,但好像apache2.4一直不成功,不知道为什么,现在连eaccelerator也装不上去。nginx这边配置文件怎么做?它貌似不需要运行PHP,也就不管它用什么方式来跑了吧?
.php 做 提交到apache
######
user www www; worker_processes 1; error_log /home/wwwlogs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; #limit_zone crawler $binary_remote_addr 10m; server { listen 80; server_name www.lnmp.org; index index.html index.htm index.php; root /home/wwwroot; location / { try_files $uri @apache; } location @apache { internal; proxy_pass http://127.0.0.1:88; include proxy.conf; } location ~ .*\.(php|php5)?$ { proxy_pass http://127.0.0.1:88; include proxy.conf; } location /status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; access_log /home/wwwlogs/access.log access; } include vhost/*.conf; }
proxy.conf
proxy_connect_timeout 30s; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 32k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Host $host; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
httpd.conf
就不贴了 ,默认就行 ,伪静态 可以直接在 nginx .conf 里添加 ,也可以直接添加进httpd.conf
仔细研究揣摩以上 代码
######好复杂,我一直都是nginx,php-fpm,mysql,这样的结构很好,不知道为什么要加一个apache,就算要平均负载,直接让dns,平均解析到不同的nginx上面,例如192.168.1.1,192.168.1.2,192.168.1.3.
然后碰到.php就丢给内网的php-fpm,几台机子rsync一下,把php代码一致,每台台子开个600进程.集群memcache,主从mysql,就这架构,我想百万级是一点问题没有阿.
######user www www; worker_processes 1; error_log /home/wwwlogs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; #limit_zone crawler $binary_remote_addr 10m; server { listen 80; server_name www.lnmp.org; index index.html index.htm index.php; root /home/wwwroot; location / { try_files $uri @apache; } location @apache { internal; proxy_pass http://127.0.0.1:88; include proxy.conf; } location ~ .*\.(php|php5)?$ { proxy_pass http://127.0.0.1:88; include proxy.conf; } location /status { stub_status on; access_log off; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; access_log /home/wwwlogs/access.log access; } include vhost/*.conf; }
proxy.conf
proxy_connect_timeout 30s; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 32k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Host $host; proxy_set_header Referer $http_referer; proxy_set_header Cookie $http_cookie; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
httpd.conf
就不贴了 ,默认就行 ,伪静态 可以直接在 nginx .conf 里添加 ,也可以直接添加进httpd.conf
仔细研究揣摩以上 代码
你这nginx里面的配置,是不是有用到fastcgi啊?这个东西放到nginx里面来干嘛?
据我所了解的,apache是以fastcgi来跑PHP的,而PHP是用php-fpm来管理fastcgi的,对吧?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。