微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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修改权限的位置。

原文地址:https://www.jb51.cc/centos/376795.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。