• LAMP搭建WordPress


    L	linux
    A	apache hhtpd
    M	mysql/maridb
    P	PHP
    
    • 1
    • 2
    • 3
    • 4
    1、 安装php
    yum -y install php php-fpm php-server php-mysql
    
    • 1
    1.1、 启动php-fpm并自启
    systemctl enable php-fpm --now
    
    • 1
    [root@ecs-1cee ~]# systemctl status php-fpm
    ● php-fpm.service - The PHP FastCGI Process Manager
       Loaded: 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 ago
     Main 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 www
    
    Sep 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.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    2、 安装mysql5.7
    2.1、搭建mysql源
    cd /etc/yum.repos.d
    
    • 1

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    2.2、安装mysql
    yum -y install mysql mysql-server
    
    • 1
    2.3、启动并自启mysql
    systemctl enable mysqld --now
    systemctl status mysqld
    
    • 1
    • 2
    ● mysqld.service - MySQL Server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
       Active: active (running) since Thu 2023-09-07 13:26:43 CST; 50s ago
         Docs: man:mysqld(8)
               http://dev.mysql.com/doc/refman/en/using-systemd.html
      Process: 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.pid
    
    Sep 07 13:26:37 ecs-1cee systemd[1]: Starting MySQL Server...
    Sep 07 13:26:43 ecs-1cee systemd[1]: Started MySQL Server.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    2.4、 修改mysql密码并创建数据库wordpress
    cat /var/log/mysqld.log | grep pass
    
    • 1
    2023-09-07T05:26:40.507698Z 1 [Note] A temporary password is generated for root@localhost: h)KhK5fo!),n		#临时密码是 h)KhK5fo!),n
    
    • 1
    mysql -uroot -p'h)KhK5fo!),n'		#使用临时密码登录mysql
    
    • 1
    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.43
    
    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> 
    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)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    mysql -uroot -p'o*zu+1FzyG3'	#使用新密码登录
    
    • 1
    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>	
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    3、安装部署httpd服务
    3.1、安装httpd服务
    yum -y install httpd
    
    • 1
    3.2、启动并自启
    systemctl enable httpd --now
    systemctl status httpd
    
    • 1
    • 2
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
       Active: active (running) since Thu 2023-09-07 13:35:48 CST; 9s ago
         Docs: 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 -DFOREGROUND
    
    Sep 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.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    4、部署WordPress
    4.1、下载wordpress

    官网下载地址:https://cn.wordpress.org/download

    cd /opt
    wget https://cn.wordpress.org/latest-zh_CN.zip
    
    • 1
    • 2
    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		#拷贝配置模版作为配置文件
    
    • 1
    • 2
    • 3
    • 4

    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', '' );
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    chmod -R 777 /var/www/html/
    systemctl restart httpd
    
    • 1
    • 2
    5、访问测试
    114.115.151.96/wordpress/		# 根据实际IP
    
    • 1

    在这里插入图片描述

    #报错了,目前PHP版本是5.4.16,但是我的wordpress6.3.1版本需要使用PHP 最小版本为7.0.0

    php --version
    
    • 1
    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
    
    • 1
    • 2
    • 3

    升级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 
    
    • 1
    • 2

    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
    
    • 1
    • 2
    • 3
    • 4

    重新启动服务

    systemctl restart httpd php-fpm
    
    • 1

    访问测试:

    在这里插入图片描述
    在这里插入图片描述

  • 相关阅读:
    企业研发数据:省级工业企业研发费用、企业非真实研发支出原始数据加计算stata do代码两大维度指标
    ubuntu20.04 实测 机械式激光雷达与相机联合标定
    什么是自动化测试?
    Go 并发可视化解释 - Semaphore
    SpringCloud微服务从入门到入土笔记(1/2)
    python处理多Session配置文件
    辅助驾驶功能开发-功能对标篇(15)-NOA领航辅助系统-吉利
    几个友好Java代码习惯建议
    JS——实现数组去重的方法
    selenium中, quit 和close的区别
  • 原文地址:https://blog.csdn.net/qq_50247813/article/details/132736420