nginx-1.12.0版本(编译安装)-自定义安装路径

安装路径:/application/nginx-1.12.0

1.前期准备

安装编译需要的gcc和gcc-c++

yum install -y gcc gcc-c++

nginx依赖

pcre-devel、openssl-devel、zlib-devel

yum install -y pcre pcre-devel openssl openssl-devel zlib zlib-devel

创建用户nginx,以该用户的身份执行nginx

useradd -s /bin/false -M nginx

下载nginx源码包并解压到当前目录

cd /tools

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

tar -zxf nginx-1.12.0.tar.gz

2.nginx编译安装

生成Makefile文件

cd nginx-1.12.0

./configure --user=nginx --group=nginx --prefix=/application/nginx-1.12.0/ --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre

编译源代码并安装

make && make install

3.后期结尾

给nginx-1.12.0创建软链接去掉末尾的版本号

ln -s /application/nginx-1.12.0/ /application/nginx

添加环境变量

创建nginx命令软链接到环境变量

ln -s /application/nginx/sbin/* /usr/local/sbin/

4.配置nginx开启php支持

在server段中开启php支持

cd /application/nginx

vim conf/nginx.conf

找到如下内容,删除注释字符,并将倒数第二行的 /scripts 替换为 $document_root

修改前

#location ~ \.php$ {

#    root           html;

#    fastcgi_pass   127.0.0.1:9000;

#    fastcgi_index  index.php;

#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

#    include        fastcgi_params;

#}

修改后

location ~ \.php$ {

root           html;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

该段代码在server中的位置:

server {

listen       80;

server_name  localhost;

location / {

root   html;

index  index.php index.html index.htm;

}

location ~ \.php$ {

root           html;

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

}

注意:location ~ \.php$ {}块中root的值和location / {}块中root的值需要一致

5.常用命令

检查配置文件

nginx -t

指定其他配置文件启动nginx

nginx -c /application/nginx/conf/nginx.conf.bak

启动nginx

nginx

停止nginx

nginx -s stop

重启nginx

nginx -s reload

参数解释

-s stop 快速停止nginx

-s quit 平滑停止nginx

-s reopen 重新打开日志文件

-s reload 平滑重载所有配置

6.目录介绍

[root@www nginx]# tree

.

├── conf  #配置文件目录

│   ├── fastcgi.conf

│   ├── fastcgi.conf.default

│   ├── fastcgi_params

│   ├── fastcgi_params.default  #fastcgi *配合php

│   ├── koi-utf

│   ├── koi-win

│   ├── mime.types  #mime 媒体类型

│   ├── mime.types.default

│   ├── nginx.conf  #nginx主配置文件

│   ├── nginx.conf.default

│   ├── scgi_params

│   ├── scgi_params.default

│   ├── uwsgi_params

│   ├── uwsgi_params.default

│   └── win-utf

├── html  #默认站点目录

│   ├── 50x.html

│   └── index.html

├── logs  #访问日志、错误日志、pid文件目录

│   ├── access.log  #访问日志

│   ├── error.log  #错误日志

│   └── nginx.pid  #pid文件

└── sbin  #命令目录

└── nginx  #nginx命令文件

nginx-1.12.0版本(编译安装)-自定义安装路径的更多相关文章

  1. nginx 升级为最新版 nginx -1.12.0

    标签:nginx 公司目前使用的nginx版本比较低(nginx-1.0.12),请网络安全公司做了一下“远程安全评估”,发现有下列漏洞: nginx URI处理安全限制绕过漏洞(CVE-2013-4 ...

  2. Ubuntu20.04linux内核(5.4.0版本)编译准备与实现过程-编译过程(2)

    前面因为博客园维修,所以内核编译过程一直没有发出来,现在把整个内核过程分享出来.本随笔给出内核的编译实现过程,在编译前需要参照我前面一篇随笔: Ubuntu20.04linux内核(5.4.0版本)编 ...

  3. Centos7 编译安装 Nginx PHP Mariadb Memcached 扩展 ZendOpcache扩展 (实测 笔记 Centos 7.3 + Openssl 1.1.0e + Mariadb 10.1.22 + Nginx 1.12.0 + PHP 7.1.4 + Laravel 5.4 )

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7-x86_64-Minimal-1611.iso 安装步骤: 1.准备 1.0 查看硬 ...

  4. 安装篇四:安装NGINX(1.4.0版本)

    #1.NGINX安装 1.安装文件上传软件 [root@TEST ~]# yum install lrzsz –y <---拖拽文件 2.检查软件安装的系统环境 [root@TEST ~]# c ...

  5. GCC 7.3.0版本编译http-parser-2.1问题

    http-paser是一个用c编写的http消息解析器,地址:https://github.com/nodejs/http-parser,目前版本2.9 今天用gcc 7.3.0编译其2.1版本时,编 ...

  6. GraphScope v0.12.0 版本发布

    GraphScope 每月进行常规版本的迭代与发布,GraphScope v0.12.0 全新版本在四月如期而至.v0.12.0 为交互式图查询 GAIA 引入全新的 IR 层以及新增 Giraph ...

  7. loadrunner 12.0.2 的下载和安装

    链接: https://pan.baidu.com/s/1o2jQjPdUrRm451Pue8bbEg 提取码: gpj6 安装了loadrunner  11 打开文件可自动更新到12 第一部分:安装 ...

  8. Tensorflow r1.12及tensorflow serving r1.12 GPU版本编译遇到的问题

    1.git clone tensorflow serving 及tensorflow代码 2. ERROR: /root/.cache/bazel/_bazel_root/f71d782da17fd8 ...

  9. Ubuntu20.04linux内核(5.4.0版本)编译准备与实现过程-编译前准备(1)

    最近项目也和linux kernel技术有关,调试内核和内核模块.修改内核源码,是学习内核的重要技术手段之一.应用这些技术时,都有一本基本的要求,那就是编译内核.因此,在分析内核调试技术之前,本随笔给 ...

随机推荐

  1. 摹客 iDoc 12月上半月新功能点评

    转眼就到了2018年的最后一个月,小伙伴们是不是都在奋力拼搏做年底的冲刺呢?摹客也没有放慢脚步,不断地优化,给大家带来一个又一个的惊喜.那么,让小摹来带大家看看12月摹客iDoc更新了哪些特色功能: ...

  2. c++11 template 模板练习

    直接上代码吧 to do // 111111.cpp: 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> ...

  3. Maximum Average Subarray I LT643

    Given an array consisting of n integers, find the contiguous subarray of given length k that has the ...

  4. HttpURLConnection 返回汉字乱码(全是问号)

    public static String doPost(String urlStr, Map<String, Object> paramMap) throws Exception { UR ...

  5. Spring中@Autowired注解、@Resource注解的区别 (zz)

    Spring中@Autowired注解.@Resource注解的区别 Spring不但支持自己定义的@Autowired注解,还支持几个由JSR-250规范定义的注解,它们分别是@Resource.@ ...

  6. Django的学习(五)————实战问题

    一.多参数问题: 首先是在添加一个新的参数,其次在url中把这个id传递过去 def article_page(request, article_id): article = models.Artic ...

  7. 682. Baseball Game

    static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...

  8. GDI基础(2):绘制文本

    1.TextOut()和DrawText()函数 CDC::TextOut()在窗口的指定位置处输出文本,函数声明: virtual BOOL TextOut(int x, int y, LPCTST ...

  9. php 验证码 图像存在错误 无法显示 解决方法

    <?php $height = 300; $width = 300; $im = imagecreatetruecolor($width, $height); $white = imagecol ...

  10. VIP之FrameBuffer

     2.VIP Frame Buffer 1.原来我是一直存在一个疑惑,demo上说VIP Frame Buffer输出是固定的60fps,但是在NiosII的程序中我没有找到设置输出为60fps的设置 ...