【银河国际手机版最新】Linux下编译安装Nginx服务器

009 Linux下编写翻译安装Nginx服务器 并 修改Nginx服务器访谈根目录,009nginx

一、 nginx安装意况

       yum install -y gcc-c++   pcre pcre-devel zlib zlib-devel  openssl
openssl-devel

该命令等效于下边4句:

1、  gcc 安装
       
安装nginx须求先上将方网址下载的源码实行编写翻译,编写翻译信任gcc碰到,若无gcc景况,需求设置gcc:

         yum install gcc-c++

2、  PCRE pcre-devel 安装
       PCRE(PerlCompatible Regular Expressions)是八个Perl库,包涵 perl
包容的正则表明式库。nginx的http模块使用pcre来深入分析正则表达式,所以供给在linux上设置pcre库。
        yum install -y pcre pcre-devel

3、  zlib 安装
       
zlib库提供了相当多样回退和平化解压缩的办法,nginx使用zlib对http包的原委张开gzip,所以必要在linux上设置zlib库。
        yum  install -y zlib zlib-devel

4、OpenSSL 安装
     
OpenSSL是叁个强劲的乌海套接字层密码库,囊括重要的密码算法、常用的密钥和证书封装处理功效及SSL合同,并提供丰盛的应用程序供测验或任何指标使用。nginx不仅仅辅助http合同,还帮忙https(即在ssl合同上传输http),所以供给在linux安装openssl库。
       yum  install -y openssl openssl-devel

二、下载nginx

1.直接下载.tar.gz安装包,地址:

2.接纳wget命令下载1.10.1本子(推荐)。
wget -c

三、安装

1、解压
tar -zxvf nginx-1.10.1.tar.gz
cd nginx-1.10.1

2、配置
其实在 nginx-1.10.1
版本中您就没有需求去安插相关东西,暗中同意就能够了。当然,若是您要自个儿安插目录也是足以的。
1.用到私下认可配置
./configure
输出:
      nginx path prefix: “/usr/local/nginx”
      nginx binary file: “/usr/local/nginx/sbin/nginx”
      nginx modules path: “/usr/local/nginx/modules”
      nginx configuration prefix: “/usr/local/nginx/conf”
      nginx configuration file: “/usr/local/nginx/conf/nginx.conf”
      nginx pid file: “/usr/local/nginx/logs/nginx.pid”
      nginx error log file: “/usr/local/nginx/logs/error.log”
      nginx http access log file: “/usr/local/nginx/logs/access.log”
      nginx http client request body temporary files:
“client_body_temp”
      nginx http proxy temporary files: “proxy_temp”
      nginx http fastcgi temporary files: “fastcgi_temp”
      nginx http uwsgi temporary files: “uwsgi_temp”
      nginx http scgi temporary files: “scgi_temp”

3、编写翻译安装
make
make install

招来安装路线:”/usr/local/nginx

四、开放80端口、开放http服务,重启防火墙
    firewall-cmd –zone=public –add-port=80/tcp –permanent
    firewall-cmd –permanent –zone=public –add-service=http
    firewall-cmd –reload
    firewall-cmd –list-all
#翻看开放服务、端口中是或不是有http服务和80端口。

五、改造nginx访谈根目录
安装完nginx服务器后发掘nginx的根目录在
安装目录的/html/下(/usr/local/nginx/html/),可是对于陈设文件来讲,在该目录下是不太习贯的,作者就尝试着改动nginx访谈的根目录

1、改造nginx配置文件

   vi  /usr/local/nginx/conf/nginx.conf

