搭建基础环境:Centos7.2 ,下列内容为脚本内容。
#! /bin/bash
#
#基础工作
chkconfig iptables off
getenforce
mkdir /save
#下载atomic yum源
yum install wget
wget /save/http://www.atomicorp.com/installers/atomic
sh ./save/atomic
#安装开发包和库文件
yum check-update
#安装开发包和库文件
yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
#卸载已有软件
yum remove httpd mysql php php-fpm
#安装nginx
yum -y install nginx
chkconfig --levels 235 nginx on
mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
mv /etc/nginx/nginx.conf /save
cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
sed -i 45s'/index.html/index.php index.html/' /etc/nginx/nginx.conf
sed -i 65,71s/\#//g /etc/nginx/nginx.conf
sed -i 66s'@html@/usr/share/nginx/html@' /etc/nginx/nginx.conf
sed -i 69s'@scripts@usr/share/nginx/html@' /etc/nginx/nginx.conf
#安装mysql
wgethttp://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum -y install mysql mysql-community-server mysql-devel
chkconfig --levels 235 mysqld on
#>mysql set password = password('新密码');
#grant all privileges on *.* to root@"localhost" identified by "新密码"; 设置用户 root 可以在本地被访问:
#安装php
yum -y install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy php-common php-devel php-fpm
chkconfig --levels 235 php-fpm on
echo "cgi.fix_pathinfo = 1" >> /etc/php.ini
systemctl start nginx
systemctl start mysql
systemctl start php-fpm
以上为脚本内容。
创建测试文档
vi /usr/share/nginx/html/info.php
$conn=mysql_connect('host','user','password'); #用于测试是否能链接数据库
if($conn)
echo "Success...";
else
echo "Failur...";
phpinfo(); #用于测试nginx是否能调用php解释器
?>
验证:
访问http://localhost:80/info.php
网友评论