# Linux WordPress 部署 ## 简介 本文主要介绍了在华为云中使用华为云云主机手动搭建WordPress论坛。 MySQL:5.7 PHP:7.0 WordPress:5.3 ## 前期准备 ## 前期准备 创建VPC和安全组,购买弹性公网IP地址。 创建VPC和安全组,购买弹性公网IP地址。 云主机镜像选择CentOS7.6。 ## LNMP环境安装 ### Nginx安装 ```shell # 下载Nginx安装包 wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm # 建立Nginx的yum仓库 rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm # 安装Nginx yum install nginx -y # 配置Nginx开机启动 systemctl enable nginx systemctl start nginx # 测试Nginx是否安装成功 curl localhost ``` ### MySQL安装 ```shell # 安装MySQL wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm yum -y install mysql57-community-release-el7-10.noarch.rpm yum -y install mysql-community-server --nogpgcheck # 配置MySQL开机启动 systemctl enable mysqld systemctl start mysqld # 获取MySQL安装生成的密码 grep 'temporary password' /var/log/mysqld.log # 配置MySQL mysql_secure_installation ``` ### PHP安装 ``` shell # 下载PHP7仓库 rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm # 安装PHP7和扩展 yum -y install php70w-tidy php70w-common php70w-devel php70w-pdo php70w-mysql php70w-gd php70w-ldap php70w-mbstring php70w-mcrypt php70w-fpm # 配置PHP开机启动 systemctl enable php-fpm systemctl start php-frm # 修改Nginx配置以支持PHP # 在/etc/nginx/conf.d/default.conf中server {}中添加 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; } ``` ## WordPress安装 ### 创建数据库 ``` shell mysql -u root -p CREATE DATABASE wordpress; exit ``` ### WordPress安装 ```shell # 下载WordPress安装包 wget https://wordpress.org/latest.tar.gz # 解压WordPress安装包 tar -zxvf latest.tar.gz # 分配权限 chmod -R 777 wordpress # 将WordPress放置到Nginx目录 mv wordpress /usr/share/nginx/html ```