改动如下:

    server {
        listen       80;
        server_name  localhost;
        location / {                 
            root  /home/ftpuser/wwwRoot;               #新的根目录
            index  index.html index.htm index.jpg;  
#增多一张图片,测验用。
        }

2、nginx根目录权限设置:

         chmod  -R 755  /home/ftpuser/wwwRoot/

3、重启nginx务器
     service nginx restart

4、测试

拷贝一贯张jpg格式图片到:/home/ftpuser/wwwRoot/目录下,改名称为:index.jpg

chmod  744  /home/ftpuser/wwwRoot/index.jpg #安装全体人可读。
访问
安装完结后此时作客   即为/home/www/XXX

六、使用nginx
1 启动nginx
 /usr/local/nginx/sbin/nginx

只顾:实行 /usr/local/nginx/sbin/nginx,这里可以-c钦定加载的nginx配置文件,如下:
/usr/local/nginx/sbin/nginx -c /xxxxx
比方不内定-c,nginx在运营时私下认可加载/usr/local/nginx/conf/nginx.conf文件。

 
2 停止nginx
/usr/local/nginx/sbin/nginx -s quit
此措施甘休步骤是待nginx进度管理职分达成进行悬停。

 
3 重启nginx:先截止再开行
/usr/local/nginx/sbin/nginx -s quit
/usr/local/nginx/sbin/nginx

 

centos-64整合nginx和tomcat

分类:
Linux
2013-04-25 10:41 128人阅读 评论(0)
收藏 举报

1、安装wget和凭仗包
yum install wget
yum install make gcc gcc-c++ autoconf automake
yum install zlib zlib-devel openssl openssl-devel pcre pcre-devel

2、创造nginx目录并下载nginx最新稳固版本
mkdir /home/nginx/
wget nginx.org/download/nginx-1.2.8.tar.gz

3、解压并查看nginx的布置扶助
tar xvzf nginx-1.2.8.tar.gz
cd /home/nginx/nginx-1.2.8
[root@nignx nginx-1.2.8]# ./configure –help

4、配置nginx的装置选项
./configure
–prefix=/usr \
–sbin-path=/usr/sbin/nginx \
–conf-path=/etc/nginx/nginx.conf \
–error-log-path=/var/log/nginx/error.log \
–pid-path=/var/run/nginx/nginx.pid \
–lock-path=/var/lock/nginx.lock \
–user=nginx \
–group=nginx \
–with-http_ssl_module \
–with-http_flv_module \
–with-http_gzip_static_module \
–http-log-path=/var/log/nginx/access.log \
–http-client-body-temp-path=/var/tmp/nginx/client/ \
–http-proxy-temp-path=/var/tmp/nginx/proxy/ \
–http-fastcgi-temp-path=/var/tmp/nginx/fcgi/

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: “/usr/local/nginx”
  nginx binary file: “/usr/local/nginx/sbin/nginx”
  nginx configuration prefix: “/usr/local/nginx/conf”
  nginx configuration file: “/usr/local/nginx/conf/nginx.conf”
  nginx pid file: “/usr/local/nginx/logs/nginx.pid”
  nginx error log file: “/usr/local/nginx/logs/error.log”
  nginx http access log file: “/usr/local/nginx/logs/access.log”
  nginx http client request body temporary files: “client_body_temp”
  nginx http proxy temporary files: “proxy_temp”
  nginx http fastcgi temporary files: “fastcgi_temp”
  nginx http uwsgi temporary files: “uwsgi_temp”
  nginx http scgi temporary files: “scgi_temp”

5、安装
make && make install

6、运维、重启、截至nginx(注意安装目录)
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf//nginx.conf
/usr/local/nginx/sbin/nginx -s reload
pkill -9 nginx

7、关闭防火墙(或然加上80端口的平整)
service iptables stop

8、配置jdk和tomcat
wget

chmod +x jdk-6u45-linux-x64.bin
mv jdk1.6.0_45/ /usr/local/jdk
vi /etc/profile加多如下内容
JAVA_HOME=”/usr/local/jdk”
CLASS_PATH=”$JAVA_HOME/lib:$JAVA_HOME/jre/lib”
PATH=”.:$PATH:$JAVA_HOME/bin”
CATALINA_HOME=”/usr/local/tomcat”
export JAVA_HOME CATALINA_HOME
source /etc/profile使得配置生效

wget

tar zxvf apache-tomcat-6.0.36.tar.gz
mv apache-tomcat-6.0.36 /usr/local/tomcat
cp -rf /usr/local/tomcat/webapps/* /home/www/
vi
/usr/local/tomcat/conf/server.xml修改appBase=”webapps”为appBase=”/home/www/”,即网页根目录

9、配置nginx.conf
vi /usr/local/nginx/conf/nginx/conf
[root@nignx conf]# cat nginx.conf

#user  nobody;
worker_processes  2;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  error;

#pid        logs/nginx.pid;

events {
    use epoll;
    worker_connections  1024;
}

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;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  65;

    gzip  on;
    gzip_http_version 1.0;
    gzip_min_length 1000;
    gzip_buffers 4 32k;
    gzip_comp_level 5;
    gzip_disable “MSIE [1-6].”;
    gzip_types text/plain application/x-javascript text/css
text/javascript application;
    gzip_vary on;

    upstream tomcat_server {
        server 127.0.0.1:8080;
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;

        root   /home/www/webapps;

        location /manageUI/ {
            index /home/www/ROOT/test.jsp;
            proxy_pass ;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
            proxy_set_header Via “nginx”;
银河国际手机版最新,        }

        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

上述就水到渠成了nginx和tomcat的咬合

发表评论

电子邮件地址不会被公开。 必填项已用*标注