php配置marialdb_CentOS7配置nginx php php-fpm mariadb(yum安装)

CentOS7配置nginx php php-fpm mariadb(yum安装)

一. 配置nginx

编辑default.conf文件

#vi /etc/nginx/conf.d/default.conf

添加index.php默认文件:

location / {

root /usr/share/nginx/html;

index index.php index.html index.htm;

}

添加php支持:

location ~ \.php${

root /usr/share/nginx/html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

设置自启动

#systemctl enable nginx

开启nginx

#systemctl start nginx

二. 配置php和php-fpm

1. 创建php的session目录及设置权限

#mkdir /var/lib/php/session

#chmod 777 /var/lib/php/session -R

2. 修改php-fpm的用户名

修改成为nginx这个用户名

#vi /etc/php-fpm.d/www.conf

user = nginx

group = nginx

设置自启动

#systemctl enable php-fpm

开启php-fpm

#systemctl start php-fpm

三. 配置mariadb

设置服务端编码

#vi /etc/my.cnf

添加到 [mysqld] 这个标志下面

[mysqld]

# 其他配置

character-set-server=utf8

开启mariadb

#systemctl start mariadb

修改root密码

#mysqladmin -u root password "密码"

设置自启动

#systemctl enable mariadb

安全设置

#mysql_secure_installation

四. 设置防火墙

添加http服务的规则

#firewall-cmd --permanent --add-service=http

#firewall-cmd --reload

五. 测试php解析

把下面内容保存为index.php,放到/usr/share/nginx/html目录。

php

phpinfo();

?>

打开浏览器,输入http://nginx的IP , 看看是否正常。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值