Centos7.9 配置 LAMP 环境#
这几天搞服务器搞坏了,重装了好几次系统,这里记录一下配置 LAMP 环境的过程。
首先更新一下 yum,先运行yum versionlock status
查看是否有版本锁,若有的话则运行yum versionlock clear
进行清除,然后运行yum -y update
进行更新。
安装 Apache#
方法很简单,也不用更新 yum 源,先执行yum install httpd
查看能否直接安装,如果显示no package found for httpd
的话用yum --disableexcludes=all install httpd
进行安装,否则直接安装就可以。安装完后用systemctl start httpd
运行 httpd。如果有安全组或者防火墙的话要打开 80 端口的通行许可,打开后可以在浏览器中输入你的 ip,如果显示以下界面即为安装成功。
安装 MySQL#
用命令直接安装即可
执行wget https://dev.mysql.com/get/mysql80-community-release-el7-6.noarch.rpm
下载 rpm 包,然后执行
yum -y install mysql80-community-release-el7-6.noarch.rpm
yum -y install mysql-community-server --nogpgcheck
进行安装
有可能出现的错误
- 出现 Package: mysql-community-server-5.7.38-1.el7.x86_64 (mysql57-community) Requires: mysql-community-common (x86-64) = 5.7.38-1.el7
- 出现 Public key for mysql-community-server-5.7.37-1.el7.x86_64.rpm is not installed
安装 PHP#
因为我要用 typecho,所以 yum 内的 php 版本太低,要更新一下 rpm。
两个命令:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
运行完后就可以直接通过yum install -y php72w php72w-cli php72w-common php72w-devel php72w-mysql
来安装了,72 是版本号,可以根据需求自行更改。
(wordpress 可能还要再安装以下扩展包yum -y install php72w-gd php72w-imap php72w-ldap php72w-odbc php72w-pear php72w-xml php72w-xmlrpc
)