LAMP架构部署WordPress

基础环境

[root@http ~]# hostnamectl set-hostname lamp
[root@http ~]# bash
[root@lamp ~]# mv /etc/yum.repos.d/CentOS-* /tmp/
[root@lamp ~]# systemctl disable firewalld --now && setenforce 0
[root@lamp ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@lamp ~]# curl -o /etc/yum.repos.d/centos.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0  14998      0 --:--:-- --:--:-- --:--:-- 15107
[root@lamp ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   664  100   664    0     0   6341      0 --:--:-- --:--:-- --:--:--  6384

yum源安装mariadb

### 移除自带依赖
[root@lamp ~]# yum list installed | grep mariadb                                            
mariadb-libs.x86_64                   1:5.5.68-1.el7                   @anaconda
[root@lamp ~]# yum remove -y mariadb-libs

### 配置官网repo源
[root@lamp ~]# cat /etc/yum.repos.d/mariadb.repo 
[mariadb]
name = MariaDB
baseurl = https://rpm.mariadb.org/10.6/rhel/$releasever/$basearch
gpgkey= https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

[root@lamp ~]# yum install -y mariadb-server mariadb-client

[root@http ~]# mariadb -V
mariadb  Ver 15.1 Distrib 10.6.16-MariaDB, for Linux (x86_64) using readline 5.1
[root@http ~]# 

[root@lamp ~]# systemctl enable mariadb --now
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

[root@lamp ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.6.16-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
+--------------------+
5 rows in set (0.001 sec)

MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> show databases;           
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| test               |
| wordpress          |
+--------------------+
6 rows in set (0.001 sec)

MariaDB [(none)]> grant all privileges on *.* to 'wordpress'@'localhost' identified by '000000';
Query OK, 0 rows affected (0.001 sec)

yum源安装apache

[root@http ~]# yum install -y httpd

[root@http ~]# systemctl enable httpd --now
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

[root@http ~]# httpd -V
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::3dc3:3652:c74b:c16e. Set the 'ServerName' directive globally to suppress this message
Server version: Apache/2.4.6 (CentOS)
Server built:   May 30 2023 14:01:11
Server's Module Magic Number: 20120211:24
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

yum源安装php

### 更新php源
[root@http ~]# rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest7.noarch.rpm
Retrieving https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
warning: /var/tmp/rpm-tmp.ttCrHQ: Header V4 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-14                warning: /etc/yum.repos.d/epel.repo created as /etc/yum.repos.d/epel.repo.rpmnew
################################# [100%]
[root@http ~]# rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:webtatic-release-7-3             ################################# [100%]

### 安装依赖
[root@http ~]# yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64

[root@http ~]# systemctl enable php-fpm --now
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

Apache解析PHP

[root@http ~]# vim /etc/httpd/conf/httpd.conf 
### 搜索ServerName,把ServerName www.example.com:80前注释去掉

<Directory />
    AllowOverride none
    Require all denied
</Directory>
# 改成:
<Directory />
    AllowOverride none  
    Require all granted
</Directory>    ### 目的允许所有请求访问

### 搜索AddType application/x-gzip .gz .tgz,在下面添加一行 AddType application/x-httpd-php .php

<IfModule dir_module>
    DirectoryIndex index.html 
</IfModule>
# 改成:
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

[root@http ~]# httpd -t
Syntax OK
[root@http ~]# systemctl restart httpd

[root@http ~]# echo "" > /var/www/html/1.php  

LAMP架构部署WordPress_第1张图片

部署WordPress

[root@http ~]# unzip wordpress-4.7.3-zh_CN.zip

[root@http ~]# cp -rvf wordpress/* /var/www/html/

[root@http ~]# chmod -R 777 /var/www/html/

[root@http ~]# cp wp-config-sample.php wp-config.php

[root@http ~]# vim wp-config.php
 21 // ** MySQL
 22 /** WordPress
 23 define('DB_NAME', 'wordpress');
 24
 25 /** MySQL数据库⽤户名 */
 26 define('DB_USER', 'wordpress');
 27
 28 /** MySQL数据库密码 */
 29 define('DB_PASSWORD', '000000');
 30
 31 /** MySQL主机 */
 32 define('DB_HOST', 'localhost');
 33
 34 /** 创建数据表时默认的⽂字编码 */
 35 define('DB_CHARSET', 'utf8');

LAMP架构部署WordPress_第2张图片
LAMP架构部署WordPress_第3张图片

你可能感兴趣的:(架构,运维,linux,服务器)