Centos 7.3 + PHP7.1.7 + Mariadb

编译安装 PHP 7.1.7

http://www.cnblogs.com/huliujun/p/7131184.html


安装 MariaDB

yum install mariadb-server mariadb-client


添加 mysql 连接登录用户

https://mariadb.com/kb/zh-cn/configuring-mariadb-for-remote-client-access/

GRANT ALL PRIVILEGES ON *.* TO 'mos'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

注:这是 root 权限


连接可能发生的错误

(1) DB 连接

mysqli 连接数据库,有两种方式,如果指定 127.0.0.1 使用 TCP/IP,如果使用 localhost,使用 socket 连接。

如果使用 localhost 作为服务器名,以 socket 方式连接时,要确认 php.ini 文件中的 mysqli_default_socket 设置要与 /etc/my.conf 中的 socket 设置保持一致,否则会报错:

Warning: mysqli::__construct(): (HY000/2002): No such file or directory in ...


注:mysql 采用unix socket连接方式,比用tcp的方式更快,但只适用于mysql和应用同在一台PC上。(参考以下来源于 mysql 文档)

https://dev.mysql.com/doc/refman/5.5/en/can-not-connect-to-server.html

A MySQL client on Unix can connect to the mysqld server in two different ways: By using a Unix socket file to connect through a file in the file system (default /tmp/mysql.sock), or by using TCP/IP, which connects through a port number. A Unix socket file connection is faster than TCP/IP, but can be used only when connecting to a server on the same computer. A Unix socket file is used if you do not specify a host name or if you specify the special host name localhost.


(2) Session 目录

Warning: session_start() [function.session-start]: open(/tmp/sess_...

编译安装后,PHP 默认的 Session 保存目录是根目录 /,需要修改 /etc/php.ini 文件,设置 session.save_path,指向到 php-fpm 运行用户 nginx 有修改权限的位置。


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值