Open felix-cao opened 5 years ago
nginx 官网下载地址
cd /home/ mkdir software wget -c https://nginx.org/download/nginx-1.14.0.tar.gz
tar -zxvf nginx-1.14.0.tar.gz cd nginx-1.14.0 ./configure make make install
configure 命令执行后
configure
nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
查找安装路径
$ whereis nginx
$ cd /usr/local/nginx/sbin/
./nginx ./nginx -s stop ./nginx -s quit ./nginx -s reload
./nginx -s quit:此方式停止步骤是待nginx进程处理任务完毕进行停止。 ./nginx -s stop:此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:
nginx
$ ./nginx -s quit $ ./nginx
当 nginx 的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload不用先停止 nginx 再启动 nginx 即可将配置信息在 nginx 中生效,如下:
nginx.conf
-s reload
$ ./nginx -s reload
即在rc.local增加启动代码就可以了。
rc.local
$ vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx 设置执行权限:
/usr/local/nginx/sbin/nginx
$ chmod 755 rc.local
安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:
gcc
$ yum install gcc-c++
PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。nginx 也需要此库。命令:
PCRE(Perl Compatible Regular Expressions)
Perl
perl
http
pcre
linux
pcre-devel
$ yum install -y pcre pcre-devel
zlib 库提供了很多种压缩和解压缩的方式, nginx 使用 zlib 对 http 包的内容进行 gzip ,所以需要在 Centos 上安装 zlib 库。
zlib
gzip
Centos
$ yum install -y zlib zlib-devel
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。 nginx 不仅支持 http 协议,还支持 https(即在ssl协议上传输http),所以需要在 Centos 安装 OpenSSL 库。
OpenSSL
SSL
https
ssl
yum install -y openssl openssl-devel
可能80端口被占用:
80
netstat -anp|grep 80
yum -y install gcc automake autoconf libtool make
nginx 官网下载地址
一、下载
二、解压安装
configure
命令执行后查找安装路径
三、启动、停止nginx
./nginx ./nginx -s stop ./nginx -s quit ./nginx -s reload
四、重启 nginx
4.1.先停止再启动(推荐):
对
nginx
进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:4.2.重新加载配置文件:
当
nginx
的配置文件nginx.conf
修改后,要想让配置生效需要重启nginx
,使用-s reload
不用先停止nginx
再启动nginx
即可将配置信息在nginx
中生效,如下:五、开机自启动
即在
rc.local
增加启动代码就可以了。增加一行
/usr/local/nginx/sbin/nginx
设置执行权限:六、可能需要安装依赖环境
6.1.、gcc 安装
安装
nginx
需要先将官网下载的源码进行编译,编译依赖gcc
环境,如果没有gcc
环境,则需要安装:6.2、 PCRE pcre-devel 安装
PCRE(Perl Compatible Regular Expressions)
是一个Perl
库,包括perl
兼容的正则表达式库。nginx
的http
模块使用pcre
来解析正则表达式,所以需要在linux
上安装pcre
库,pcre-devel
是使用pcre
开发的一个二次开发库。nginx
也需要此库。命令:6.3、 zlib 安装
zlib
库提供了很多种压缩和解压缩的方式,nginx
使用zlib
对http
包的内容进行gzip
,所以需要在Centos
上安装zlib
库。6.4、 OpenSSL 安装
OpenSSL
是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL
协议,并提供丰富的应用程序供测试或其它目的使用。nginx
不仅支持http
协议,还支持https
(即在ssl
协议上传输http
),所以需要在Centos
安装OpenSSL
库。Error
可能
80
端口被占用: