Rocky 8.9 安装LAMP





安装方法1:
yum install httpd -y




安装mysql 和 php
yum -y install mariadb-server php php-mysqlnd

启动mariadb
systemctl enable --now mariadb


进入mysql
直接输入mysql 回车,默认没有密码

mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory


该问题由于系统中未安装对应5版本库件导致



没有对应的libncurses.so.5文件,这个时候可以将高版本创建软连接到5版本



ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5

再次运行:mysql


还需要一个libtinfo.so.5文件

同样的方法,有一个高版本的链接过来

find / -name "libtinfo.so.*"
ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5




再次运行mysql 命令,看是否能登录mysql



ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

查找 mysql.sock 的具体位置



ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

再次运行mysql





###### 添加 php 信息文件,检测php是否安装成功

cd /var/www/html/
vi index.php

<?php
 phpinfo();
?>


保存退出。
重启httpd

systemctl restart httpd

打开浏览器输入


phpinfo是php自带的函数,显示的是php服务器的配置信息