LAMP 环境搭建

1
2
3
4
5
6
7
8
9
apt-get update && apt-get upgrade

apt-get install apache2 mysql-server php5 php5-mysql

a2enmod ssl

cp 000-default.conf [your.domain].conf

a2ensite [your.domain].conf

Let’s Encrypt 证书配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 添加源
deb http://ftp.debian.org/debian jessie-backports main

# 安装 certbot
apt-get install python-certbot-apache -t jessie-backports

# 启用 headers 模块
a2enmod headers

# 获取证书
certbot --apache -d [your.domain] -d www.[your.domain]

# 测试自动续期
certbot renew --dry-run

# 检查版本
apache2 -v
openssl version

WordPress 安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 下载 WordPress
wget https://cn.wordpress.org/wordpress-4.7.2-zh_CN.tar.gz

# 解压
tar -zvxf wordpress-4.7.2-zh_CN.tar.gz

cd wordpress

# 复制配置文件
cp wp-config-sample.php wp-config.php

# 启用 rewrite 模块
a2enmod rewrite

# 设置权限
chown www-data:www-data -R ../www
chmod -R 755 www

# 检查端口
netstat -tunlp

vi ports.conf

配置系统环境

1
2
3
4
5
6
7
8
# 配置语言环境
dpkg-reconfigure locales

# 配置时区
dpkg-reconfigure tzdata

# MySQL 安全配置
mysql_secure_installation

创建 MySQL 数据库和用户

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-- 创建数据库
CREATE DATABASE `[db_name]` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

-- 创建用户
CREATE USER [user]@localhost;

-- 设置密码
SET PASSWORD FOR [user]@localhost= PASSWORD("[password]");

-- 或者直接创建用户并设置密码
CREATE USER [wp_user]@localhost IDENTIFIED BY '[password]';

-- 授予权限
GRANT ALL PRIVILEGES ON [db_name].* TO [wp_user]@localhost IDENTIFIED BY '[password]';

-- 刷新权限
FLUSH PRIVILEGES;

设置定时计划

用于自动更新 Let’s Encrypt 证书:

1
apt-get install cron