Under centos nginx proxy tomcat, while supporting the nginx php and jsp

  nginx ability to deal with static html page is quite tough, because nginx uses than select models more obstinate epoll, so if the site content is not often change (a lot of html page), they need to support other such as php, jsp of cgi scripts, consider using nginx instead of still using select models of apache (httpd); of course, after a long-term follow discovery appears to nginx fastcgi (php-fpm) run php will occasionally 502 errors, but it seems there is no way to completely eradicated; it is not considered in the case of large flow configuration php-fpm way to make nginx support php is a good choice, of course, you can also use nginx proxy module to handle php proxy apache, has a lot of information on this network, not repeat them - This paper mainly deals nginx at 80 ports in the same supports php, jsp; because I know much about jsp, error also please bear with me.

    As a rookie nginx server software for php fastcgi way to support the relevant information is already a lot, just search for what you can find many, there will no longer support the introduction nginx php configuration, if you need to know this knowledge, you can refer I have another article:

    Article name: "CentOS6.3 compiler installation configuration nginx1.2.3 + php5.3.16 + mysql5.5.27 + memcached1.4.5"

    Address: http://blog.jjonline.cn/linux/centos6_3_nginx1_2_3_mysql5_5_27.html 

    Ps: different configurations similar principle nginx php mysql version, if the problem can give me a message, the next time permitting it can help you troubleshoot ~

==============

tomcat6 installation and operation

    Under fairly simple to install centos tomcat server supports jsp, and a yum command all set, of course, you can also refer to the existing network code is compiled mode or rpm package installation mode, this is no longer introduced.

tomcat installation (tomcat6 version):

-----------------------

shell command:

yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps

-----------------------

yum command is completed, tomcat6 installation is complete;

tomcat6 start: yum install tomcat6 has been automatically command chkconfig service is installed, that is, can be used as service httpd start command such as start, stop, restart tomcat6

-----------------------

shell command:

service tomcat6 start|stop|restart

-----------------------

tomcat6 configuration

    Since nginx php-fpm already installed, the root has also been specified, but just nginx individual virtual hosts are in / mnt / down, such as: www.jjonline.cn root directory / mnt / www my blog blog.jjonline. cn in / mnt / blog so

    So we need to configure tomcat under the root directory in the server.xml file in the / etc / tomcat6 directory, locate </ Host> added before the </ Host>

    <Context path="" docBase="/mnt/" debug="0"/> 

Can [I do not have the versatility of configuration, simply because the root of parallel individual virtual hosts before placing under / mnt, so the use of the above configuration, tomcat default port is 8080, you need to modify the look for information on their own] .

nginx proxy configuration tomcat

打开nginx的配置文件,在server中添加一个location,代码如下:

------------------------

 location ~ \.(jsp|jspx|do|wsdl)?$ {

            proxy_set_header Host $host;

            proxy_set_header X-Forwarded-For $remote_addr;

            proxy_pass http://127.0.0.1:8080/XXXX$uri;

 }

------------------------

    请注意,tomcat的根目录在/mnt下,而php、html的根目录在/mnt/xxx的目录下,如上述的/mnt/www即为www.jjonline.cn根目录,所以此处www.jjonline.cn要支持jsp,则需要将上述location中的红色XXXX部分改为www

本文来至晶晶的博客

Guess you like

Origin www.cnblogs.com/ZhangZiYangDeBoKe/p/10947737.html