您的位置:首页 > 数据库 > MariaDB

centos7安装nginx+mariadb+php-fpm(yum版)

2017-06-29 16:23 661 查看
由 dp7f1f9f 创建,最后一次修改 2017-05-22
用CentOS-7-x86_64-Minimal-1611.iso最小化安装一个centos7,安装选项:英文、时区为上海、启用网络(如果不在安装时设置,需要安装完成后修改/etc/sysconfig/network-scripts/ifcfg-enp12s0文件中的ONBOOT选项为yes)。安装完成后,先升级一下整个系统:
yum update
重启:

reboot
列出内核,如:
# rpm -qa|grep kernelkernel-3.10.0-514.10.2.el7.x86_64kernel-tools-libs-3.10.0-514.16.1.el7.x86_64kernel-3.10.0-514.16.1.el7.x86_64kernel-tools-3.10.0-514.16.1.el7.x86_64kernel-headers-3.10.0-514.16.1.el7.x86_64
删除旧内核:

yum remove kernel-3.10.0-514.10.2.el7.x86_64
安装一些基本工具(不建议安装net-tools来使用ifconfig命令,试试ip命令!):

yum install wget unzip unrar -y
做完以上工作后,下面是用yum安装nginx+mariadb+php-fpm的具体过程:

1、添加nginx官方源:
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm[/code]2、安装lnmp基本环境(如需要其他php组件,另行安装): 
yum install nginx php-fpm php-gd php-mysql mariadb-server -y
3、设置mariadb的root密码:

systemctl start mariadbmysqladmin -u root password "密码"
4、创建php的session目录及设置权限

mkdir /var/lib/php/sessionchmod 777 /var/lib/php/session -R
5、修改nginx配置添加php默认文件:

vi /etc/nginx/nginx.conf
location / {  root /usr/share/nginx/html;  index index.php index.html index.htm;}
修改以下代码,添加php支持:
# location ~ .php$ {#   root html;#   fastcgi_pass 127.0.0.1:9000;#   fastcgi_index index.php;#   fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;#   include fastcgi_params;# }
删除上面所有的#和蓝色字体部分。6、防火墙中打开http服务由于centos7默认使用的是firewalld防火墙,不再是iptables,许多人不习惯,把默认的卸载,重新安装了iptables,不建议这样做,firewalld功能更强大,使用也简单。防火墙中把http服务放行设置如下(配置文件:/etc/firewalld/zones/public.xml):
firewall-cmd --permanent --zone=public --add-service=httpfirewall-cmd --reload
7、启动lnmp环境及设置开机启动
systemctl start nginxsystemctl start php-fpmsystemctl enable nginxsystemctl enable php-fpmsystemctl enable mariadb
完成!写个phpinfo测试一下就可以了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux