Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1390230
  • 博文数量: 146
  • 博客积分: 1440
  • 博客等级: 少尉
  • 技术积分: 2996
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-24 23:47
个人简介

我一直在走,至少还有条路,也好于无路可走…

文章分类

全部博文(146)

文章存档

2024年(1)

2023年(1)

2017年(2)

2016年(5)

2015年(13)

2014年(13)

2013年(70)

2012年(41)

分类: LINUX

2013-12-05 07:43:07

             Nginx + php + tomcat  服务器支持php和Java程序

 

系统版本 centos 6.3  64位

软件版本:

Nginx:  nginx-1.4.4.tar.gz

Pcre : pcre-8.33.tar.gz

Jdk: jdk-7u45-linux-x64.rpm

Apache-tomcat  :apache-tomcat-7.0.47.tar.gz

安装依赖包:

Groupadd  www

Useradd  -s /sbin/nologin www

1.yum install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch

2.安装Ngingx nginx-1.4.4.tar.gz

tar -zxvf  /source/Packages/pcre-8.33.tar.gz

cd pcre-8.33

./configure

make  &&  make install

tar -zxvf nginx-1.4.4.tar.gz

cd nginx-1.4.4.

./configure --prefix=/usr/local/nginx --without-http_memcached_module --with-openssl=/usr/ --with-pcre=/source/Packages/pcre-8.33  --with-http_stub_status_module

make  && make install

Nginx  配置文件设置

 user www www;

worker_processes  1;

 

 

 

 

events {

    use epoll;

    worker_connections  65535;

}

 

 

http {

    include       mime.types;

    default_type  application/octet-stream;

 

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

    #                  '$status $body_bytes_sent "$http_referer" '

    #                  '"$http_user_agent" "$http_x_forwarded_for"';

 

    #access_log  logs/access.log  main;

      server_names_hash_bucket_size 128;

      client_header_buffer_size 32k;

      large_client_header_buffers 4 32k;

      client_max_body_size 300m;

      sendfile        on;

      tcp_nopush     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 128k;

      #keepalive_timeout  0;

      keepalive_timeout  60;

      tcp_nodelay on;

      server_tokens off;

     

      gzip  on;

      gzip_min_length  1k;

      gzip_buffers     4 16k;

      gzip_http_version 1.1;

      gzip_comp_level 2;

      gzip_types       text/plain application/x-javascript tex    t/css application/xml;

      gzip_vary on;

 

       upstream tomcat {

        server 127.0.0.1:8080;         #反向代理丢给tomcat

    } 

    server {

        listen       80;

        server_name   

 

        #charset koi8-r;

 

        #access_log  logs/host.access.log  main;

        location / {                         访问  自动调给tomcat解析

          proxy_pass 

          proxy_set_header Upgrade $http_upgrade;

          proxy_set_header Connection "upgrade";

        }

 

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

      

    }

include  vhost/*.conf;

}

另一个php解析配置文件

Vim /usr/local/nginx/etc/vhost/local.conf

  1 server

  2         {

  3                 listen       80;

  4                 server_name 

  5                 server_name  ip;

  6                 index index.php index.html index.htm default.html default.htm default.php;

  7                 root  /data/wwwroot/;

  8                  location ~ \.php$ {

  9                         root  /data/wwwroot;

 10                         fastcgi_pass 127.0.0.1:9000;

 11                         fastcgi_index index.php;

 12                         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

 13                          include fastcgi_params;

 14                        }

 15 location ~ .*\.(php|php5)?$

 16                         {

 17                                 fastcgi_pass  unix:/tmp/php-cgi.sock;

 18                                 fastcgi_index index.php;

 19                                 include fcgi.conf;

 20                         }

 21                 location /status {

 22                         stub_status on;

 23                         access_log   off;

 24                 }

 25

 26                 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

 27                         {

 28                                 expires      30d;

 29                         }

 30                 location ~ .*\.(js|css)?$

 31                         {

 32                                 expires      12h;

 33                         }

 34

 35                 access_log off;

 36         }

                                                                                             

/usr/local/nginx/sbin/nginx  启动nginx

安装 php 

wget 

tar   -jxvf /source/Packages/php-5.4.5.tar.bz2

cd  php-5.4.5

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --disable-fileinfo

make  && make install

cp php.ini-production /usr/local/php5/etc/php.ini 拷贝php主配置文件

rm -rf /etc/php.ini         删除系统自带配置文件

ln  -s /usr/local/php5/etc/php.ini /etc/ 软连接到/etc 目录下

cd /usr/local/php5/etc/

cp php-fpm.conf.default  php-fpm.conf   拷贝php-fpm主配置文件

Vim  /usr/local/php5/etc/php-fpm.conf

更改一下位置

user = www

group = www

pid = run/php-fpm.pid

cp /usr/local/php5/sbin/php-fpm  /etc/rc.d/init.d/

chmod 755 /etc/rc.d/init.d/php-fpm

chkconfig   --add  php-fpm

chkconfig php-fpm on

Jdk 下载地址 我这里使用 jdk-7u45-linux-x64.rpm

安装jdk

rpm -ivh  jdk-7u45-linux-x64.rpm

查看是否安装成功

# java -version 查看版本号

Vim  /etc/profile

添加以下内容

 JAVA_HOME="/usr/java/jdk1.7.0_45/"

 CLASS_PATH=".:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/dt.jar"

 PATH=".:$PATH:$JAVA_HOME/bin"

 CATALINA_HOME="/usr/local/tomcat"

 export JAVA_HOME CATALINA_HOME CLASS_PATH

安装apache-tomcat-7.0.47.tar.gz

tar  -zxvf  apache-tomcat-7.0.47.tar.gz

mkdir  /usr/local/nginx/html/tomcat

cp -rf  apache-tomcat-7.0.47   /usr/local/nginx/html/tomcat

/usr/local/nginx/html/tomcat/bin/startup.sh 启动tomcat

# netstat -tunlap |grep :8080 监听端口是否启动

测试:


  # 1.3.14这个版本号自己改的哦

测试成功

阅读(13985) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~