1.系统信息
cat /etc/issue
1
2
<code>CentOS release 6.5 (Final)</code>
<code>Kernel \r on an \m</code>
uname -a
<code>Linux GHCLC6X-4352 2.6.32-431.29.2.el6.x86_64 </code><code>#1 SMP Tue Sep 9 21:36:05 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux</code>
2.配置yum
3
<code>yum clean all</code>
<code>yum makecache</code>
<code>yum update</code>
3.安装nginx
4
<code>yum info nginx 查看nginx的版本信息</code>
<code>yum nginx</code>
<code>service nginx restart</code>
<code>netstat</code> <code>-ntpl | </code><code>grep</code> <code>80 看是否有80端口进程</code>
3.安装nginx依赖包
<code>yum </code><code>install</code> <code>-y </code><code>make</code> <code>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</code>
4.编译安装nginx(支持伪静态)
<code>.</code><code>/configure</code> <code>--prefix=</code><code>/etc/nginx</code> <code>--sbin-path=</code><code>/usr/sbin/nginx</code> <code>--conf-path=</code><code>/etc/nginx/nginx</code><code>.conf --error-log-path=</code><code>/Disk/log/nginx/error</code><code>.log --http-log-path=</code><code>/Disk/log/nginx/access</code><code>.log --pid-path=</code><code>/Disk/log/nginx/run/nginx</code><code>.pid --lock-path=</code><code>/Disk/log/nginx/run/nginx</code><code>.lock --http-client-body-temp-path=</code><code>/Disk/log/nginx/cache/client_temp</code> <code>--http-proxy-temp-path=</code><code>/Disk/log/nginx/cache/proxy_temp</code> <code>--http-fastcgi-temp-path=</code><code>/Disk/log/nginx/cache/nginx/fastcgi_temp</code> <code>--http-uwsgi-temp-path=</code><code>/Disk/log/nginx/cache/nginx/uwsgi_temp</code> <code>--http-scgi-temp-path=</code><code>/Disk/log/nginx/cache/nginx/scgi_temp</code> <code>--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-</code><code>file</code><code>-aio --with-ipv6 --with-http_spdy_module --with-cc-opt=</code><code>'-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'</code> <code>--with-pcre=</code><code>/Disk/nginx_source/pcre-8</code><code>.35</code>
5.修改配置文件支持tomcat调用
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<code>cat</code> <code>ad.conf </code>
<code>upstream </code><code>test</code><code>{</code>
<code> </code><code>server HostIP:Port weight=20 max_fails=2 fail_timeout=30s;</code>
<code> </code><code>ip_hash;</code>
<code> </code><code>}</code>
<code>server {</code>
<code> </code><code>listen 80;</code>
<code> </code><code>server_name www.</code><code>test</code><code>.com;</code>
<code> </code><code>root </code><code>/var/www/index</code><code>;</code>
<code> </code><code>index index.html index.htm;</code>
<code>location / {</code>
<code> </code><code>proxy_pass http:</code><code>//test</code><code>;</code>
<code> </code><code>proxy_set_header HOST $host;</code>
<code> </code><code>proxy_set_header X-Real-IP $remote_addr;</code>
<code> </code><code>proxy_set_header X-Forwarded-FOR $proxy_add_x_forwarded_for;</code>
<code> </code><code>}</code>
<code> </code><code>error_page 500 502 503 504 </code><code>/50x</code><code>.html;</code>
<code> </code><code>location = </code><code>/50x</code><code>.html {</code>
<code> </code><code>root </code><code>/usr/share/nginx/html</code><code>;</code>
<code> </code><code>}</code>
<code>}</code>
<code></code>
本文转自 xinsir999 51CTO博客,原文链接:http://blog.51cto.com/xinsir/1572796,如需转载请自行联系原作者