Configuring LAMP Environment on CentOS 7.9#
I messed up the server these days and had to reinstall the system several times. Here, I will record the process of configuring the LAMP environment.
First, update yum. Run yum versionlock status
to check if there are any version locks. If there are, run yum versionlock clear
to clear them. Then, run yum -y update
to update.
Installing Apache#
The method is very simple, and there is no need to update yum source. First, run yum install httpd
to see if it can be installed directly. If it displays no package found for httpd
, use yum --disableexcludes=all install httpd
to install. Otherwise, you can install it directly. After installation, use systemctl start httpd
to run httpd. If there is a security group or firewall, open port 80 for access. After opening, you can enter your IP in the browser. If the following interface is displayed, the installation is successful.
Installing MySQL#
Install directly using the command
Run wget https://dev.mysql.com/get/mysql80-community-release-el7-6.noarch.rpm
to download the rpm package, and then run
yum -y install mysql80-community-release-el7-6.noarch.rpm
yum -y install mysql-community-server --nogpgcheck
for installation.
Possible errors that may occur:
- 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
Installing PHP#
Because I want to use Typecho, the PHP version in yum is too low, so I need to update the rpm.
Two commands:
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
After running these commands, you can directly install using yum install -y php72w php72w-cli php72w-common php72w-devel php72w-mysql
. 72 is the version number, you can change it according to your needs.
(For WordPress, you may also need to install the following extension packages: yum -y install php72w-gd php72w-imap php72w-ldap php72w-odbc php72w-pear php72w-xml php72w-xmlrpc
)