Configure the nginx + java + php environment in linux

Source: Internet
Author: User
I. Configuration goals 1. After the basic environment is installed through lnmp, refer to the official instructions for the software. After installation, I will go through official instructions on gas, upgrade nginx version 2. Configure nginx to meet the requirements for reuse of the phpjava environment on one machine. 2. related installation instructions. 1. install tomcat on usrlocaltomca.

I. Configuration goals 1. After the basic environment is installed through lnmp, refer to the official instructions for the software. After installation, I will go through official instructions on gas, upgrade nginx version 2. Configure nginx to meet the requirements for reuse of the phpjava environment on one machine. 2. related installation instructions. 1. install tomcat on/usr/local/tomca.

I. Configuration Objectives

1. Install the basic environment through lnmp

After lnmp is installed, refer to the official instructions for the software. After installation, I upgraded the nginx version through official instructions.

2. Configure nginx to meet the need for reuse on a single machine in the php + java environment


Ii. Installation instructions

1. install tomcat on/usr/local/tomcat6

2. Install nginx on/usr/local/nginx

3. Install the java project under tomcat6/webapps


4. install php-related projects directly under/usr/local /.


Iii. configuration instructions

Mainly describes the situation of several main configuration files

1. nginx. conf

User 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 parameter configuration is very important. It has a great impact on performance. http {include mime. types; default_type application/octet-stream; Limit 128; Limit 32 k; limit 4 32 k; Limit 50 m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; limit 300; fastcgi_read_timeout 300; Limit 256 k; fastcgi_buffers 8 256 k; Limit 512 k; Limit 512 k; gzip on; gzip_min_length 1 k; gzip_buffers 4 16 k; 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 10 m; # log formatlog_format access' $ remote_addr-$ remote_user [$ time_local] "$ request" ''$ status $ response" $ http_referer "'' "$ http_user_agent" $ http_x_forwarded_for '; # The core points out the configuration file location of each domain name. include vhost/* in the nginx/conf/vhost directory /*. conf ;}


2. vhost (the configuration file location corresponding to the relevant domain name is specified in nginx. conf)

(1) php project configuration: file name shequ.jiuchongju.com. conf

Here I will display the configuration of a domain name here: shequ.jiuchongju.com

server        {                listen      80;                server_name shequ.jiuchongju.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 project configuration: file name www.quickbook.cn. conf

Here I have specified the configuration of a java project www.quickbook.cn

Server {listen 80; server_name www.quickbook.cn; # charset koi8-r; access_log logs/dev/null; root/usr/local/tomcat6/webapps/quickbook /; # reverse proxy of the request to the tomcat Application Server with location/{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 $ scheme; limit 10 m; Limit 128 k; proxy_buffers 32 4 k; proxy_connect_timeout 3; proxy_send_timeout 30; proxy_read_timeout 30; proxy_pass http: // 127.0.0.1: 8080 ;}}

Iii. Summary

1. nginx puts the configuration of each sub-domain name in conf/vhost for independent processing.

2. The configuration files under each vhost take effect independently.

3. nginx only forwards requests to the backend application server.

4. Start in the following order

(1) Start the mysql database

(2) start tomcat

(3) Start nginx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.