nginx 1.9 安装

简介:
  1. 安装说明

  2. 系统环境:CentOS 6.4

  3. 软件:nginx-1.9.12.tar.gz

  4. 安装方式:源码编译安装

  5. 安装位置:/usr/local/nginx

  6. 下载地址:http://nginx.org/en/download.html



  1. 1.yum 安装一些依赖包

    [root@niaoyun-101 tools]# yum install  pcre*  zlib*    gcc     openssl  openssl-devel  libxml*  libxslt*   gd-devel  GeoI GeoIP-data GeoIP-devel  perl-devel perl-ExtUtils-Embed  gcc-c++


wget  http://nginx.org/download/nginx-1.9.12.tar.gz


  1. cd  nginx-1.9.12

  2.  ./configure  --prefix=/usr/local/nginx   --user=nobody --group=nobody   --with-http_stub_status_module  --with-http_ssl_module

  3. make && make install

  4. /usr/local/nginx/sbin/nginx -V  

  5. vi /etc/init.d/nginx

  6. #!/bin/bash
    # chkconfig: - 30 21
    # description: http service.
    # Source Function Library
    . /etc/init.d/functions
    # Nginx Settings

    NGINX_SBIN="/usr/local/nginx/sbin/nginx"
    NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
    NGINX_PID="/usr/local/nginx/logs/nginx.pid"
    RETVAL=0
    prog="Nginx"

    start() {
            echo -n $"Starting $prog: "
            mkdir -p /dev/shm/nginx_temp
            daemon $NGINX_SBIN -c $NGINX_CONF
            RETVAL=$?
            echo
            return $RETVAL
    }

    stop() {
            echo -n $"Stopping $prog: "
            killproc -p $NGINX_PID $NGINX_SBIN -TERM
            rm -rf /dev/shm/nginx_temp
            RETVAL=$?
            echo
            return $RETVAL
    }

    reload(){
            echo -n $"Reloading $prog: "
            killproc -p $NGINX_PID $NGINX_SBIN -HUP
            RETVAL=$?
            echo
            return $RETVAL
    }

    restart(){
            stop
            start
    }

    configtest(){
        $NGINX_SBIN -c $NGINX_CONF -t
        return 0
    }

    case "$1" in
      start)
            start
            ;;
      stop)
            stop
            ;;
      reload)
            reload
            ;;
      restart)
            restart
            ;;
      configtest)
            configtest
            ;;
      *)
            echo $"Usage: $0 {start|stop|reload|restart|configtest}"
            RETVAL=1
    esac
    exit $RETVAL

    保存后,执行
    chmod a+x /etc/init.d/nginx
    chkconfig --add nginx
    chkconfig nginx on

vim /usr/local/nginx/conf/nginx.conf //清空原来的配置,加入如下内容:


user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
events
{
    use epoll;
    worker_connections 6000;
}
http

