环境说明

操作系统: CentOS 7.2 64位

1. 准备LAMP环境

LNMP 是 Linux、Nginx、MySQL 和 PHP 的缩写,是 WordPress 博客系统依赖的基础运行环境。我们先来准备 LNMP 环境

  • 安装 Nginx

yum install nginx -y

修改 /etc/nginx/nginx.conf,去除对 IPv6 地址的监听,如下:

server {
listen 80 default_server;
# listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
} }

修改完成之后,启动NGINX,并设置为开机自启
nginx

chkconfig nginx on

安装MySQL

下载rmp包。

 
wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

安装rpm包

rpm -Uvh mysql57-community-release-el7-9.noarch.rpm

安装MySQL

 
yum install mysql-community-server -y

启动MySQL

 
systemctl start mysqld.service

设置MySQL密码

获取 root 临时密码

 
grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}'

使用上一步的获得的临时密码登入 MySQL

 
mysql -uroot -p

更改MySQL的root密码为dettRoot$123

 
ALTER USER 'root'@'localhost' IDENTIFIED BY 'dettRoot$123';

退出MySQL,回到Bash shell

 
exit;

将MySQL设置为开机自启

 
chkconfig mysqld on
  • 安装PHP
 
yum install php-fpm php-mysql -y

安装之后,启动 PHP-FPM 进程:

 
service php-fpm start

启动之后,可以使用下面的命令查看 PHP-FPM 进程监听哪个端口

 
netstat -nlpt | grep php-fpm

把 PHP-FPM 设置成开机自动启动

 
chkconfig php-fpm on

2. 安装并配置WordPress

安装

 
yum install wordpress -y

在完成安装之后,可以在 /usr/share/wordpress 看到 WordPress 的源代码。

配置MySQL数据库

## 进入mysql数据库
mysql -uroot --password='dettRoot$123'
创建数据库
CREATE DATABASE wordpress;
退出数据库
exit;

修改编辑/usr/share/wordpress/wp-config.php文件,主要修改数据库的配置信息,如下:

要根据自己之前对数据库的配置进行设置

define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root'); /** MySQL database password */
define('DB_PASSWORD', 'dettRoot$123'); /** MySQL hostname */
define('DB_HOST', 'localhost');
  • 配置NGINX

WordPress 已经安装完毕,我们配置 Nginx 把请求转发给 PHP-FPM 来处理

进入NGINX配置目录

 
cd /etc/nginx/conf.d/

修改/etc/nginx/nginx.conf文件,如下

 
server {
listen 80;
root /usr/share/wordpress;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php index.php;
}
# 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;
}
}

配置后,通知 Nginx 进程重新加载:

 
nginx -s reload

3. 检查

后台访问地址:http://IP/wp-admin/install.php

前端博客地址:http://IP

最新文章

  1. Node 编程规范
  2. SQL --Chapter 04 数据更新
  3. ADO.NET基础03
  4. T-SQL性能调整(一)--编译和重新编译
  5. Capture
  6. 《JavaScript高级程序设计》学习笔记
  7. Ubuntu 装JDK
  8. web2py--------------用web2py写 django的例子 --------开发环境
  9. Codeforces #377 Div2
  10. Quick Brown Fox
  11. hibernate学习(四)hibernate的一级缓存&快照
  12. qt 拖拽 修改大小(二)
  13. Simple Sort
  14. Kubernetes学习之路(二十)之K8S组件运行原理详解总结
  15. CSS——图片替换方法:Fahrner图片替换法(FIR)
  16. 委托发展史(Linq操作符)
  17. [翻译] FeSpinner
  18. 深入理解C/C++混合编程优秀博文赏析与学习
  19. bzoj2750最短路计数
  20. Wavesurfer.js音频播放器插件的使用教程

热门文章

  1. springIOC源码接口分析(四):MessageSource
  2. math type白嫖教程
  3. python写的用WMI检测windows系统信息的脚本
  4. Java并发读书笔记:线程安全与互斥同步
  5. html作业记录
  6. Node——request使用代理
  7. ELK:收集k8s容器日志最佳实践
  8. SpringBoot之ApplicationRunner接口和@Order注解
  9. 7天用Go动手写/从零实现分布式缓存GeeCache
  10. 视觉光盘,只有我可以贴全世界唯一,Windows上最高级的DOCKER客户端数字, 夜晚点击一个都没有,值班的小编辛苦了