centos6.9 yum安装lnmp(shell脚本)
Posted wangyong-blog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos6.9 yum安装lnmp(shell脚本)相关的知识,希望对你有一定的参考价值。
#!/bin/bash
echo "...................CentOS release 6.9 (Final)...................."
echo "############################# nginx ################################ "
service iptables stop
yum install nginx -y
chkconfig nginx on
service nginx start &&
echo "*****************Nginx installed successfully*************************"
echo "############################# mysql ################################ "
yum install mysql mysql-server mysql-devel -y
service mysqld start
chkconfig --levels 235 mysqld on
mysqladmin -u root password "123456"
service mysqld restart
echo "*****************mysql installed successfully*************************"
echo "############################# php ################################ "
yum install php php-fpm -y
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt -y
chkconfig php-fpm on
cat > /etc/nginx/conf.d/default.conf<<EOF
#
# The default server
#
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
# root /usr/share/nginx/html;
root /var/www/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ .php$ {
root /var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
}
EOF
sed -i "s#user = apache#user = nginx#g" /etc/php-fpm.d/www.conf
sed -i "s#group = apache#group = nginx#g" /etc/php-fpm.d/www.conf
chown nginx.nginx /var/www/ -R
chmod 700 /var/www/html -R
service nginx restart &&
service php-fpm restart &&
service php-fpm restart &&
cd /var/www &&
cat >/var/www/b.php<<EOF
<?php
phpinfo();
// 将会打印出所有的PHP信息
?>
EOF
cd /var/www/html &&
cat > /var/www/html/a.html<<EOF
<h1>Hello World</h1>
EOF
echo "*****************PHP installed successfully*************************"
echo "测试php是否安装成功:IP/b.php"
echo "测试站点目录下网页:IP/a.html"
以上是关于centos6.9 yum安装lnmp(shell脚本)的主要内容,如果未能解决你的问题,请参考以下文章