nginx服務部署
nginx服務概念地址:
首先,新建虛擬機,我們默認是使用CentOS-7-x86_64-DVD-1511的鏡像
鏡像地址:
鏈接:https://pan.baidu.com/s/1Myl_GXnUg7t3OR01mCuMrQ
提取碼:1511
①安裝虛擬機,配置ip,yum源
安裝虛擬機,配置ip,配置yum源地址教程
②修改主機名(主從資料庫同理)
這里我們設定主機名為nginx
[root@localhost /]# hostnamectl set-hostname nginx (修改主機名)
[root@localhost /]# bash (重繪shell命令列)
[root@mysql0 /]# su - (重新登錄)
[root@mysql0 ~]# hostnamectl (查看主機資訊)

③關閉防火墻和SELinux服務
防火墻和SELinux開啟關閉教程
[root@nginx ~]# setenforce 0 (設定關閉 1開啟0關閉)
[root@nginx ~]# systemctl stop firewalld (關閉防火墻)
[root@nginx ~]# getenforce (查看行程 Enforcing開啟Permissive關閉)
Permissive
④安裝配置基礎服務
[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 (查看資訊)

⑤安裝配置nginx服務
事先用檔案傳輸工具(博主用的是xftp)將nginx安裝包放到/usr/local/src目錄下
nginx安裝包鏈接(這里我們用的版本為nginx-1.12.2):
鏈接:https://pan.baidu.com/s/1GcIyTUdvjiohFIKvQQ2UrQ
提取碼:1122
[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 (查看)

[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

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/166970.html
標籤:其他
