nginx动静分离

nginx代理http实现动静分离

简单来说,就是使用正则表达式匹配过滤,然后交个不同的服务器。
准备一个nginx代理 http 分别处理动态和静态。也可以让nginx代理自己解析静态网页,不过nginx又代理又解析网站感觉压力也挺大的。
安装软件包

yum -y install httpd mariadb-server php* php-mysql php-gd
[root@localhost ~]# ll /etc/my.cnf
-rw-r–r--. 1 root root 570 11月 15 2016 /etc/my.cnf
[root@localhost ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
启动mariadb服务
[root@localhost ~]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost ~]# ss -tnl 查看端口
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 *:3306 :
LISTEN 0 128 :22 :
LISTEN 0 128 :::22 :::

[root@localhost ~]# mysql_secure_installation 初始化数据库
全部回车
[root@localhost ~]# mysql -uroot -p123456789
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.52-MariaDB MariaDB Server

Copyright © 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

MariaDB [(none)]> \q

[root@localhost ~]# echo "<?php phpinfo(); ?> " > /var/www/html/info.php

[root@localhost ~]# cat /var/www/html/info.php

<?php phpinfo(); ?>

[root@localhost ~]# systemctl enable --now httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

[root@localhost ~]# sed -i ‘/^#S/s/#//’ /etc/httpd/conf/httpd.conf
[root@localhost ~]# grep ServerN /etc/httpd/conf/httpd.conf

ServerName gives the name and port that the server uses to identify itself.

ServerName www.example.com:80
打开浏览器查看php网页
192.168.168.10.110/info.php
crtl +f 搜索
[root@localhost ~]# yum -y localinstall ./*.rpm
[root@localhost ~]# rpm -q nginx
nginx-1.16.1-1.el7.ngx.x86_64
[root@localhost ~]# rpm -qc nginx
/etc/logrotate.d/nginx
/etc/nginx/conf.d/default.conf
/etc/nginx/fastcgi_params
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/mime.types
/etc/nginx/nginx.conf
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
/etc/nginx/win-utf
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug

[root@localhost ~]# vim /etc/nginx/nginx.conf

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值