1.安装nginx
# wget http://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.8.1-1.el7.ngx.x86_64.rpm
# rpm -ivh nginx-1.8.1-1.el7.ngx.x86_64.rpm
2.安装PHP
# yum install php-fpm php-mysql -y
# systemctl enable php-fpm
# systemctl start php-fpm
3.在nginx主机上配置php
测试nginx
# mkdir -pv /www/web1
# systemctl enable nginx
# systemctl start nginx
# iptables -I INPUT -d 192.168.80.11 -p tcp --dport 80 -j ACCEPT
# iptables-save > /etc/sysconfig/iptables
# echo "iptables-restore < /etc/sysconfig/iptables" >>/etc/rc.local
配置php
location ~ \.php$ {
root /www/web1/php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/web1/php/$fastcgi_script_name;
include fastcgi_params;
}
测试php
<?php
phpinfo();
?>
4.搭建一个mysql
# yum install mariadb-server -y
# systemctl enable mariadb
# systemctl start mariadb
授权用户
grant all on test.* to [email protected]‘192.168.80.%‘ identified by ‘12345‘;
flush privileges;
测试mysql
<?php
$conn=mysql_connect(‘192.168.80.100‘,‘test‘,‘12345‘);
if ($conn)
echo "OK.....";
else
echo "Failure...";
?>