nginx-1.12.0版本(编译安装)-自定义安装路径
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版本(编译安装)-自定义安装路径的更多相关文章
- nginx 升级为最新版 nginx -1.12.0
标签:nginx 公司目前使用的nginx版本比较低(nginx-1.0.12),请网络安全公司做了一下“远程安全评估”,发现有下列漏洞: nginx URI处理安全限制绕过漏洞(CVE-2013-4 ...
- Ubuntu20.04linux内核(5.4.0版本)编译准备与实现过程-编译过程(2)
前面因为博客园维修,所以内核编译过程一直没有发出来,现在把整个内核过程分享出来.本随笔给出内核的编译实现过程,在编译前需要参照我前面一篇随笔: Ubuntu20.04linux内核(5.4.0版本)编 ...
- 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 查看硬 ...
- 安装篇四:安装NGINX(1.4.0版本)
#1.NGINX安装 1.安装文件上传软件 [root@TEST ~]# yum install lrzsz –y <---拖拽文件 2.检查软件安装的系统环境 [root@TEST ~]# c ...
- 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版本时,编 ...
- GraphScope v0.12.0 版本发布
GraphScope 每月进行常规版本的迭代与发布,GraphScope v0.12.0 全新版本在四月如期而至.v0.12.0 为交互式图查询 GAIA 引入全新的 IR 层以及新增 Giraph ...
- loadrunner 12.0.2 的下载和安装
链接: https://pan.baidu.com/s/1o2jQjPdUrRm451Pue8bbEg 提取码: gpj6 安装了loadrunner 11 打开文件可自动更新到12 第一部分:安装 ...
- Tensorflow r1.12及tensorflow serving r1.12 GPU版本编译遇到的问题
1.git clone tensorflow serving 及tensorflow代码 2. ERROR: /root/.cache/bazel/_bazel_root/f71d782da17fd8 ...
- Ubuntu20.04linux内核(5.4.0版本)编译准备与实现过程-编译前准备(1)
最近项目也和linux kernel技术有关,调试内核和内核模块.修改内核源码,是学习内核的重要技术手段之一.应用这些技术时,都有一本基本的要求,那就是编译内核.因此,在分析内核调试技术之前,本随笔给 ...
随机推荐
- Spring Environment(二)源码分析
Spring Environment(二)源码分析 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html) Spring Envi ...
- Pairs of Songs With Total Durations Divisible by 60 LT1010
In a list of songs, the i-th song has a duration of time[i] seconds. Return the number of pairs of s ...
- HttpURLConnection 返回汉字乱码(全是问号)
public static String doPost(String urlStr, Map<String, Object> paramMap) throws Exception { UR ...
- 表单提交textarea内容,第一次获取不到值,第二次才能获取到的解决方法:
因为KindEditor的可视化操作在新创建的iframe上执行,代码模式下的textarea框也是新创建的,所以最后提交前需要执行 sync() 将HTML数据设置到原来的textarea. Kin ...
- 第09章:MongoDB-CRUD操作--文档--修改--update
①语法 db.collection.update( <query>, <update>, { upsert: <boolean>, multi: <boole ...
- iframe父子元素获取
jquery.js调用iframe父窗口与子窗口元素的方法 1. jquery在iframe子页面获取父页面元素代码如下: $("#objid",parent.document) ...
- BT1120时序,可以用于自测用
module bt1120_gen #( , , , , , )( input clk, input rst_p, // input [5:0] h_sync_pixcels, // input [5 ...
- DDR4控制笔记
DDR4接口 A[17:0] input 为激活命令提 供行地址,为读.写命令地址输入:提供列地址,也为模式寄存器设 置提供操作码,A[16]只用于8Gb和16Gb,A[17]只用于16Gb,另外 ...
- ROM的一种写法
module mr_rom_pll_valuemask_8bpc #( , , , , // 6*7 // alt_clogb2(42) ) ( input wire clock, :] addr_p ...
- Path类对路径字符串的操作
在写程序时,不时会用到处理文件路径的问题,例如:取得扩展名.从路径中取出文件名.路径合并.取出或者去年扩展名等.这些功能都可以通过System.IO.Path类提供的方法来实现.这些相关功能用过多次了 ...