centos 编译nginx php mariadb,centos7安装nginx+mariadb+php-fpm

由 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

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.conflocation / {  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测试一下就可以了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值