参考文档:https://support.huaweicloud.com/bestpractice-ecs/zh-cn_topic_0135015337.html
购买ECS,centos7.6镜像,vpc要和RDS一样
购买RDS,vpc要和ECS的一样
登录ECS
安装Nginx。
- 登录弹性云服务器。
- 执行以下命令,下载对应当前系统版本的Nginx包。
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
- 执行以下命令,建立Nginx的yum仓库。
- 执行以下命令,安装Nginx。
- 执行以下命令,启动Nginx并设置开机启动。
systemctl enable nginx
- 查看启动状态。
跳过安装sql
安装PHP。
- 依次执行以下命令,安装PHP 7和一些所需的PHP扩展。
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php70w-tidy php70w-common php70w-devel php70w-pdo php70w-mysql php70w-gd php70w-ldap php70w-mbstring php70w-mcrypt php70w-fpm
- 执行以下命令,验证PHP的安装版本。
- 执行以下命令,启动PHP服务并设置开机自启动。
systemctl enable php-fpm
- 执行以下命令打开配置文件/etc/nginx/conf.d/default.conf。
-
添加红色部分server {
listen 80;
server_name localhost;#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
- 执行以下命令,重新载入nginx的配置文件。
在/usr/share/nginx/html目录下创建“info.php”的测试页面。
- 执行以下命令创建并打开“info.php”的测试文件。
- 按i键进入编辑模式。
- 修改打开的“info.php”文件,将如下内容写入文件。
<?php phpinfo(); ?>
- 使用浏览器访问“http://服务器IP地址/info.php”,显示如下页面,说明环境搭建成功。
安装wordpress服务
切换目录
cd /usr/share/nginx/html
打开官网链接https://wordpress.org/download/releases/
光标移动到要下载的版本压缩包上面复制链接(这里下载最新版本,tar解压的时候版本不一样要改版本号)
执行命令
wget 复制的链接
如
wget https://wordpress.org/wordpress-6.2.tar.gz
- 执行以下命令,解压缩软件包。
解压后生成一个“wordpress”的文件夹。
- 执行以下命令,设置解压后的文件权限。
浏览器访问“http://服务器IP地址/wordpress”进入安装向导
登录RDS创建一个名字叫wordpress数据库
回到安装向导,按Let‘s go 如图输入信息,username是自定义的建议使用(root,admin)
后面的乱按就行