yum安装搭建lamp架构部署WordPress个人论坛

yum安装搭建lamp架构部署WordPress个人论坛

1、关闭防火墙、修改selinux并重启
[root@stw2 ~]# systemctl stop firewalld.service 
[root@stw2 ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@stw2 ~]# setenforce 0
[root@stw2 ~]# vim /etc/selinux/config 
[root@stw2 ~]# reboot

在这里插入图片描述

2、时钟同步(因为要使用网络源安装)
[root@stw2 ~]# rpm -q chrony
chrony-3.2-2.el7.x86_64
[root@stw2 ~]# systemctl restart chronyd
[root@stw2 ~]# systemctl enable chronyd
Created symlink from /etc/systemd/system/multi-user.target.wants/chronyd.service to /usr/lib/systemd/system/chronyd.service.
[root@stw2 ~]# hwclock -w
[root@stw2 ~]# timedatectl 
      Local time: Mon 2025-08-18 15:18:32 CST
  Universal time: Mon 2025-08-18 07:18:32 UTC
        RTC time: Mon 2025-08-18 07:18:32
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
3、配置网络源仓库并安装epel-release
[root@stw2 ~]# cd /etc/yum.repos.d/
[root@stw2 yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@stw2 yum.repos.d]# rm -rf *
[root@stw2 yum.repos.d]# ls
[root@stw2 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
//在浏览器搜索阿里巴巴镜像站,将centos7版本的任意一个复制过来
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0   6712      0 --:--:-- --:--:-- --:--:--  6728
[root@stw2 yum.repos.d]# ls
CentOS-Base.repo
[root@stw2 yum.repos.d]# yum -y install epel-release
[root@stw2 yum.repos.d]# ls
CentOS-Base.repo  epel.repo  epel-testing.repo
4、安装httpd和mariadb数据库
[root@stw2 ~]# yum -y install httpd mariadb mariadb-server
[root@stw2 ~]# systemctl restart mariadb.service 
[root@stw2 ~]# systemctl enable mariadb.service 
5、初始化数据库
[root@stw2 ~]# mysql_secure_installation 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y    //设置数据库的root用户的密码,密码是123456
New password: 
Re-enter new password: 
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   //是否不允许root用户远程登录
 ... 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@stw2 ~]# yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@stw2 ~]# yum -y install yum-utils
[root@stw2 ~]# cd /etc/yum.repos.d/
[root@stw2 yum.repos.d]# ls
CentOS-Base.repo   remi-php54.repo  remi-php73.repo  remi-php82.repo
epel.repo          remi-php70.repo  remi-php74.repo  remi-php83.repo
epel-testing.repo  remi-php71.repo  remi-php80.repo  remi.repo
remi-modular.repo  remi-php72.repo  remi-php81.repo  remi-safe.repo
[root@stw2 yum.repos.d]# yum-config-manager --enable remi-php70
[root@stw2 yum.repos.d]# yum -y install php php-cli php-fpm php-gd php-curl php-zip php-mbstring php-opcache php-intl php-mysqlnd
[root@stw2 yum.repos.d]# php -v    //查看php版本
PHP 7.0.33 (cli) (built: Jun  5 2024 09:34:26) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies
7、配置php,将时区改成亚洲/上海
[root@stw2 ~]# vim /etc/php.ini 
[root@stw2 ~]# systemctl restart php-fpm
[root@stw2 ~]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

在这里插入图片描述

8、配置默认网页
[root@stw2 ~]# vim /etc/httpd/conf/httpd.conf 
[root@stw2 ~]# cd /var/www/html
[root@stw2 html]# ls
[root@stw2 html]# vim index.php
[root@stw2 html]# systemctl restart httpd
[root@stw2 html]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

在这里插入图片描述

在这里插入图片描述

9、测试访问lamp基础架构

在这里插入图片描述

10、将压缩包上传并解压
[root@stw2 ~]# ls
anaconda-ks.cfg  Documents  initial-setup-ks.cfg  Pictures  Templates
Desktop          Downloads  Music                 Public    Videos
[root@stw2 ~]# rz -E  //不用敲命令直接将压缩包丢进来
rz waiting to receive.
[root@stw2 ~]# ls
anaconda-ks.cfg  Documents  initial-setup-ks.cfg  Pictures  Templates  wordpress-6.5.5.tar.gz
Desktop          Downloads  Music                 Public    Videos
[root@stw2 ~]# tar -xzvf wordpress-6.5.5.tar.gz 
[root@stw2 ~]# ls
anaconda-ks.cfg  Documents  initial-setup-ks.cfg  Pictures  Templates  wordpress
Desktop          Downloads  Music                 Public    Videos     wordpress-6.5.5.tar.gz
11、将解压之后的压缩包复制移动到/var/www/html,并为之设置权限
[root@stw2 ~]# cp -r wordpress /var/www/html/
[root@stw2 ~]# cd /var/www/html/
[root@stw2 html]# ls
index.php  wordpress
[root@stw2 html]# ll
total 8
-rw-r--r-- 1 root root   21 Aug 18 15:59 index.php
drwxr-xr-x 5 root root 4096 Aug 18 16:06 wordpress
[root@stw2 html]# chown -R apache:apache wordpress/
[root@stw2 html]# ll
total 8
-rw-r--r-- 1 root   root     21 Aug 18 15:59 index.php
drwxr-xr-x 5 apache apache 4096 Aug 18 16:06 wordpress
[root@stw2 html]# chmod -R 775 wordpress/
12、为wordpress配置数据库
[root@stw2 ~]# mysql -uroot -p   //root用户登录,输入密码
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.68-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 |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> create database wordpress_db; //创建数据库wordpress_db
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> create user 'wordpress_user'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
//为wordpress_db数据库创建一个用户和密码

MariaDB [(none)]> grant all on wordpress_db.* to 'wordpress_user'@'localhost';
Query OK, 0 rows affected (0.00 sec)
//给刚刚创建的用户权限

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| wordpress_db       |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
13、为wordpress配置站点
[root@stw2 ~]# cp -p /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf /etc/httpd/conf.d
[root@stw2 ~]# vim /etc/httpd/conf.d/httpd-vhosts.conf 
[root@stw2 wordpress]# vim /etc/httpd/conf/httpd.conf 
//将主配置文件中的一个两个内容复制
[root@stw2 ~]# systemctl restart httpd

在这里插入图片描述

14、使用浏览器访问wordpress站点

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值