Centos 配置 Nginx+Tomcat

1.系统信息

cat /etc/issue

CentOS release 6.5 (Final)
Kernel \r on an \m

uname  -a

Linux GHCLC6X-4352 2.6.32-431.29.2.el6.x86_64 #1 SMP Tue Sep 9 21:36:05 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

2.配置yum

yum clean all
yum makecache
yum update

3.安装nginx

yum info nginx 查看nginx的版本信息
yum nginx
service nginx restart
netstat -ntpl | grep 80  看是否有80端口进程

3.安装nginx依赖包

yum install -y make apr* autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libjpeg* libpng* php-common php-gd gettext gettext-devel ncurses* libtool* libxml2 libxml2-devel patch policycoreutils bison

4.编译安装nginx(支持伪静态)

./configure  --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/Disk/log/nginx/error.log --http-log-path=/Disk/log/nginx/access.log --pid-path=/Disk/log/nginx/run/nginx.pid --lock-path=/Disk/log/nginx/run/nginx.lock --http-client-body-temp-path=/Disk/log/nginx/cache/client_temp --http-proxy-temp-path=/Disk/log/nginx/cache/proxy_temp --http-fastcgi-temp-path=/Disk/log/nginx/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/Disk/log/nginx/cache/nginx/uwsgi_temp --http-scgi-temp-path=/Disk/log/nginx/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-pcre=/Disk/nginx_source/pcre-8.35

5.修改配置文件支持tomcat调用

    

cat ad.conf 
upstream test{
           server HostIP:Port  weight=20 max_fails=2 fail_timeout=30s;
           ip_hash;
                }
server {
    listen       80;
    server_name  www.test.com;
        root   /var/www/index;
        index  index.html index.htm;
location / {
          proxy_pass      http://test;
          proxy_set_header HOST   $host;
          proxy_set_header X-Real-IP      $remote_addr;
          proxy_set_header X-Forwarded-FOR $proxy_add_x_forwarded_for;
              }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}


你可能感兴趣的:(tomcat,nginx,centos)