nginx-1.12.0版本(编译安装)-自定义安装路径
admin
2023-03-17 21:21:19
0

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

安装路径:/application/nginx-1.12.0

1.前期准备

安装编译需要的gccgcc-c++

yum install -y gcc gcc-c++

nginx依赖

pcre-developenssl-develzlib-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命令文件


 


相关内容

热门资讯

今日重大消息“微乐家乡大贰辅助... 网上科普关于“微乐家乡大贰有没有挂”话题很是火热,小编也是针对微乐家乡大贰作*弊开挂的方法以及开挂对...
我来教教您“友乐广西麻将到底有... 您好:友乐广西麻将这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这款...
终于明白“花花生活圈开挂神器?... 网上科普关于“花花生活圈有没有挂”话题很是火热,小编也是针对花花生活圈作*弊开挂的方法以及开挂对应的...
终于了解“AAPOKER到底是... 有 亲,根据资深记者爆料AAPOKER是可以开挂的,确实有挂(咨询软件无...
终于明白“山西互动是不是有挂?... 网上科普关于“山西互动有没有挂”话题很是火热,小编也是针对山西互动作*弊开挂的方法以及开挂对应的知识...
【第一资讯】“推大石怎么装挂?... 有 亲,根据资深记者爆料推大石是可以开挂的,确实有挂(咨询软件无需打开直...
玩家分享攻略“秦乐陕西麻将开挂... 网上科普关于“秦乐陕西麻将有没有挂”话题很是火热,小编也是针对秦乐陕西麻将作*弊开挂的方法以及开挂对...
终于了解“新上游炸/金/花究竟... 网上科普关于“新上游炸/金/花有没有挂”话题很是火热,小编也是针对新上游炸/金/花作*弊开挂的方法以...
终于明白“趣友麻将究竟有挂吗?... 网上科普关于“趣友麻将有没有挂”话题很是火热,小编也是针对趣友麻将作*弊开挂的方法以及开挂对应的知识...
最新引进“至尊宝炸金花开挂器?... 家人们!今天小编来为大家解答至尊宝炸金花透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里...