“Nginx服务及部署”的版本间的差异

来自CloudWiki
跳转至: 导航搜索
第63行: 第63行:
  
 
④安装配置基础服务
 
④安装配置基础服务
 +
 +
 +
[[文件:nginx2.png]]
 +
 +
 +
  
  
第91行: 第97行:
  
 
⑤安装配置nginx服务
 
⑤安装配置nginx服务
 +
 
事先用文件传输工具(博主用的是xftp)将nginx安装包放到/usr/local/src目录下
 
事先用文件传输工具(博主用的是xftp)将nginx安装包放到/usr/local/src目录下
 +
 
nginx安装包链接(这里我们用的版本为nginx-1.12.2):
 
nginx安装包链接(这里我们用的版本为nginx-1.12.2):
 +
 
链接:https://pan.baidu.com/s/1GcIyTUdvjiohFIKvQQ2UrQ
 
链接:https://pan.baidu.com/s/1GcIyTUdvjiohFIKvQQ2UrQ
 +
 
提取码:1122
 
提取码:1122
[root@nginx ~]# cd /usr/local/src     
+
 
 +
[[文件:nginx3.png]]
 +
 
 +
 
 +
 
 +
 
 +
[root@nginx ~]# cd /usr/local/src  
 +
    
 
[root@nginx src]# ls
 
[root@nginx src]# ls
 +
 
nginx-1.12.2.tar.gz
 
nginx-1.12.2.tar.gz
 +
 
[root@nginx src]# tar -zxvf nginx-1.12.2.tar.gz (解压安装包)
 
[root@nginx src]# tar -zxvf nginx-1.12.2.tar.gz (解压安装包)
 +
 
[root@nginx src]# cd nginx-1.12.2/
 
[root@nginx src]# cd nginx-1.12.2/
 +
 
运行这个超长命令
 
运行这个超长命令
 +
 
[root@nginx nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --with-http_dav_module \
 
[root@nginx nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --with-http_dav_module \
 +
 
> --with-http_stub_status_module --with-http_addition_module \
 
> --with-http_stub_status_module --with-http_addition_module \
 +
 
> --with-http_sub_module --with-http_flv_module --with-http_mp4_module \
 
> --with-http_sub_module --with-http_flv_module --with-http_mp4_module \
 +
 
> --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx
 
> --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx
 +
 
(此处省略运行信息,如果没有报错,可进行编译安装)
 
(此处省略运行信息,如果没有报错,可进行编译安装)
 +
 
[root@nginx src]# make && make install  (编译安装)
 
[root@nginx src]# make && make install  (编译安装)
 +
 
[root@nginx src]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/  (创建软连接)
 
[root@nginx src]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/  (创建软连接)
 +
 
[root@nginx src]# nginx -t (查看)
 
[root@nginx src]# nginx -t (查看)
 +
 
1
 
1
 +
 
2
 
2
 +
 
3
 
3
 +
 
4
 
4
 +
 
5
 
5
 +
 
6
 
6
 +
 
7
 
7
 +
 
8
 
8
 +
 
9
 
9
 +
 
10
 
10
 +
 
11
 
11
 +
 
12
 
12
 +
 
13
 
13
 +
 
14
 
14
 +
  
 
[root@nginx nginx-1.12.2]# yum -y install net-tools  (安装该工具)
 
[root@nginx nginx-1.12.2]# yum -y install net-tools  (安装该工具)
第152行: 第196行:
 
9
 
9
 
10
 
10
 +
 +
 +
 +
[[文件:nginx4.png]]

2020年10月12日 (一) 03:03的版本

  1. nginx服务部署


    1. nginx服务概念地址:


首先,新建虚拟机,我们默认是使用CentOS-7-x86_64-DVD-1511的镜像

镜像地址:

链接:https://pan.baidu.com/s/1Myl_GXnUg7t3OR01mCuMrQ

提取码:1511


    1. ①安装虚拟机,配置ip,yum源


安装虚拟机,配置ip,配置yum源地址教程


②修改主机名(主从数据库同理)


这里我们设置主机名为nginx


[root@localhost /]# hostnamectl set-hostname nginx (修改主机名)


[root@localhost /]# bash (刷新shell命令行)


[root@mysql0 /]# su - (重新登录)


[root@mysql0 ~]# hostnamectl (查看主机信息)


Nginx1.png



③关闭防火墙和SELinux服务


防火墙和SELinux开启关闭教程


[root@nginx ~]# setenforce 0 (设置关闭 1开启0关闭)


[root@nginx ~]# systemctl stop firewalld (关闭防火墙)


[root@nginx ~]# getenforce (查看进程 Enforcing开启Permissive关闭)


Permissive


④安装配置基础服务


Nginx2.png



`[root@nginx src]# yum install gcc gcc-c++ openssl-devel zlib-devel zlib pcre-devel -y`


(安装编译器)


[root@nginx src]# groupadd -g 1001 nginx


(创建指定所属组)


[root@nginx src]# useradd -u 900 nginx -g nginx -s /sbin/nologin


(创建指定用户组) [root@nginx src]# tail -l /etc/passwd (查看信息) 1 2 3 4 5 6 7

⑤安装配置nginx服务

事先用文件传输工具(博主用的是xftp)将nginx安装包放到/usr/local/src目录下

nginx安装包链接(这里我们用的版本为nginx-1.12.2):

链接:https://pan.baidu.com/s/1GcIyTUdvjiohFIKvQQ2UrQ

提取码:1122

Nginx3.png



[root@nginx ~]# cd /usr/local/src

[root@nginx src]# ls

nginx-1.12.2.tar.gz

[root@nginx src]# tar -zxvf nginx-1.12.2.tar.gz (解压安装包)

[root@nginx src]# cd nginx-1.12.2/

运行这个超长命令

[root@nginx nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --with-http_dav_module \

> --with-http_stub_status_module --with-http_addition_module \

> --with-http_sub_module --with-http_flv_module --with-http_mp4_module \

> --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx

(此处省略运行信息,如果没有报错,可进行编译安装)

[root@nginx src]# make && make install (编译安装)

[root@nginx src]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/ (创建软连接)

[root@nginx src]# nginx -t (查看)

1

2

3

4

5

6

7

8

9

10

11

12

13

14


[root@nginx nginx-1.12.2]# yum -y install net-tools (安装该工具)


[root@nginx src]# nginx


[root@nginx src]# netstat -ntpl (查看端口信息,有80端口,浏览器链接本虚拟机ip ,出现欢迎界面说明成功)


Active Internet connections (only servers)


Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5171/nginx: master tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1096/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2236/master tcp6 0 0 :::22  :::* LISTEN 1096/sshd tcp6 0 0 ::1:25  :::* LISTEN 2236/master 1 2 3 4 5 6 7 8 9 10


Nginx4.png