实验八-Web部署

openEuler中基于LAMP部署WordPress

实验过程

一、配置openEuler

在华为云openEuler 安装后,没有配置yum源,我们通过重新配置。

cd /etc/yum.repos.d

vi openEuler_x86_64.repo 

增加下面内容:

[OS]
name=OS
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler

[everything]
name=everything
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/everything/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/everything/$basearch/RPM-GPG-KEY-openEuler

[EPOL]
name=EPOL
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/EPOL/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler

[debuginfo]
name=debuginfo
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/debuginfo/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/debuginfo/$basearch/RPM-GPG-KEY-openEuler

[source]
name=source
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/source/
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/source/RPM-GPG-KEY-openEuler

[update]
name=update
baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/update/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler

二、安装LAMP

在shell中 通过下面命令安装Apache:

yum install -y httpd 


通过下面命令开启Apache服务:

systemctl start httpd.service


通过下面命令,设置Apache开机自启动:

systemctl enable httpd.service


系统默认启动防火墙,会导致我们无法访问网站,通过下面命令关闭防火墙:

systemctl stop firewalld

通过下面命令禁止防火墙自启动:

systemctl disable firewalld


通过下面命令安装mariadb:

yum install -y mariadb-server





通过下面命令开启mariadb服务:

systemctl start mariadb


通过下面命令设置mariadb开机自启动:

systemctl enable mariadb


通过下面命令给mariadb数据库的root账户设置密码123456:

mysqladmin -uroot password '123456'


通过下面命令安装PHP和PHP模块:

yum install -y php


yum install -y php-mysqlnd php-fpm php-opcache php-cli php-curl php-dom php-exif php-fileinfo php-gd ph`p-hash php-json php-mbstring php-mysqli php-openssl php-pcre php-xml libsodium






通过下面命令安装交互更加良好的nano 文本编辑器:

yum install nano



通过下面命令查看Apache和mariadb的运行状态:

systemctl status httpd

systemctl status mariadb


通过下面命令查看Apache和mariadb是否已经开启了开机自启动:

systemctl list-unit-files | grep httpd.service

systemctl list-unit-files | grep mariadb.service


通过下面命令查看PHP的版本信息:

php -v


通过下面命令创建一个PHP测试文件测试PHP是否正常,输出重定向到test.php文件:

echo "<?php phpinfo();  ?>" > /var/www/html/test.php


通过下面命令给这个文件赋权限:

chmod 755 /var/www/html/test.php


通过下面命令重启Apache服务:

systemctl restart httpd

三、安装部署wordpress

通过下面命令安装wget:

yum install -y wget


通过下面命令请求wordpress安装包(.ZIP):

wget https://cn.wordpress.org/latest-zh_CN.zip


通过下面命令查看mariadb的版本号:

rpm -qa | grep mariadb


通过下面命令登录到mariadb:

mysql -uroot -p


通过下面命令创建WordPress数据库:

create database wordpressdb;



通过下面命令安装unzip解压工具:

yum install -y unzip


解压latest-zh_CN.zip到/var/www目录下

unzip latest-zh_CN.zip -d /var/www


通过下面命令创建用户给Apache权限:

chown -R apache:apache /var/www/wordpress
chmod -R 755 /var/www/wordpress/


编辑Apache的配置文件:

nano /etc/httpd/conf/httpd.conf


编辑Apache的欢迎页面,将其内容都注释掉:

nano /etc/httpd/conf.d/welcome.conf

重启Apache服务:

systemctl restart httpd

转到下面这个文件夹:

cd /var/www/wordpress

创建 wp-config.php 文件:

nano wp-config.php


访问ip/wp-config.php

遇到的问题与解决方案

1、不知道control+C,control+X是退出的功能。——————查看他人博客得知如何在华为云服务器里退出文件。
2、创建wp-config.php是没有添加文件中应该有的内容。——————在群里复制有关内容进行添加。
3、没有配置http.conf,http.conf无法打开。——————用记事本打开http.conf,复制有关内容。

对实验的建议

1、希望视频也能有博客与之对应。
2、希望博客中解释一下相关专业术语的意思。

posted @ 2022-12-25 20:10  20221320冯泰瑞  阅读(33)  评论(0编辑  收藏  举报