Nginx安装配置与部署
2015-11-18 15:54
776 查看
Nginx安装部署Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个 IMAP/POP3/SMTP 服务器,其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好。1、安装PCRE库
下载地址:http://www.pcre.org/
tar -jxvf pcre-8.36.tar.bz2
cd pcre-8.36
./configure
make
make install
2、安装zlib库
下载地址:http://zlib.net/
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
3、安装ssl
下载地址:http://www.openssl.org/
tar -zxvf openssl-1.0.2d.tar.gz
cd openssl-1.0.2d
./config
make
make install
备注:pcre为了重写rewrite,zlib为了gzip压缩,openssl是https访问所需。
4、安装nginx
Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,安装Nginx到 /usr/local/nginx 目录下。./configure --sbin-path=/usr/local/nginx/nginx--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/loacal/nginx/nginx.pid
--with-http_ssl_module
--with-http_realip_module
--with-http_sub_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_stub_status_module
--with-openssl=../openssl-1.0.2d
--with-pcre=../pcre-8.36
--with-zlib=../zlib-1.2.8
make
make install
5.启动nginx
进入到nginx安装目录/usr/local/nginx下,执行
[root@jason1~]# cd /usr/local/nginx/
[root@jason1nginx]# ./nginx
[root@jason1nginx]# ps -ef|grep nginx
root 17577 1 0 22:47 ? 00:00:00 nginx: master process ./nginx
nobody 17578 17577 0 22:47 ? 00:00:00 nginx:worker process
root 17580 3591 0 22:48 pts/1 00:00:00 grep nginx
[root@jason1nginx]#
通过访问web页面查看,显示如下结果
![](http://s2.51cto.com/wyfs02/M01/76/2B/wKioL1ZMM7mQffLmAAGMT-9jRwk950.jpg)
Nginx安装部署成功。
6、Nginx常用管理命令行参数。
[root@jason1nginx]# ./nginx -h
nginxversion: nginx/1.4.7
Usage:nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: /usr/local/nginx/nginx.conf)
-g directives : set global directives out ofconfiguration file
stop — shut down quickly
quit — shut down gracefully
reload — reload configuration, start thenew worker process with a new configuration, gracefully shut down old workerprocesses.
reopen — reopen log files
Nginx启动
/usr/local/nginx/nginx
Nginx关闭
/usr/local/nginx/nginx -s stop
/usr/local/nginx/nginx -s quit
Nginx重新加载配置文件
/usr/local/nginx/nginx -s reload
Nginx测试配置文件语法是否正确
/usr/local/nginx/nginx -t -c /usr/local/nginx/nginx.conf
下载地址:http://www.pcre.org/
tar -jxvf pcre-8.36.tar.bz2
cd pcre-8.36
./configure
make
make install
2、安装zlib库
下载地址:http://zlib.net/
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
3、安装ssl
下载地址:http://www.openssl.org/
tar -zxvf openssl-1.0.2d.tar.gz
cd openssl-1.0.2d
./config
make
make install
备注:pcre为了重写rewrite,zlib为了gzip压缩,openssl是https访问所需。
4、安装nginx
Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,安装Nginx到 /usr/local/nginx 目录下。./configure --sbin-path=/usr/local/nginx/nginx--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/loacal/nginx/nginx.pid
--with-http_ssl_module
--with-http_realip_module
--with-http_sub_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_stub_status_module
--with-openssl=../openssl-1.0.2d
--with-pcre=../pcre-8.36
--with-zlib=../zlib-1.2.8
make
make install
5.启动nginx
进入到nginx安装目录/usr/local/nginx下,执行
[root@jason1~]# cd /usr/local/nginx/
[root@jason1nginx]# ./nginx
[root@jason1nginx]# ps -ef|grep nginx
root 17577 1 0 22:47 ? 00:00:00 nginx: master process ./nginx
nobody 17578 17577 0 22:47 ? 00:00:00 nginx:worker process
root 17580 3591 0 22:48 pts/1 00:00:00 grep nginx
[root@jason1nginx]#
通过访问web页面查看,显示如下结果
![](http://s2.51cto.com/wyfs02/M01/76/2B/wKioL1ZMM7mQffLmAAGMT-9jRwk950.jpg)
Nginx安装部署成功。
6、Nginx常用管理命令行参数。
[root@jason1nginx]# ./nginx -h
nginxversion: nginx/1.4.7
Usage:nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: /usr/local/nginx/nginx.conf)
-g directives : set global directives out ofconfiguration file
stop — shut down quickly
quit — shut down gracefully
reload — reload configuration, start thenew worker process with a new configuration, gracefully shut down old workerprocesses.
reopen — reopen log files
Nginx启动
/usr/local/nginx/nginx
Nginx关闭
/usr/local/nginx/nginx -s stop
/usr/local/nginx/nginx -s quit
Nginx重新加载配置文件
/usr/local/nginx/nginx -s reload
Nginx测试配置文件语法是否正确
/usr/local/nginx/nginx -t -c /usr/local/nginx/nginx.conf
相关文章推荐
- 从源码安装Mysql/Percona 5.5
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- 在 AppImage、Flathub 和 Snapcraft 平台上搜索 Linux 应用
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- 快速部署远程同步服务Rsync
- 解决vc中unable to connect to the MKS:Internal error问题
- Nginx 学习笔记(一)
- [游戏资讯]《极品飞车16:亡命狂飙》配置需求公布
- 网站502与504错误分析
- 杰奇一些安装详细说明文件,比官方更细
- 路由器备份配置
- 无线网卡安装DIY