环境介绍:
CentOS7.3安装部署wordpress,本环境主机运行在阿里云,部署方式为单节点部署。
主机配置:
系统:CentOS7.3 mini
CPU:1核
内存:1GB
硬盘:60G
外网带宽:1Mbs
一、配置主机名
[root@localhost ~]# vi /etc/hostname //需要重启电脑
wordpress
[root@wordpress ~]# reboot
[root@wordpress ~]# hostname
wordpress
二、下载wordpress
[root@wordpress ~]# yum install wget -y
[root@wordpress ~]# ls
wordpress-4.8.1-zh_CN.zip
三、安装lamp+vsftp
1、安装httpd、php和vsftpd
[root@wordpress ~]# yum install -y httpd*
[root@wordpress ~]# yum install -y php*
[root@wordpress ~]# yum install -y vsftpd*
2、安装mysql
a. 下载mysql的repo源
b. 安装mysql-community-release-el7-5.noarch.rpm包
#rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装这个包后,会获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo。
c. 安装mysql
# yum install mysql-server
d
、设置开机启动
[root@wordpress ~]# systemctl enable httpd
[root@wordpress ~]# systemctl enable mysqld
[root@wordpress ~]# systemctl enable vsftpd
自己安装的系统需关闭firewalld和selinux
[root@wordpress ~]# systemctl stop firewalld
[root@wordpress ~]# systemctl disable firewalld
[root@wordpress ~]# setenforce 0
[root@wordpress ~]# vi /etc/selinux/config
SELINUX=disabled
四、配置lamp和vsftp
1、为mysql设置root账户密码
mysql_secure_installation
#回车,根据提示输入Y
#输入2次密码,回车
#根据提示一路输入Y
#最后出现:Thanks for using MySQL!
#MySql密码设置完成,重新启动 MySQL:
2、创建wordpress库
[root@wordpress ~]# mysql -u root -p
mysql> show databases;
mysql> create database wordpress;
mysql> exit;
3、配置httpd,指定wordpress默认目录
[root@wordpress wordpress]# vi /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html/wordpress"
4、配置vsftp,上传下载代码或模板用
[root@wordpress ~]# vi /etc/vsftpd/vsftpd.conf
anonymous_enable=No //关闭匿名登陆
[root@wordpress ~]# useradd wpftp -s /sbin/nologin //创建wpftp用户,但不能登陆系统
[root@wordpress ~]# passwd wpftp //设置wpftp密码
5、解压WordPress安装包
[root@wordpress ~]# cp wordpress-4.8.1-zh_CN.zip /var/www/html/
[root@wordpress ~]# yum install unzip -y
[root@wordpress html]# unzip wordpress-4.8.1-zh_CN.zip
6、重启WordPress服务
[root@wordpress ~]# systemctl restart httpd
[root@wordpress ~]# systemctl restart mysqld
[root@wordpress ~]# systemctl restart vsftpd
五、初始化安装 wordpress
1、在浏览器中访问
http://IP/wp-admin/install.php
2、配置数据库连接
3、数据库配置文件生成失败
wp-config.php没有执行权限,需要使用chmod授权普通用户有可写权限,或者按照下方步骤直接修改数据库登录信息。
[root@wordpress ~]# cd /var/www/html/wordpress
[root@wordpress wordpress]# cp wp-config-sample.php wp-config.php
[root@wordpress wordpress]# vi wp-config.php //手动修改数据库连接信息
define('DB_NAME', 'wordpress');
define('DB_USER', 'root'); //数据库账户
define('DB_PASSWORD', '数据库密码'); //数据库密码
define('DB_HOST', 'localhost'); //数据库地址
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
4、配置用户名密码
5、安装完成
五、登陆
http://ip/wp-login.php //后台登陆
http://ip //网站首页