WordPress 是一款常用的搭建个人博客网站软件,该软件使用 PHP 语言开发。您可通过在腾讯云服务器的简单操作部署 WordPress,发布个人博客。
本文介绍手动部署 WordPress 的方法,如果您的网站对可扩展性需求要求不高,腾讯云还提供镜像的方式部署 WordPress,具体可参考 使用镜像部署 WordPress。
本教程以 Linux 系统 CentOS 7.5 为例,搭建一个 WordPress 个人站点,具体操作方法如下:
https://partners.cloud.tencent.com/invitation/1000062081375d1c9bfd9e7b5 通过链接申请同意关联为代理客户,关联成功后,咨询在线客服或添加客户经理微信【微信号:15323880413 】。请告之我们您的会员QQ号+订单号+支付宝/财付通/微信/银行账号,以便后面及时准确的给您返现!
以下是本教程中,将会使用的服务或工具:
已登录 云服务器控制台。
注意: 此步骤针对全新购买云服务器。如果您已购买云服务器实例,可以通过重装系统选择 WordPress 建站系统。
LNMP 是 Linux、Nginx、MariaDB 和 PHP 的缩写,这个组合是最常见的 Web 服务器的运行环境之一。在创建并登录云服务器实例之后,您可以开始进行 LNMP 环境搭建。 LNMP 组成及使用版本说明:
登录云服务器后,默认已获取 root 权限。在 root 权限下,根据以下步骤分步安装。
yum -y install nginx
nginx.conf
文件。
vim /etc/nginx/nginx.conf
nginx.conf
文件中 server{...} 的内容替换成以下内容。
用于取消对 IPv6 地址的监听,同时配置 Nginx,实现与 PHP 的联动。
server { listen 80; root /usr/share/nginx/html; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; # location / { index index.php index.html index.htm; } #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; } #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
systemctl start nginx systemctl enable nginx
说明: 以下操作以 PHP7.2.19 版本为例。
rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum search php72w
yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64
systemctl start php-fpm systemctl enable php-fpm
echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php
index.php
文件,查看环境配置是否成功。http://云服务器实例的公网 IP/index.php 页面显示如下,则说明 PHP-Nginx 环境配置成功。
rpm -qa | grep -i mariadb 返回结果类似如下内容,则表示已存在 MariaDB,请执行 步骤2。
yum -y remove 包名
/etc/yum.repos.d/
下创建 MariaDB.repo
文件。vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.4 CentOS7-amd64 [mariadb] name = MariaDB baseurl = http://mirrors.cloud.tencent.com/mariadb/yum/10.4/centos7-amd64/ gpgkey = http://mirrors.cloud.tencent.com/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1 说明: 腾讯云软件源站每天从各软件源的官网同步一次软件资源,请从 MariaDB 软件源 中获取最新地址。
yum clean all
yum -y install MariaDB-client MariaDB-server
systemctl start mariadb systemctl enable mariadb
mysql_secure_installation
mysql -uroot -p 显示结果如下,则已成功进入 MariaDB。
说明: WordPress 可从 WordPress 官方网站 下载 WordPress 最新中文版本并安装,本教程采用 WordPress 中文版本。
index.php
文件。rm -rf /usr/share/nginx/html/index.php
/usr/share/nginx/html/
目录,并下载与解压 WordPress。cd /usr/share/nginx/html wget https://cn.wordpress.org/wordpress-5.0.4-zh_CN.tar.gz tar zxvf wordpress-5.0.4-zh_CN.tar.gz
在写博客之前,需要先建好数据库,以存储各类数据。请根据以下步骤进行 MariaDB 数据库配置。
mysql -uroot -pXXXXX(XXXXX 表示安装 MariaDB 时设置的登录密码)
CREATE DATABASE wordpress;
CREATE USER user;
SET PASSWORD FOR user=PASSWORD("wordpresspassword");
GRANT ALL PRIVILEGES ON wordpress.* TO user IDENTIFIED BY 'wordpresspassword';
FLUSH PRIVILEGES;
\q
wp-config-sample.php
文件复制到wp-config.php
文件中,并将原先的示例配置文件保留作为备份。
cd /usr/share/nginx/html/wordpress cp wp-config-sample.php wp-config.php
vim wp-config.php
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress'); /** MySQL database username */ define('DB_USER', 'user'); /** MySQL database password */ define('DB_PASSWORD', 'wordpresspassword'); /** MySQL hostname */ define('DB_HOST', '127.0.0.1');
http://192.xxx.xxx.xx /wordpress 转至 WordPress 安装页,开始配置 WordPress。
此外,您还可以在腾讯云平台横向和纵向扩展服务容量,例如:
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。