Centos7 使用lamp架构部署wordpress

发布于:2025-08-20 ⋅ 阅读:(17) ⋅ 点赞:(0)

                       Centos7 使用lamp架构部署wordpress

简要流程
1.修改主机名,关闭防火墙
2,同步时钟
3,导入阿里镜像源并安装http,mariadb
4,初始化数据库
5,安装php,改时区,配置默认网页
6,测试
7,部署workpress,将安装包导入并解压
8,写入权限,
9,配置数据库
10,配置站点
11,重启测试
centos 7 lamp架构搭建workpress

1,修改主机名

hostnamectl set-hostname lamp.example.com

bash

2.关闭防火墙,selinux

systemctl stop firewalld

systemctl disable firewalld

setenforce 0

vim /etc/selinux/config

reboot

3,开启时钟同rpm -q chrony

systemctl resatrt chronyd

systemctl enable chronyd

hwcolck -w

4,安装httpd和mariadb数据库

cd /etc/yum.repos.d

rm -rf *

在从阿里找镜像源放入

yum -y install epel-release

yum -y install httpd  mariadb mariadb-server

5,初始化数据库

systemctl restart mariadb

systemctl restart mariadb

mysql_secure_installation



6,安装php

yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum -y install yum-utils

yum-config-manager --enable remi-php70

yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd

php -v

7,将php时区改为Asia/Shanghai

vim /etc/php.ini

systemctl resatrt php-fpm

systrmctl restart php-fpm

8,配置默认网页

vim /etc/httpd/conf/httpd.conf

添加 index.php

vim /var/www/html/index.php

<?php

​			phpinfo();

?>

systemctl restart httpd

systemctl enable httpd

9,测试lamp架构是否成功部署

在浏览器输入IP地址



10,部署workpress

将安装包拖入主目录

解压

tar -xzvf wordpress-6.5.5.tar.gz

cp -r wordpress /var/www/html/

11,给workpress权限

chmod -R apache.apsche /var/www/html/workpress

chmod -R 775 /var/www/html/workpress

12,为workpress配置数据库

mysql -u root -p

create database workpress_db;

create user 'workpress_user'@localhost idendified by 'redhat';

grent all on workpress_db.*to 'workprss_user'@'localhost';

flush privileges;

exit

13,为workpress配置虚拟站点

cp -p /usr/share/doc/httpd-2.4.5/httpd-vhosts.conf /etc/httpd/conf.d/

vim /etc/httpd/conf.d/httpd-vhost.conf

复制模板

再从vim /etc/httpd/conf/httpd.conf

复制模板

<VirtualHost 192.168.100.10:80>
    DocumentRoot "/var/www/html/wordpress"
    <Directory "/var/www/html/wordpress">
        Options Indexes FollowSymLinks ##软连接
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>

14,重启服务

systemctl restart httpd

15,在浏览器访问192.168.100.10/wp-admin
1,修改主机名
[root@localhost ~]# hostnamectl set-hostname lamp.example.com
[root@localhost ~]# bash
2,关闭防火墙和selinux
systemctl  stop  firewalld
systemctl  disable  firewallld
setenforce  0
vim /etc/selinux/config(重启)
3,时钟同步服务器
[root@lamp ~]# yum -y install chrony
[root@lamp ~]# systemctl restart chronyd
[root@lamp ~]# systemctl enable chronyd
[root@lamp ~]# hwclock -w
4,安装httpd和mariadb数据库
CentOS-Base.repo  epel.repo  epel-testing.repo
先在阿里云找到镜像,把原来的yum仓库删除
yum -y install epel-release
[root@lamp ~]# yum -y install httpd mariadb mariadb-server
5,初始化数据库
[root@lamp ~]# systemctl restart mariadb
[root@lamp ~]# systemctl enable mariadb
[root@lamp ~]# mysql_secure_installation
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n]
Enabled successfully!
Reloading privilege tables..
 ... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y
New password: 设置密码为redhat
Re-enter new password: 确认密码为redhat
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n ##允许远程登录
 ... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
6,安装php
[root@lamp yum.repos.d]#
yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum-config-manager --enable remi-php70
[root@lamp ~]# yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd
看版本:
php  -v
7,配置php,将时区改成亚洲/上海
[root@lamp ~]# vim /etc/php.ini
date.timezone = Asia/Shanghai
[root@lamp ~]# systemctl restart php-fpm
[root@lamp ~]# systemctl enable php-fpm
8,配置默认网页
[root@lamp ~]# vim /etc/httpd/conf/httpd.conf
<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>
[root@lamp ~]# vim /var/www/html/index.php
<?php
        phpinfo();
?>
[root@lamp ~]# systemctl restart httpd
[root@lamp ~]# systemctl enable httpd
9,测试访问lamp基础架构
10,将wordpress压缩包上传到服务器的/opt/software下
[root@lamp ~]# yum -y install lrzsz
[root@lamp ~]# mkdir /opt/software
[root@lamp software]# ls /opt/software/
wordpress-6.5.5.tar.gz
解压wordpress压缩包
[root@lamp software]# yum -y install tar
[root@lamp software]# tar -zxvf wordpress-6.5.5.tar.gz
[root@lamp software]# ls
wordpress  wordpress-6.5.5.tar.gz
##或直接把压缩包托到home目录下
然后解压
tar -xzvf wordpress-6.5.5.tar.gz
[root@lamp software]# cp -r wordpress /var/www/html/
11,设置wordpress的权限
[root@lamp ~]# chown -R apache.apache /var/www/html/wordpress/
[root@lamp ~]# chmod -R 775 /var/www/html/wordpress/
12,为wordpress配置数据库
[root@lamp ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.5.22-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.
查看数据库:
show databases;
创建数据库:名:wordpress_db
MariaDB [(none)]> create database wordpress_db;
Query OK, 1 row affected (0.000 sec)
创建用户:名字:wordpress_user 密码:redhat
MariaDB [(none)]> create user 'wordpress_user'@'localhost' identified by 'redhat';
Query OK, 0 rows affected (0.001 sec)
设置权限:
MariaDB [(none)]> grant all on wordpress_db.* to 'wordpress_user'@'localhost';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)
13,为wordpress配置站点
[root@lamp ~]# cp -p /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d/
[root@lamp ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf
复制模板:
<VirtualHost 192.168.100.10:80>
    DocumentRoot "/var/www/html/wordpress"
    <Directory "/var/www/html/wordpress">
        Options Indexes FollowSymLinks ##软连接
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>
从主配置文件复制以下模板。
vim /etc/httpd/conf/httpd.conf
14,重启apache服务
[root@lamp ~]# systemctl restart httpd
15使用浏览器访问wordpress站点192.168.100.10/wp-admin

网站公告

今日签到

点亮在社区的每一天
去签到