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技术有关,调试内核和内核模块.修改内核源码,是学习内核的重要技术手段之一.应用这些技术时,都有一本基本的要求,那就是编译内核.因此,在分析内核调试技术之前,本随笔给 ...
随机推荐
- vue input,textarea失去焦点调用函数方法
<input type="number" class="num" value="1" @blur.prevent="chan ...
- Mockito学习1
Mockito学习1 junitmaven软件测试框架项目管理 Mockito是一个流行的Mocking框架.它使用起来简单,学习成本很低,而且具有非常简洁的API,测试代码的可读性很高.因此它十分 ...
- Epson Pos Printer for .net
注:因发现各网站爬虫随意收集文章,故做此声明:版权归原作者(Leaf.Duan)所有,转载还请著名出处,谢谢 设备信息 Epson TM-T88IV Thermal Printer,爱普生 TM-T8 ...
- 使用policheck 检测
Policheck is a profing and testing tool for sensitive terminology and helps in ensuring thattrustwor ...
- bootstrap 中 css 与 javascript 的使用
1.css 1.1.选择器 1.2.子选择器: css 里的子元素用符号'>'表示.如下示例是表示拥有table样式的表盒,其thead元素内的tr元素如果有th的话,则应用该样式. .tabl ...
- Mac 环境通用
mac 下更新 .bash_profile 文件 1.打开terminal(终端) 2.cd ~ ( 进入当前用户的home目录) 3.open .bash_profile (打开.bash_prof ...
- 《团队-爬取豆瓣电影TOP250-设计文档》
搭建环境: 1.安装python3.4 2.安装pycharm集成开发环境 3.安装Git for Windows 4.安装python第三方包 bs4开发阶段: 1.团队成员申请并配置github账 ...
- mac挂载ntfs文件系统方法
1.插入磁盘,并查看 zz@pzdeMacBook-Pro:~/Volumes/ntfs16g$ df Filesystem 512-blocks Used Available Capacity iu ...
- centos7 新增ip
1.进入network-scripts目录:cd /etc/sysconfig/network-scripts/ 2.复制ifcfg-eth0: cp ifcfg-eth0 ifcfg-eth0:0 ...
- mysql update受影响的行数为0或查询结果为空时
当执行update语句时,如果受影响的行数是0,返回的也是true. $conn = new mysqli(); $sql = "update ..."; $query = $co ...