nginx-0基础安装篇

 

 

Nginx安装手册

一:获取nginx安装包

1.1,下载nginx安装包:

可以在nginx官网自行下载安装nginx所需的安装包

1.2,也可以通过我提供的分享链接进行下载,链接如下:

https://pan.baidu.com/s/1gDVZun7vDxI8Ep1oRu2SgA

二:安装nginx

       2,1,将下载好的软件包上传到系统

              我们这边是使用xshell工具进行远程连接centos7的服务器,使用其自带的xsftp把文件传上去,打开方式如 图(1)所示,上传步骤如 图(2)所示。

                  图(1)

 

                  图(2)

2,2、安装nginx所需要的依赖包

       进入系统,安装nginx所需要的依赖包文件命令如图(3)所示,我们这里使用yum安装即可,

 

                图(3)

 

      附上可复制的具体命令:

yum -y install openssl openssl-devel pcre pcre-devel gcc-c++ autoconf automake zlib-devel libxml2 libxml2-dev libxslt-devel gd-devel perl-devel perl-ExtUtils-Embed GeoIP GeoIP-devel GeoIP-data

依赖安装完成之后会出现Complete! 如图(4) 所示:

                图(4)

2.3、安装nginx

       创建nginx所使用的用户:

[root@localhost ~]# useradd nginx
[root@localhost ~]# id nginx
uid=1000(nginx) gid=1000(nginx) groups=1000(nginx)

  进入系统使用 ls 命令查看文件包是否存在,在使用tar 命令将nginx文件包进行解压,解压完成之后进入 nginx-1.8.1 这个目录,通过 ls 命令查看一下存在一个configure (绿色文件)的可执行文件 图(5),使用这个文件进行初始化,configure后面需要指定一些初始化的参数,初始化完成之后会出现 图(6)的样子,在使用命令 make && make install 进行编译安装,编译成功之后如 图(7) 所示,以上具体操作请参考如下步骤详细:

[root@localhost ~]# ls
anaconda-ks.cfg  nginx-1.8.1.tar.gz
[root@localhost ~]# tar -xf nginx-1.8.1.tar.gz 
[root@localhost ~]# ls
anaconda-ks.cfg  nginx-1.8.1  nginx-1.8.1.tar.gz
[root@localhost ~]# cd nginx-1.8.1
[root@localhost nginx-1.8.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src
[root@localhost nginx-1.8.1]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx \
--error-log-path=/var/log/nginx_error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--sbin-path=/usr/sbin/nginx \
--with-rtsig_module \
--with-select_module \
--with-poll_module \
--with-file-aio \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_image_filter_module \
--with-http_geoip_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-cpp_test_module [root@localhost nginx-1.8.1]# make && make install

                  图(5)

                图(6)

                  图(7)

注意: nginx的安装目录在初始化中使用参数 --prefix=/usr/local/nginx 指定了,以后的配置将在/usr/local/nginx 目录中

[root@localhost nginx-1.8.1]# cd /usr/local/nginx/
[root@localhost nginx]# ls
conf  html
[root@localhost nginx]# 

三:启动

启动nginx

/usr/local/nginx/sbin/nginx

停止nginx

/usr/local/nginx/sbin/nginx -s stop

重启nginx

/usr/local/nginx/sbin/nginx -s reload

 

posted @ 2018-12-12 14:43  格桑梅朵儿  阅读(219)  评论(0编辑  收藏  举报