CentOS 7+Apache 2.4+PHP 7.3+MariaDB 10.4安装记录

安装Apache
使用CentOS官方源
yum install httpd
这个安装包就是2.4的最新版本,所以不需要在官网下载源码自己编译
安装MariaDB
1.MariaDB官网
https://downloads.mariadb.org/
官网上面给出的提示:
Use CentOS, Fedora, Red Hat, Debian, Ubuntu, openSUSE, or Mageia? See our repository configuration tool.
2.根据选项找到centos7应该下载的
https://downloads.mariadb.org/mariadb/repositories/#mirror=tuna&distro=CentOS&distro_release=centos7-amd64--centos7&version=10.4
官方给出的安装方式:
把下面的配置成yum repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
运行
sudo yum install MariaDB-server MariaDB-client
我发现还有一些需要安装的
MariaDB-devel和MariaDB-shared
安装PHP
1.下载PHP
PHP官网https://www.php.net/downloads
找到下载
wget ‘https://www.php.net/distributions/php-7.3.7.tar.gz’
因为下载的是源码包,解压缩到/usr/local/src下,

2.安装PHP
官方的安装文档https://www.php.net/manual/zh/install.unix.apache2.php
官方给出的编译参数是:
cd …/php-NN
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
make
make install

3.编译有问题
通过官方的另一个文档:
Overview of the MySQL PHP drivers
https://www.php.net/manual/zh/mysql.php
得知php7版本不可以使用msyql extension,只能使用mysqli和pdo_mysql

3.查找正确的mysql编译参数
找到mysqli的安装文档:
https://www.php.net/manual/zh/mysqli.installation.php
官方给出的编译参数是:
./configure --with-mysql=/usr/bin/mysql_config
–with-mysqli=mysqlnd
–with-pdo-mysql=mysqlnd

4.总结出编译参数
自己结合一下,总结出来的编译参数是:
./configure --with-apxs2=/usr/bin/apxs --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
不需要设置prefix,因为默认的路径已经被设置了环境变量,所以更加方便,网上的一些设置prefix的其实更加麻烦,而且违背了linux的一些理论
编译
make
安装
make install

5.通过phpinfo查看到gd库没有启用
可以重新编译安装或者使用phpize,这里我使用重新编译php的方式,因为之前操作的时候有些问题 索性就直接全部重新编译了
通过./configure –help | grep -i gd 看到gd的安装方式
结合gd的官方文档https://www.php.net/manual/zh/image.installation.php
然后总结出编译参数:
./configure --with-apxs2=/usr/bin/apxs --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-zlib-dir

6.通过phpinfo查看gd库启用了,但是jpeg没有
找到libjpeg官网
http://www.ijg.org/
下载http://www.ijg.org/files/jpegsrc.v9c.tar.gz
通过安装文档找到编译参数
我把它安装到了/usr/local/jpeg,指定了路径,因为这个没有命令 并且是php来使用它的库,所以全部安装在同一个文件夹更好
编译,安装

7.再次编译PHP
./configure --with-apxs2=/usr/bin/apxs --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gd --with-jpeg-dir=/usr/local/jpeg/ --with-png-dir --with-freetype-dir --with-zlib-dir
Make
Makeinstall
看到PHP已经安装成功,phpinfo正常显示
另外,重新编译前,一定要make clean,不然安装的内容是先前编译的so等文件;这个小问题耽误了我几个小时的时间

8.mysql连接不正常
在wp当中连不上mysql
在php.ini里面启用extension,还是不行
在phpinfo里面通过和能正常连接mysql的phpinfo对比发现:
Mysql.sock的路径设置的不正确
百度搜索查找到: 不能通过’/tmp/mysql.sock’连到服务器,而php标准配置正是用过’/tmp/mysql.sock’,但是一些mysql安装方法将mysql.sock放在/var/lib/mysql.sock或者其他的什么地方,你可以通过修改/etc/my.cnf文件来修正它
因为我的mysql是正常全自动安装配置的,我觉得不需要修改它,有问题的是PHP,所以我选择修改php.ini:
pdo_mysql.default_socket=/var/lib/mysql.sock
mysql.default_socket=/var/lib/mysql.sock
mysqli.default_socket=/var/lib/mysql.sock

重启启动httpd, Exceptionally ordinary!

2019年7月16日

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值