{
    include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 3526;
    server_names_hash_max_size 4096;
    log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
    '$host "$request_uri" $status'
    '"$http_referer" "$http_user_agent"';
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 30;
    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;
    connection_pool_size 256;
    client_header_buffer_size 1k;
    large_client_header_buffers 8 4k;
    request_pool_size 4k;
    output_buffers 4 32k;
    postpone_output 1460;
    client_max_body_size 10m;
    client_body_buffer_size 256k;
    client_body_temp_path /usr/local/nginx/client_body_temp;
    proxy_temp_path /usr/local/nginx/proxy_temp;
    fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
    fastcgi_intercept_errors on;
    tcp_nodelay on;
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 8k;
    gzip_comp_level 5;
    gzip_http_version 1.1;
    gzip_types text/plain application/x-javascript text/css text/htm application/xml;

   include  vhosts/*.conf;   

}




mkdir  /usr/local/nginx/conf/vhosts


vi jzg.conf

// 加入


server

{
    listen 80;
    server_name localhost;
    index index.html index.htm index.php;
    root /data/www;

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/php-fcgi.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
    }
}


mkdir -p /data/www

/usr/local/nginx/sbin/nginx -t  检查配置文件

重新加载/usr/local/nginx/sbin/nginx -s  reload



本文转自 15816815732 51CTO博客,原文链接:http://blog.51cto.com/68686789/1888905

相关文章
|
15天前
|
NoSQL 关系型数据库 Redis
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
mall在linux环境下的部署(基于Docker容器),docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongodb、minio详细教程,拉取镜像、运行容器
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
|
30天前
|
应用服务中间件 Linux 网络安全
2022年超详细在CentOS 7上安装Nginx方法(源码安装)
这篇文章提供了在CentOS 7系统上通过源码安装Nginx的详细步骤,包括从官网下载Nginx源码包、上传至虚拟机、解压、删除压缩包、编译安装前的配置、安装PCRE库(因为Nginx使用PCRE库解析正则表达式)、安装zlib和OpenSSL库(用于支持HTTPS协议)、重新编译Nginx、安装后启动Nginx服务、关闭服务、修改默认端口、以及重启服务测试等步骤。文章还提供了相关命令和操作截图,帮助用户更好地理解和执行安装过程。
2022年超详细在CentOS 7上安装Nginx方法(源码安装)
|
1月前
|
应用服务中间件 PHP nginx
Mac安装Nginx
Mac安装Nginx
22 2
Mac安装Nginx
|
21天前
|
缓存 应用服务中间件 nginx
安装nginx-http-flv-module模块
本文介绍如何为Nginx安装`nginx-http-flv-module`模块。此模块基于`nginx-rtmp-module`二次开发,不仅具备原模块的所有功能,还支持HTTP-FLV播放、GOP缓存、虚拟主机等功能。安装步骤包括:确认Nginx版本、下载相应版本的Nginx与模块源码、重新编译Nginx并加入新模块、验证模块安装成功。特别注意,此模块已包含`nginx-rtmp-module`功能,无需重复编译安装。
56 1
|
2月前
|
应用服务中间件 Linux 网络安全
|
30天前
|
应用服务中间件 Linux nginx
Linux虚拟机磁盘扩容、Docker容器磁盘满的问题、Docker安装nginx
这篇文章讨论了Linux虚拟机磁盘扩容的方法,包括外部配置、具体扩容步骤和扩容后的效果验证。同时,文章还涉及了Docker容器磁盘满的问题及其解决方法,如删除不必要的镜像和容器,以及调整Docker的安装路径。此外,还提到了意外情况的处理,例如误删除停止的容器后的应对措施。最后,文章还提供了使用Docker安装nginx的步骤和成功访问的截图。
Linux虚拟机磁盘扩容、Docker容器磁盘满的问题、Docker安装nginx
|
1月前
|
应用服务中间件 Linux nginx
在CentOS上使用源码包安装Nginx、以及手动启动Nginx的步骤过程
这篇文章介绍了在CentOS系统上使用Nginx源码包进行安装和配置的详细步骤,包括源码包的获取、解压、配置、编译、安装、启动验证以及注意事项。
65 0
在CentOS上使用源码包安装Nginx、以及手动启动Nginx的步骤过程
|
1月前
|
应用服务中间件 网络安全 nginx
运维专题.Docker+Nginx服务器的SSL证书安装
运维专题.Docker+Nginx服务器的SSL证书安装
40 3
|
1月前
|
JavaScript 应用服务中间件 nginx
Windows安装hexo并配置nginx
Windows安装hexo并配置nginx
|
1月前
|
应用服务中间件 Shell 网络安全
nginx安装提示 libssl.so.3: cannot open shared object file: No
【8月更文挑战第1天】### 原因 未将安装的ssl中的`libssl.so.3`链接到`/usr/lib`导致缺失。 ### 解决方案 1. 检查openssl是否已安装,若为低版本则需重装。 ```sh whereis openssl
379 6