在CentOS7上通过RPM安装实现LAMP+phpMyAdmin安装过程全记录

在CentOS7上通过RPM安装实现LAMP+phpMyAdmin安装过程全记录

时间:2017年9月20日

一、软件环境:
IP:192.168.1.71
Hostname:centos73-2.surmount.net
Linux:CentOS Linux release 7.3.1611 (Core)
Apache:httpd-2.4.6
Mysql:Ver 15.1 Distrib 5.5.52-MariaDB
PHP:初始用ISO光盘yum源安装的版本为php-5.4.16。在后续安装phpMyAdmin-4.7.4时报错,然后按提示升级为php56w-5.6.31。

二、LAMP搭建:

2-1:配置本地ISO镜像yum源;

# mount -r /dev/cdrom /media/cdrom
# vim /etc/yum.repos.d/iso.repo
[iso]
name=iso
baseurl=file:///media/cdrom
gpgcheck=0
enable=0

# yum repolist

2-2:安装MariaDB、设置MariaDB的root用户密码;
# yum install mariadb-server -y
# systemctl start mariadb.service
# mysql
MariaDB [(none)]> SET PASSWORD FOR 'root' @'127.0.0.1'=PASSWORD('jingpei');
MariaDB [(none)]> SET PASSWORD FOR 'root' @'localhost'=PASSWORD('jingpei');
MariaDB [(none)]> FLUSH PRIVILEGES;
//设置MariaDB的root用户密码

2-3:安装及配置Apache;
# yum install httpd -y
# vim /etc/httpd/conf/httpd.conf
ServerName centos73-2.surmount.net:80
# httpd -t
Syntax OK
# systemctl start httpd.service
http://192.168.1.71
//测试html页面
OK

2-4:安装PHP、测试php与DB的连接;
# yum install php php-mysql -y
# vim /var/www/html/index.php
$link = mysql_connect('localhost', 'root', 'jingpei');
if (!$link)
{
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
phpinfo()
?>
http://192.168.1.71/index.php
//测试php页面,测试DB连接。
OK


三、安装phpMyAdmin:

3-1:phpMyAdmin简介;
phpMyAdmin,是MySQL或MariaDB数据库的GUI管理工具,以php为基础,以web为工作形式。

3-2:安装、配置及访问测试phpMyAdmin;
# unzip phpMyAdmin-4.7.4-all-languages.zip
# cp -a phpMyAdmin-4.7.4-all-languages /var/www/html
# cd /var/www/html
# ln -sv phpMyAdmin-4.7.4-all-languages pma
# cd /var/www/html/pma
# cp config.sample.inc.php config.inc.php
# tr -d 'a-zA-Z0-9' < /dev/urandom | head -30 | md5sum
8b2c0e4f280fb8cab9ff8b2716cf7a40 -
# vim config.inc.php
......
$cfg['blowfish_secret'] = '8b2c0e4f280fb8cab9ff8b2716cf7a40'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
......
# systemctl reload httpd.service
http://192.168.1.71/pma
status code:500

3-3:排错及测试;
# vim /etc/php.ini
......
display_errors
Default Value: On
......
error_reporting
Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
......
//根据状态码500(服务器内部错误),开启PHP报错。

# systemctl reload httpd.service
http://192.168.1.71/pma/
Parse error: syntax error, unexpected '@' in /var/www/html/phpMyAdmin-4.7.4-all-languages/libraries/common.inc.php on line 467
# yum install php-mbstring -y
# vim /var/www/html/pma/libraries/common.inc.php
467 if (@extension_loaded('mbstring') && !empty(@ini_get('mbstring.func_overload'))) {
468 PMA_fatalError(
469 __(
470 'You have enabled mbstring.func_overload in your PHP '
471 . 'configuration. This option is incompatible with phpMyAdmin '
472 . 'and might cause some data to be corrupted!'
473 )
474 );
475 }
//根据报错安装php-mbstring软件包;查看报错文件,暂时注释掉common.inc.php的467-475行(待php升级完成后再取消注释)。

# systemctl reload httpd.service
http://192.168.1.71/pma/
PHP 5.5+ is required.
Currently installed version is: 5.4.16
//提示php版本低

# yum list installed | grep php
php.x86_64 5.4.16-42.el7 @iso
php-cli.x86_64 5.4.16-42.el7 @iso
php-common.x86_64 5.4.16-42.el7 @iso
php-mbstring.x86_64 5.4.16-42.el7 @base
php-mysql.x86_64 5.4.16-42.el7 @iso
php-pdo.x86_64 5.4.16-42.el7 @iso
# yum remove php php-cli php-common php-mbstring php-mysql php-pdo -y
//删除低版本PHP

# wget -O /etc/yum.repos.d/CentOS-Base-Ali.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base-Ali.repo

# vim /etc/yum.repos.d/epel.repo
[epel]
name=epel
baseurl=https://mirrors.ustc.edu.cn/epel/7Server/x86_64/
enabled=0
gpgcheck=0

# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# yum install php56w -y
//配置网络yum源、epel源、webtatic源,升级PHP。

# systemctl reload httpd.service
http://192.168.1.71/pma/
//安装php56w-mbstring软件包,再测试提示缺少mysqli扩展。
# wget http://repo.webtatic.com/yum/el7/x86_64/RPMS/php56w-mbstring-5.6.31-1.w7.x86_64.rpm
# rpm -ivh php56w-mbstring-5.6.31-1.w7.x86_64.rpm
# systemctl reload httpd.service
http://192.168.1.71/pma/
//安装php56w-mysql,再测试正常。
# yum install php56w-mysql -y
# systemctl reload httpd.service
# httpd -M | grep php
php5_module (shared)
http://192.168.1.71/pma/
OK
完成安装,鼠标流操作不再敖述。

四、总结:
下载phpMyAdmin-4.7.4-all-languages.zip时未注意,此版本较新,需要php5.5以上方可支持。下载源码包时最好要看看官网的提示及软件包解压后的说明文档。

 

转载于:https://www.cnblogs.com/cured/p/7593583.html

你可能感兴趣的:(在CentOS7上通过RPM安装实现LAMP+phpMyAdmin安装过程全记录)