NGINX

在虚拟控制台把vm1Memory改为2048,启动vm1

(1)安装 编译 软链接

  77  cd /  ###切换到文件包所在目录

  78  ls

  79  tar zxf nginx-1.12.0.tar.gz  ###解压

  80  ls

  81  cd  nginx-1.12.0   ###切换到解压后文件包的目录下

  82  ls

  84  pwd   ###查看文件所在路径

  85  useradd -M -d/usr/local/lnmp/nginx  -s/sbin/nologin  -u 800 nginx          ##添加nginx用户

  86  id nginx   

  87  ls

  88  cd src

  89  ls

  90  cd core

  91  ls

  92  vim nginx.h  图

  93  pwd

  94  cd ..  

   95  ls

  96  cd auto/

  97  ls

  98  cd cc/

  99  ls

 100  vim gcc  图

 101  cd --

 102  cd /nginx-1.12.0

 103  ls

 104  ./configure--prefix=/usr/local/lnmp/nginx --user=nginx --group=nginx --with-threads --with-file-aio--with-http_ssl_module --with-http_stub_status_module

 105  yum install gcc pcre-developenssl-devel -y

 106  ./configure--prefix=/usr/local/lnmp/nginx --user=nginx --group=nginx --with-threads --with-file-aio--with-http_ssl_module --with-http_stub_status_module

 107  make && make install

 108  cd /usr/local/lnmp/nginx/

 109  ls

 110  du -sh

 111  cd sbin

 112  ./nginx

 113  ls

 115  pwd

 116  ln -s/usr/local/lnmp/nginx/sbin/nginx /sbin/

 117  ls

 118  which nginx

 121 curl localhost -I

 

 

wKioL1lyIHDy7ixEAABj2J9ZRjc842.png-wh_50

wKiom1lyIHHwDXeeAACqas5JATs738.png-wh_50

wKioL1lyIM3QMCraAAC1pxV0beE843.png-wh_50wKiom1lyIQbTZBJRAACZvgqTgBU506.png-wh_50

gcc文件

wKioL1lyIQaSROwtAABQcpRWxjk291.png-wh_50wKiom1lyIQXRYFs2AABTPCHDy8s695.png-wh_50

wKiom1lyIyLwJA1NAAC6CQj4WyA472.png-wh_50


(2) 文件打开数

 146  cd /usr/local/lnmp/

 147  ls

 148  cd nginx/

 150  ls

 151  cd conf

 152  ls

 153  vim nginx.conf       

      worker_processes  2;

      worker_cpu_affinity 01 10;

 154  nginx -t     ####检测有没有语法错误

 155  nginx -s reload  ###更新配置

 158 vim /etc/security/limits.conf

 160  usermod -s /bin/bash   nginx

  161  su - nginx

 wKiom1lyIyWS7yyqAAHO_iNhR_Y620.png-wh_50

 wKiom1lyIyji8ibuAAG689U-4WA105.png-wh_50

 wKioL1lyIyODj-lmAAB6BotvM-o763.png-wh_50

2个CPU,开启2个进程

worker_processes     2;
worker_cpu_affinity 01 10;

01表示启用第一个CPU内核,10表示启用第二个CPU内核
worker_cpu_affinity 01 10;表示开启两个进程,第一个进程对应着第一个CPU内核,第二个进程对应着第二个CPU内核


  wKioL1lyIyaTarFyAABk47oJ1kU216.png-wh_50




(3) 共享文件

 166  vim nginx.conf

 167  nginx -t

 168  vim nginx.conf

wKiom1lyJfPDIGscAABLobde0lQ301.png-wh_50

 169  nginx -t

 170  nginx -s reload

 171  mkdir /web1

 172  cd /web

 173  cd /web1

 174  vim index.html


 wKioL1lyJhGA8F2LAAF0CrVONjI983.png-wh_50

 

测试结截图:真机

wKiom1lyJg_iMGJ8AAAq5r70Gd4692.png-wh_50




 175  cd /usr/local/lnmp/

 176  ls

 177  cd nginx/

 178  ls

 179  cd conf

 180  ls

 182  vim nginx.conf

 183  cd /etc/pki/tls/certs

 184  ls

 186  make cert.pem

 187  ll cert.pem

 188  mv cert.pem   /usr/local/lnmp/nginx/conf/

 189  cd  /usr/local/lnmp/nginx/conf/

 190  ls

 191  nginx -t

 192  nginx -s reload

 193  netstat -antlp

 

 配置文件:

 48       location /status{

 49             stub_status on;

 50              access_log off;

 51             allow 172.25.21.250;

 52             deny all

 

 

109        server_name  www.westos.org;

121             root   web1;

129        rewrite ^(.*)$ https://www.westos.org permanent


wKiom1lyJhLjm4gFAAIsoABSPaQ856.png-wh_50

 wKioL1lyJhTDzV1cAAH01BIWWjU408.png-wh_50

wKiom1lyKMfz87A4AAGg6eCRFa8282.png-wh_50

测试:物理机,即真机


wKioL1lyKMKS7HQVAADDGQE-skc888.png-wh_50

wKiom1lyKMWyA7OjAADgikwAg5Y522.png-wh_50

wKioL1lyKMOQqB64AACRIZw8CN8214.png-wh_50