搜尋
首頁php教程php手册在linux下配置nginx+java+php的环境

一、配置目标 1、通过lnmp完成基础环境的安装 通过lnmp安装后,相关软件的位置请参考其官方说明。安装后我单独通过气官方说明,升级了nginx的版本 2、配置nginx使之能满足phpjava环境在一台机器上的复用 二、相关安装说明 1、将tomcat安装到/usr/local/tomca

一、配置目标

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 format
		log_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.jiuchongju.com.conf

这里我将一个域名的相关配置在这里展示: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项目配置:文件名称www.quickbook.cn.conf

这里我指定了一个java项目的配置  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/;  
 
#将请求反向代理到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;  
        }

}

三、总结

1、主要是nginx将各个子域名的配置放到conf/vhost中独立处理

2、每个vhost下的配置文件都独立生效

3、nginx只是将请求转发到后端的应用服务器上

4、启动的时候需要按照如下次序启动

(1)、启动mysql数据库

(2)、启动tomcat

(3)、启动nginx


陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
3 週前By尊渡假赌尊渡假赌尊渡假赌

熱工具

SecLists

SecLists

SecLists是最終安全測試人員的伙伴。它是一個包含各種類型清單的集合,這些清單在安全評估過程中經常使用,而且都在一個地方。 SecLists透過方便地提供安全測試人員可能需要的所有列表,幫助提高安全測試的效率和生產力。清單類型包括使用者名稱、密碼、URL、模糊測試有效載荷、敏感資料模式、Web shell等等。測試人員只需將此儲存庫拉到新的測試機上,他就可以存取所需的每種類型的清單。

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用