L linux
A apache hhtpd
M mysql/maridb
P PHP
1、 安装php
yum -y install php php-fpm php-server php-mysql
1.1、 启动php-fpm并自启
systemctl enable php-fpm --now
[root@ecs-1cee ~]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process ManagerLoaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2023-09-07 13:20:17 CST; 15s agoMain PID: 8456 (php-fpm) #running 正常启动中Status: "Processes active: 0, idle: 5, Requests: 0, slow: 0, Traffic: 0req/sec"CGroup: /system.slice/php-fpm.service├─8456 php-fpm: master process (/etc/php-fpm.conf)├─8458 php-fpm: pool www├─8459 php-fpm: pool www├─8460 php-fpm: pool www├─8461 php-fpm: pool www└─8462 php-fpm: pool wwwSep 07 13:20:17 ecs-1cee systemd[1]: Starting The PHP FastCGI Process Manager...
Sep 07 13:20:17 ecs-1cee systemd[1]: Started The PHP FastCGI Process Manager.
2、 安装mysql5.7
2.1、搭建mysql源
cd /etc/yum.repos.d
vim mysql.repo
[mysql]
name=mysql
baseurl=http://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/ # 采用的是清华源
enabled=1
gpgcheck=0
2.2、安装mysql
yum -y install mysql mysql-server
2.3、启动并自启mysql
systemctl enable mysqld --now
systemctl status mysqld
● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2023-09-07 13:26:43 CST; 50s agoDocs: man:mysqld(8)http://dev.mysql.com/doc/refman/en/using-systemd.htmlProcess: 8682 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)Process: 8632 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)Main PID: 8686 (mysqld)CGroup: /system.slice/mysqld.service└─8686 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pidSep 07 13:26:37 ecs-1cee systemd[1]: Starting MySQL Server...
Sep 07 13:26:43 ecs-1cee systemd[1]: Started MySQL Server.
2.4、 修改mysql密码并创建数据库wordpress
cat /var/log/mysqld.log | grep pass
2023-09-07T05:26:40.507698Z 1 [Note] A temporary password is generated for root@localhost: h)KhK5fo!),n #临时密码是 h)KhK5fo!),n
mysql -uroot -p'h)KhK5fo!),n' #使用临时密码登录mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.43Copyright (c) 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'o*zu+1FzyG3'; #修改密码为o*zu+1FzyG3
Query OK, 0 rows affected (0.00 sec)
mysql -uroot -p'o*zu+1FzyG3' #使用新密码登录
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.43 MySQL Community Server (GPL)Copyright (c) 2000, 2023, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> create database wordpress default character set utf8 collate utf8_general_ci #创建wordpress数据库,字符集是utf8-> ;
Query OK, 1 row affected (0.00 sec)mysql>
3、安装部署httpd服务
3.1、安装httpd服务
yum -y install httpd
3.2、启动并自启
systemctl enable httpd --now
systemctl status httpd
● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)Active: active (running) since Thu 2023-09-07 13:35:48 CST; 9s agoDocs: man:httpd(8)man:apachectl(8)Main PID: 8774 (httpd)Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"CGroup: /system.slice/httpd.service Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.├─8774 /usr/sbin/httpd -DFOREGROUND├─8775 /usr/sbin/httpd -DFOREGROUND├─8776 /usr/sbin/httpd -DFOREGROUND├─8777 /usr/sbin/httpd -DFOREGROUND├─8778 /usr/sbin/httpd -DFOREGROUND└─8779 /usr/sbin/httpd -DFOREGROUNDSep 07 13:35:48 ecs-1cee systemd[1]: Starting The Apache HTTP Server...
Sep 07 13:35:48 ecs-1cee httpd[8774]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the...is message
Sep 07 13:35:48 ecs-1cee systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
4、部署WordPress
4.1、下载wordpress
官网下载地址:
https://cn.wordpress.org/download
cd /opt
wget https://cn.wordpress.org/latest-zh_CN.zip
4.2、部署wordpress
unzip latest-zh_CN.zip
cp -r wordpress/ /var/www/html/
cd /var/www/html/wordpress
cp wp-config-sample.php wp-config.php #拷贝配置模版作为配置文件
vi wp-config.php
/** Database username */
define( 'DB_USER', 'root' ); # 数据库用户/** Database password */
define( 'DB_PASSWORD', 'o*zu+1FzyG3' ); # 数据库密码/** Database hostname */
define( 'DB_HOST', 'localhost' ); # 数据库地址,localhost表示本机地址,如果端口不是3306,需要写成localhost:端口号/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
chmod -R 777 /var/www/html/
systemctl restart httpd
5、访问测试
114.115.151.96/wordpress/ # 根据实际IP
#报错了,目前PHP版本是5.4.16,但是我的wordpress6.3.1版本需要使用PHP 最小版本为7.0.0
php --version
PHP 5.4.16 (cli) (built: Apr 1 2020 04:07:17)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
升级php版本
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install --enablerepo=remi --enablerepo=remi-php72 php php-opcache php-devel php-mysqlnd php-gd
php --version
PHP 7.2.34 (cli) (built: Aug 1 2023 16:03:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies
重新启动服务
systemctl restart httpd php-fpm
访问测试: