Ubuntu搭建WordPress-MySQL-Apache
目标
技术博客www.xifarm.com有5年时间了.
原来在虚拟机/VPS上搭建,不过都是Windows系统下的。 最近突发奇想,试试迁移到Linux的Unbuntu下。说干就干,抽空用了大约3天时间*每天1~2小时投入,完成搭建。
这里记录一下过程,分享给有需求的朋友。
1. 安装LAMP (Install Linux, Apache, MySQL, PHP)
首先需要安装 (LAMP) stack, 顺序执行命令,很简单。
sudo apt update
sudo apt install apache2
http://your_server_ip
sudo apt install mysql-server
sudo mysql_secure_installation
sudo apt install php libapache2-mod-php php-mysql
sudo vi /etc/apache2/mods-enabled/dir.conf
新的wordPress已经推荐支持Php 7.2,所以直接安装php 7.2。
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install -y php7.2
2. 安装WordPress
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
touch /tmp/wordpress/.htaccess
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
mkdir /tmp/wordpress/wp-content/upgrade
sudo cp -a /tmp/wordpress/. /var/www/wordpress
sudo chown -R www-data:www-data /var/www/wordpress
配置3个字段,可完成DB创建。(前置条件,需要先用MySQL创建DB,这里不再赘述)
curl -s https://api.wordpress.org/secret-key/1.1/salt/
vi 打开配置文件 /var/www/wordpress/wp-config.php
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpressuser');
/** MySQL database password */
define('DB_PASSWORD', 'password');
define('FS_METHOD', 'direct');
3. SSL增加HTTPs
今年Google Chorome、Apple Safari先后声明,全力支持HTTPS,故,本次也一并把HTTPS考虑在内了。 原来以为HTTPs和域名一样需要申请、审核,比较费时。
看了几篇博客,才知道通过certbot 申请,整个过程完全自动化,网速快的话10分钟可以完成申请(90天免费,写个自动化调度执行命令Refresh即可实现长期免费)。
按照顺序执行command:
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache
sudo certbot --apache -d example.com
sudo certbot --apache -d example.com -d www.example.com
https://www.ssllabs.com/ssltest/analyze.html?d=example.com&latest
cron script placed in /etc/cron.d
sudo certbot renew --dry-run
tips: 几个比较耗时的过程总结
mySQL外网运维权限
linux的安全大门果然紧闭,难怪安全呢;不像windows安全大门比较松,使用起来灵活一些。如,MySQL访问权限,Linux默认在localHost内开放,但是我们为了运维方便,需要向定向IP进行授权。
通过修改配置文件,可开启MySQL外网访问权限:增删改查。
打开/etc/mysql/mysql.conf.d/mysqld.cnf 文件
修改IP地址
bind-address = 0.0.0.0
GRANT ALL ON *.* TO 'root'@'192.168.0.7' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
GRANT ALL ON *.* TO 'user'@'localhost' IDENTIFIED BY 'passwd' WITH GRANT OPTION;
同时,需要Linux系统防火墙开放3306端口:
sudo ufw allow 3306
sudo ufw status
netstat -an | grep 3306
netstat -an | grep -i established
WordPress调试开关
导入备份的DB,打开博客首页,奇怪,没反应。
估计是DB或者配置问题,为了Debug log,需要开启了WordPress自带的log开关,查debug.log看看端倪。
在 wp-config.php,添加如下代码:
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );
WordPress固定连接访问失效解决
为了SEO,我把默认的WordPress博客链接修改为 http://www.xifarm.com/photononazure/
但是默认的Apache2没有打开这个规则,需要修改Apache的config文件,并重启Apache2服务。
vi /etc/apache2/apache2.conf
<Directory /path/to/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
sudo service apache2 restart
参考文章:
1. How To Install WordPress with LAMP on Ubuntu 18.04
2. How To Secure Apache with Let's Encrypt on Ubuntu 14.04
3. How to set up MySQL for remote access on Ubuntu Server 16.04
Ubuntu搭建WordPress-MySQL-Apache的更多相关文章
- 基于Ubuntu 搭建 WordPress 个人博客 - 开发者实验室 - 腾讯云
1.准备 LAMP 环境 安装 Apache2 在终端输入该命令 ,使用 apt-get 安装 Apache2: sudo apt-get install apache2 -y 安装好后,您可以通过访 ...
- 基于ubuntu搭建 WordPress 个人博客
系统要求:Ubuntu 16.04.1 LTS 64 位操作系统 准备 LAMP 环境:(LAMP 是 Linux.Apache.MySQL 和 PHP 的缩写,是 Wordpress 系统依赖的基础 ...
- Ubuntu下PHP+MySQL+Apache+PHPStorm的安装和配置
粘贴自:https://www.jianshu.com/p/a6a0d2a29591 1.Apache的安装: $ sudo apt-get update $ sudo apt-get install ...
- Linux搭建PHP+MySQL+Apache环境
环境: CentOS 6.4 MySQL详细安装可参考:http://www.cnblogs.com/yangxia-test/archive/2012/11/12/2766237.html Apac ...
- linux下搭建nginx+mysql+apache
对于开发人员来说,进行Web开发时可以用Apache进行网站测试,然而当一个Web程序进行发布时,Apache中并发性能差就显得很突出,这时配置一台Nginx服务器显得尤为重要. 以下是配置Nginx ...
- 阿里云ECS Ubuntu安装PHP+Mysql+Apache+Nginx+Redis+Discuz
http://www.linuxdiyf.com/linux/13662.html http://blog.csdn.net/wangnan537/article/details/47868659 h ...
- Ubuntu 搭建PHP开发环境
Ubuntu确实很好玩.有喜欢的命令行,简洁的界面,不同于Window要的感觉.偶尔换换环境工作,学习Linux的思维方式,是一种不错的做 法.之前也折腾过Ubuntu,不过,因为网络的问题,一直没有 ...
- 搭建自己的apache tomcat php mysql 环境和WordPress站点制作
无论你是web开发人员,还是程序员,拥有一个自己的站点总没有坏处,下面我们就从搭建wordpress的环境来说吧. 1.首先wordpre是用的php语言,所以需要php环境,最基本的数据库也不能缺少 ...
- [Linux] Ubuntu Server 12.04 LTS 平台上搭建WordPress(Nginx+MySql+PHP) Part II
接着上一节继续搭建我们的LNMP平台,接下来我们安装PHP相关的服务 sudo apt-get install php5-cli php5-cgi php5-fpm php5-mcrypt php5- ...
- [Linux] Ubuntu Server 12.04 LTS 平台上搭建WordPress(Nginx+MySQL+PHP) Part IV
接下来我们去下载 WorePress 用最新的 3.7.1 下载地址是:http://cn.wordpress.org/wordpress-3.7.1-zh_CN.zip 我们先建立一个文件夹 /va ...
随机推荐
- dead reckoning variation
Targeting A target is a structure of information that describes the state, and change of state, of a ...
- 1034 Head of a Gang (30)(30 分)
One way that the police finds the head of a gang is to check people's phone calls. If there is a pho ...
- NCEE2018游记
前言 悠闲的高中生活结束啦.俺たちの戦いはこれからだ!(无误) Day0 看考场 听考前教育,前面还挺常规,后面讲了半个多小时相关法律,听了几句后实在没兴趣了,开始瞎想.那个人连续读了近一个小时也不嫌 ...
- bzoj 4555 [Tjoi2016&Heoi2016] 求和 —— 第二类斯特林数+NTT
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4555 关于第二类斯特林数:https://www.cnblogs.com/Wuweizhen ...
- 面向对象(this关键字)
package com_package2; public class Person3 { private int age; private String name; public int getAge ...
- windows 代理无法设置上不了网的解决
--- title:windows 代理无法设置的解决 date: 2018-09-12 14:07:04 tags: windows 上网 --- ## 问题描述 Internet 属性 -> ...
- 《SpringBoot揭秘 快速构建微服务体系》读后感(二)
最简单的springBoot应用 package com.louis.test; import org.springframework.boot.SpringApplication; import o ...
- Ubuntu下CodeBlocks更改调试终端
Ubuntu下CodeBlocks更改调试终端 Ubuntu下的CodeBlocks自带的调试终端xterm不能进行复制粘贴操作,更换调试终端就可以解决了,就是把ubuntu下的gnome-ter ...
- vb常用命名空间
摘自:http://www.2cto.com/kf/201211/170837.html 感谢 (一)如下是系统中分离出来Imports MicrosoftImports Microsoft.CSha ...
- docker-compose是个好东西,越用越香
回顾前文 前文演示了在单一容器中部署 Nginx和ASP.NET Core WebApp, 正在前文评论区某大牛指出的,容器化部署 nginx+ASP.NET Core 有更符合实战的部署选择:多容 ...