首先要提前上传nginx安装包,要不就直接下载wget安装
#!/bin/bash
yum -y install gcc gcc-c++ pcre-devel zlib-devel > /dev/null
tar xzf nginx-1.12.2.tar.gz > /dev/null
cd nginx-1.12.2
./configure > /dev/null
make > /dev/null
make install > /dev/null
/usr/local/nginx/sbin/nginx
cd
yum -y install php php-fpm mysql mysql-server php-mysql > /dev/null
sed -i 's/index.html/ index.php &/' /usr/local/nginx/conf/nginx.conf
sed -i 's/.scripts$fastcgi_script_name/$document_root$fastcgi_script_name/' /usr/local/nginx/conf/nginx.conf
sed -i '65,71s/#//' /usr/local/nginx/conf/nginx.conf
service php-fpm restart
/usr/local/nginx/sbin/nginx -s reload
echo "
<?php
phpinfo();
?>
" > /usr/local/nginx/html/index.php