1. 程式人生 > >快速部署一個LNMP

快速部署一個LNMP

lnmp

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]%‘ identified by ‘12345‘;

flush privileges;


測試mysql

<?php

$conn=mysql_connect(‘192.168.80.100‘,‘test‘,‘12345‘);

if ($conn)

echo "OK.....";

else

echo "Failure...";

?>


本文出自 “愛吃貓的秋刀魚” 博客,請務必保留此出處http://yunstudy.blog.51cto.com/13190628/1958428

快速部署一個LNMP