在Linux下安装Nginx软件

构建Nginx服务器

下载资源>>>>【https://download.csdn.net/download/zhydream77/10391803】


[root@proxy ~]# yum -y install gcc pcre-devel openssl-devel ----------安装软件
[root@proxy ~]# useradd -s /sbin/nologin nginx                    ----------创建用户
[root@proxy ~]# tar -xf lnmp_soft.tar.gz                                ----------解压包
[root@proxy ~]# ls                                                                  ----------查看列表信息
[root@proxy ~]# cd lnmp_soft/                                              -----------跳转到加压后的文件夹中
[root@proxy lnmp_soft]# ls                                                     ----------查看列表信息
[root@proxy lnmp_soft]# tar -xf nginx-1.10.3.tar.gz                 ----------加压nginx的10版本到当前目录
[root@proxy lnmp_soft]# cd nginx-1.10.3/                              ------------跳转到加压后的10版本目录下

[root@proxy nginx-1.10.3]# ./configure \                                 ----------- ./configure是源代码安装的第一步

                                                                                                         ,主要的作用   是对即将安装的软件进行配置,

                                                                                                               检查当前的环境是否满足要安装软件的依赖关系

 >> --prefix=/usr/local/nginx \                                                ------------指定安装目录                                          
> > --user=nginx \                                                                   ------------指定账户名称
> > --group=nginx \                                                                 ------------指定组名词

> > --with-http_ssl_module                                                      -------------支持加密功能

> > --with-stream                                                                     -----------支持TCP/UDP代理 

[root@proxy nginx-1.10.3]# make && make install                      ----------编译以及安装软件





nginx命令用法解析


[root@proxy nginx-1.10.3]# /usr/local/nginx/sbin/nginx                   -------------启动Nginx服务

[root@proxy nginx-1.10.3]# /usr/local/nginx/sbin/nginx -s stop          ------------关闭服务

[root@proxy nginx-1.10.3]# /usr/local/nginx/sbin/nginx -s reload ----------重新加载配置文件 ,必须在nginx开启的前提下使用

[root@proxy nginx-1.10.3]# /usr/local/nginx/sbin/nginx -V                   ---------查看软件信息

[root@proxy nginx-1.10.3]# ln -s /usr/local/nginx/sbin/nginx /sbin/         -----------方便后期使用

nginx服务器默认通过TCP端口监听客户端请求:

[root@proxy nginx-1.10.3]# netstat -anptu | grep nginx                    --------------查看服务相关进程及端口信息

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      4475/nginx: master


测试首页文件的地址

在测试前需要设置防火墙与SELinux


[root@proxy ~]#firewall-cmd --set-default-zone=trusted

[root@proxy ~]#setenforce 0


Nginx Web服务默认首页存储目录为/usr/local/nginx/html/,在此目录下默认有一个名为index.html的文件,使用客户端访问


测试页面:

Welcome to nginx!

If you see this page, the nginx web server is successfully installed andworking. Further configuration is required.

For online documentation and support please refer tonginx.org.
Commercial support is available atnginx.com.

Thank you for using nginx.










猜你喜欢

转载自blog.csdn.net/zhydream77/article/details/80193733