在linux下配置nginx+java+php的环境

来源:互联网 发布:mac默认dock排列 编辑:程序博客网 时间:2024/05/17 01:29

一、配置目标

1、通过lnmp完成基础环境的安装

通过lnmp安装后,相关软件的位置请参考其官方说明。安装后我单独通过气官方说明,升级了nginx的版本

2、配置nginx使之能满足php+java环境在一台机器上的复用


二、相关安装说明

1、将tomcat安装到/usr/local/tomcat6

2、将nginx安装到/usr/local/nginx

3、将java项目安装到tomcat6/webapps下


4、将php相关项目直接安装到/usr/local/下


三、相关配置说明

主要说明几个主配置文件的情况

1、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;}#fastcgi参数的配置很重要。对性能影响较大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 256k;fastcgi_buffers 8 256k;fastcgi_busy_buffers_size 512k;fastcgi_temp_file_write_size 512k;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;#log formatlog_format  access  '$remote_addr - $remote_user [$time_local] "$request" '             '$status $body_bytes_sent "$http_referer" '             '"$http_user_agent" $http_x_forwarded_for';#核心指出了各个域名的配置文件位置,在nginx/conf/vhost目录中 include vhost/*.conf;}

2、vhost(在nginx.conf指明了相关域名对应的配置文件位置)

(1)、php项目配置:文件名称shequ.imudges.com.conf

这里我将一个域名的相关配置在这里展示:join.imudges.com

server        {                listen      80;                server_name join.imudges.com;                index index.html index.htm index.php;                root  /usr/local/discuzx/upload;                location ~ .*\.(php|php5)?$                        {                                try_files $uri =404;                                fastcgi_pass  unix:/tmp/php-cgi.sock;                                fastcgi_index index.php;                                include fcgi.conf;                        }                location /status {                        stub_status on;                        access_log   off;                }                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$                        {                                expires      30d;                        }                location ~ .*\.(js|css)?$                        {                                expires      12h;                        }                access_log  /home/wwwlogs/access.log  access;        }

(2)、java项目配置:文件名称www.imudges.com.conf

这里我指定了一个java项目的配置  www.imudges.com

    server {          listen       80;          server_name  www.imudges.com;           #charset koi8-r;            access_log  logs/dev/null;        root   /usr/local/tomcat6/webapps/quickbook/;   #将请求反向代理到tomcat应用服务器上了 location / {                             index   index.jsp index.html index.htm ;                 proxy_redirect          off;                 proxy_set_header        Host            $host;                 proxy_set_header        X-Real-IP       $remote_addr;                 proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;                 client_max_body_size    10m;                 client_body_buffer_size 128k;                 proxy_buffers           32 4k;               proxy_connect_timeout   3;                 proxy_send_timeout      30;                 proxy_read_timeout      30;                 proxy_pass http://127.0.0.1:8080;          }}

来源网络
0 0