Linux脚本一键执行nginx和php

一、nginx脚本

我的centos的版本是CentOS Linux release 8.0.1905 (Core)

注意:
此脚本仅供centos8.0 以上

  • 创建一个nginx.sh 脚本文件,在里面编写一下内容:
#!/bin/bash
dnf -y install http://nginx.org/packages/centos/8/x86_64/RPMS/nginx-1.18.0-1.el8.ngx.x86_64.rpm         #安装nginx
cd /etc/nginx/conf.d/
cp default.conf default.conf.bak
cd
sed -in '10d' /etc/nginx/conf.d/default.conf
sed -i '9a\\t index index.html index.htm index.php;' /etc/nginx/conf.d/default.conf
sed -in '30,36d' /etc/nginx/conf.d/default.conf
sed -i '29a\\t location ~ \.php$ {' /etc/nginx/conf.d/default.conf
sed -i '30a\\t root           html;' /etc/nginx/conf.d/default.conf
sed -i '31a\\t fastcgi_pass   unix:/run/php-fpm/www.sock;' /etc/nginx/conf.d/default.conf
sed -i '32a\\t fastcgi_index  index.php;' /etc/nginx/conf.d/default.conf
sed -i '33a\\t fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;' /etc/nginx/conf.d/default.conf
sed -i '34a\\t include        fastcgi_params;' /etc/nginx/conf.d/default.conf
sed -i '35a }' /etc/nginx/conf.d/default.conf
systemctl start nginx;systemctl enable nginx
dnf -y install @mysql
systemctl enable --now mysqld
systemctl status mysqld
echo "恭喜你nginx和数据库已经安装好了配置数据库请执行"
echo "mysql_secure_installation"
echo "执行完成运行php脚本"
  •  输入source 执行:
source nginx.sh

 二、php脚本

创建一个php.sh 脚本文件,在里面编写一下内容:

#!/bin/bash
dnf -y install epel-release
dnf update epel-release
dnf clean all
dnf makecache
dnf module enable php:7.3
dnf install php php-curl php-dom php-exif php-fileinfo php-fpm php-gd php-hash php-json php-mbstring php-mysqli php-openssl php-pcre php-xml libsodium
sed -in '24d' /etc/php-fpm.d/www.conf
sed -i '23a user = nginx' /etc/php-fpm.d/www.conf
sed -in '26d' /etc/php-fpm.d/www.conf
sed -i '25a group = nginx' /etc/php-fpm.d/www.conf
systemctl start php-fpm
systemctl enable php-fpm
echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php
echo "http://云服务器实例的公网 IP/index.php"
  •  输入source 执行:
source php.sh
http://云服务器实例的公网 IP/index.php 

版权声明:
作者:小李
链接:https://xianshengli.cc/linux%e8%84%9a%e6%9c%ac%e4%b8%80%e9%94%ae%e6%89%a7%e8%a1%8cnginx%e5%92%8cphp/
来源:先生不吃香菜
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
Linux脚本一键执行nginx和php
一、nginx脚本 我的centos的版本是CentOS Linux release 8.0.1905 (Core) 注意: 此脚本仅供centos8.0 以上 创建一个nginx.sh 脚本文件,在里面编写一下内容……
文章目录
关闭
目 录