Nginx学习笔记(1)--安装步骤
2018-02-27 14:12
393 查看
说明:本人是在虚拟机中安装centos7系统,安装Nginx 1.8版本的
安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc:
>yum install gcc-c++
(2)PCRE
PCRE(Perl Compatible Regular Expressions)gcc是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。
>yum install -y pcre pcre-devel
注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。
(3)zlib
zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。
>yum install -y zlib zlib-devel
(4)openssl
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。
>yum install -y openssl openssl-devel
>mkdir temp
>mkdir nginx
即为存在目录,/var/temp/nginx
或者用创建目录命令
>mkdir /var/temp/nginx -p
>cd nginx-1.8.0
参数设置如下:
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
conf,html,sbin
>./nginx
注意:执行./nginx启动nginx,这里可以-c指定加载的nginx配置文件,如下:
>./nginx -c /usr/local/nginx/conf/nginx.conf
如果不指定-c,nginx在启动时默认加载conf/nginx.conf文件,此文件的地址也可以在编译安装nginx时指定./configure的参数(--conf-path=指向配置文件(nginx.conf))
>cd /usr/local/nginx/sbin
>./nginx -s stop
此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
方式2,完整停止(推荐使用):
>cd /usr/local/nginx/sbin
>./nginx -s quit
此方式停止步骤是待nginx进程处理任务完毕进行停止。
浏览器中输入:localhost
或者在主机中输入虚拟机中的ip地址也可以
出现如下界面,则安装成功:
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
1.Nginx安装环境(如果装过,略过此步骤)
(1)gcc安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc:
>yum install gcc-c++
(2)PCRE
PCRE(Perl Compatible Regular Expressions)gcc是一个Perl库,包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式,所以需要在linux上安装pcre库。
>yum install -y pcre pcre-devel
注:pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。
(3)zlib
zlib库提供了很多种压缩和解压缩的方式,nginx使用zlib对http包的内容进行gzip,所以需要在linux上安装zlib库。
>yum install -y zlib zlib-devel
(4)openssl
OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议,并提供丰富的应用程序供测试或其它目的使用。
nginx不仅支持http协议,还支持https(即在ssl协议上传输http),所以需要在linux安装openssl库。
>yum install -y openssl openssl-devel
2.解压
将nginx-1.8.0.tar.gz拷贝至linux服务器。3.在var目录新建目录
>cd /var>mkdir temp
>mkdir nginx
即为存在目录,/var/temp/nginx
或者用创建目录命令
>mkdir /var/temp/nginx -p
4.configure配置参数
进入Nginx的解压目录>cd nginx-1.8.0
参数设置如下:
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
5.在nginx-1.8.0的目录下编译
>make6.安装
>make install7.安装的位置为/usr/local/nginx
进入该位置目录,有如下三个目录即安装成功:conf,html,sbin
8.启动Nginx
>cd /usr/local/nginx/sbin/>./nginx
9.查看Nginx进程
>ps aux|grep nginx注意:执行./nginx启动nginx,这里可以-c指定加载的nginx配置文件,如下:
>./nginx -c /usr/local/nginx/conf/nginx.conf
如果不指定-c,nginx在启动时默认加载conf/nginx.conf文件,此文件的地址也可以在编译安装nginx时指定./configure的参数(--conf-path=指向配置文件(nginx.conf))
10.停止nginx
方式1,快速停止:>cd /usr/local/nginx/sbin
>./nginx -s stop
此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
方式2,完整停止(推荐使用):
>cd /usr/local/nginx/sbin
>./nginx -s quit
此方式停止步骤是待nginx进程处理任务完毕进行停止。
11.测试
在虚拟机中输入浏览器中输入:localhost
或者在主机中输入虚拟机中的ip地址也可以
出现如下界面,则安装成功:
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
相关文章推荐
- oracle 12c GI安装详细步骤(oracle 12C + Grid Infrastructure(GI) + UDEV + ASM +centos6.4)
- sqlite3 的安装步骤:
- Scrapy安装步骤及错误汇总:scrapy OpenSSL error: command ‘gcc’ failed with exit status 1
- FEKO 6.0 电磁仿真软件在 Linux下安装以及破解详细步骤(附下载地址和注册程序)
- Ubuntu安装perl模块步骤
- VSTS 安装步骤
- MySQL安装步骤
- 只需6步骤,教你用ghost硬盘对拷实现系统安装
- centos编译安装LNMP详细步骤
- 阿里云CentOS安装ActiveMQ详细步骤
- arcgis_SDE安装步骤
- CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤
- linux下安装jdk的步骤和方法
- Linux系统指定目录下安装配置Mysql 5.7.15步骤图文详解,只需5分钟搞定
- Mysql 5.7 Linux安装详细步骤
- Linux下Memcached的安装步骤
- centos下安装mysql步骤
- MySQL 在Ubuntu14.04上的安装和基本使用(带步骤截图)
- REDHAT(RHEL6) 重新安装 Centos YUM 安装步骤以及 遇到的问题 总汇
- Hive的安装步骤