由dp7f1f9f创建,最后一次修改-05-22
用CentOS-7-x86_64-Minimal-1611.iso最小化安装一个centos7,安装选项:英文、时区为上海、启用网络(如果不在安装时设置,需要安装完成后修改/etc/sysconfig/network-scripts/ifcfg-enp12s0文件中的ONBOOT选项为yes)。安装完成后,先升级一下整个系统:yumupdate
重启:
reboot
列出内核,如:
#rpm-qa|grepkernelkernel-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
删除旧内核:
yumremovekernel-3.10.0-514.10.2.el7.x86_64
安装一些基本工具(不建议安装net-tools来使用ifconfig命令,试试ip命令!):
yuminstallwgetunzipunrar-y
做完以上工作后,下面是用yum安装nginx+mariadb+php-fpm的具体过程:
1、添加nginx官方源:rpm-Uvh/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
2、安装lnmp基本环境(如需要其他php组件,另行安装):
yuminstallnginxphp-fpmphp-gdphp-mysqlmariadb-server-y
3、设置mariadb的root密码:
systemctlstartmariadbmysqladmin-urootpassword"密码"
4、创建php的session目录及设置权限
mkdir/var/lib/php/sessionchmod777/var/lib/php/session-R
5、修改nginx配置添加php默认文件:
vi/etc/nginx/nginx.conflocation/{root/usr/share/nginx/html;indexindex.phpindex.htmlindex.htm;}
修改以下代码,添加php支持:#location~.php${#roothtml;#fastcgi_pass127.0.0.1:9000;#fastcgi_indexindex.php;#fastcgi_paramSCRIPT_FILENAME/usr/share/nginx/html$fastcgi_script_name;#includefastcgi_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环境及设置开机启动systemctlstartnginxsystemctlstartphp-fpmsystemctlenablenginxsystemctlenablephp-fpmsystemctlenablemariadb
完成!写个phpinfo测试一下就可以了。
如果觉得《centos 编译nginx php mariadb centos7安装nginx+mariadb+php-fpm》对你有帮助,请点赞、收藏,并留下你的观点哦!