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. @1-2初识Python爬虫

    初识Python爬虫 Python爬虫(入门+进阶)     DC学院 环境搭建: Python2与Python3的差异:python2与python3整体差异不大,大多是一些语法上的区别,考虑到py ...

  2. sqli-labs:11-16,post注入

    sqli11: post:uname=xx' order by 2#&passwd=bla&submit=Submit(判定字段为2) 解释下为什么结果不是admin,这是sql执行的 ...

  3. Java学习笔记:注解Annotation

    annotation的概念 In the Java computer programming language, an annotation is a form of syntactic metada ...

  4. Python中sys和os模块的区别

    sys: This module provides access to some variables used or maintained by the interpreter and to func ...

  5. MyBatis中log4j 和 参数 和 分页和别名 功能

    1.配置全局文件,注意各个配置标签的顺序 properties?, settings?, typeAliases?, typeHandlers?, objectFactory?,   objectWr ...

  6. 2018.06.27The Windy's(费用流)

    The Windy's Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 6003 Accepted: 2484 Descripti ...

  7. poj--2299(树状数组+离散化)

    一.离散化: https://www.cnblogs.com/2018zxy/p/10104393.html 二.逆序数 AC代码: #include<iostream> #include ...

  8. Calendar 得到前一天当前时间

    @Test public void test(){ //因为Calendar的构造方法是私有的,所以实例化一个Calendar对象用getInstance方法 Calendar calendar = ...

  9. php输出语句

    看不懂? 抄一遍代码吧. echo 和 print 在 PHP 中有两个基本的输出方式: echo 和 print echo 和 print 区别: echo - 可以输出一个或多个字符串 print ...

  10. Arria10_emif

    DDR3 由排(Rank),体(Bank),行(Row),列(Column)组成的四维结构. Arria10是第一批支持ddr4的altera Arria10与老器件相比的新结构 (1)  更多的硬( ...