关于网友提出的“LNMPA,单独配置的问题”问题疑问,本网通过在网上对“LNMPA,单独配置的问题”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题:LNMPA,单独配置的问题
描述:这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,也就不管它用什么方式来跑了吧?
解决方案1:引用来自“xiaojia2008”的答案
你都
php-fpm了,还要apache干嘛解决方案2:你都
php-fpm了,还要apache干嘛
解决方案3:引用来自“红星”的答案
nginx.conf
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
仔细研究揣摩以上 代码
解决方案4:好复杂,我一直都是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,就这架构,我想百万级是一点问题没有阿.
解决方案5:nginx.conf
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
仔细研究揣摩以上 代码
解决方案6:需要 怎么配置还得需要具体需求来看了。
1:php和静态文件分别在两个不同的域,这是最好配置的了。
2:如果都在一个域,但是静态文件又都在一个目录下,那就把这一个目录交给nginx处理,其它的交给apache处理
3:这种是最麻烦的,到时都可能存在静态文件和php,那么把.js、.css、.flv、.swf、.gif、.png、.txt、.jpg、.jpeg,其它的都交给apache处理,如果有urlrewrite,但是后缀不带有html、htm等,那么htm、html也交给nginx处理,如果带有,那么只好都交给apache处理了
解决方案7:引用来自“Meso”的答案
中间层apache直接可以省略,直接nginx既做balance,也可以server
解决方案8:中间层apache直接可以省略,直接nginx既做balance,也可以server
解决方案9:引用来自“滔哥”的答案
.php 做 提交到apache
解决方案10:.php 做 提交到apache
以上介绍了“LNMPA,单独配置的问题”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/1337127.html