vim nginx.conf 编辑主配置文件
98,115s/#// #将98-115的#去掉
[root@localhost nginx]# cd conf
[root@localhost conf]# ls
fastcgi.conf koi-win scgi_params
fastcgi.conf.default mime.types scgi_params.default
fastcgi_params mime.types.default uwsgi_params
fastcgi_params.default nginx.conf uwsgi_params.default
koi-utf nginx.conf.default win-utf
[root@localhost conf]# vim nginx.conf
[root@localhost conf]# openssl genrsa > cert.key 私钥
Generating RSA private key, 2048 bit long modulus
…+++
…+++
e is 65537 (0x10001)
[root@localhost conf]# openssl req -new -x509 -key cert.key > cert.pem 公钥
You are about to be asked to enter information that will be incorporated
into your certificate request.
[root@localhost sbin]# /usr/local/nginx/sbin/nginx -s reload
重新加载
https://192.168.4.5
cp nginx.conf.default ngixn.conf
#####################################################
部署 lmnp 环境
安装数据库 mysql(mariadb)
[root@localhost ~]# yum -y install mariadb 客户端
[root@localhost ~]# yum -y install mariadb-server 服务端
[root@localhost ~]# yum -y install mariadb-devel 数据库依赖包
[root@localhost ~]# yum -y install php
[root@localhost ~]# yum -y install php-mysql
[root@localhost ~]# yum -y install php-fpm
[root@localhost sbin]# systemctl start mariadb 打开
[root@localhost sbin]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost sbin]# systemctl status mariadb
[root@localhost sbin]# systemctl php-fpm 打开
Unknown operation ‘php-fpm’.
[root@localhost sbin]# systemctl start php-fpm
[root@localhost sbin]# netstat -nutlp | grep php-fpm 查看是否被监听
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 3840/php-fpm: maste
|___________________________
[root@localhost /]# cd /usr/local/nginx/logs
[root@localhost logs]# ls
access.log error.log nginx.pid
[root@localhost logs]# tail -3 access.log
192.168.4.254 - - [12/Apr/2020:18:58:03 +0800] “GET /favicon.ico HTTP/1.1” 404 169 “-” “Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0”
[root@localhost lnmp_soft]# cd php_scripts
[root@localhost php_scripts]# cp test.php /usr/local/nginx/html 拷贝
vim ngixn.conf
将65-71 # 去掉
去掉69 改70 fastcgi_conf
fastcgi :公共网关接口 ,可以让网站服务与脚本解析沟通
______________________________________________________-
地址重写
[root@localhost sbin]# cd /usr/local/nginx/html
[root@localhost html]# echo aa > a.html
[root@localhost html]# echo bbb > b.html
[root@localhost html]# vim /usr/local/nginx/conf/nginx.conf
38 : rewrite a.html$ /b.html redirect ; (如果没有redirect,就不会显示a变成了b)
_____[root@localhost sbin]# ./nginx -s reload
rewrite /(.) http://www.tmooc.cn/$1 (.) 正则保留 $1粘贴效果