Update from Sync Service
This commit is contained in:
@@ -1,2 +1,165 @@
|
||||
**阿里云下Ubuntu16下LAMP+wordpress建站记录**
|
||||
> 来自 <[http://blog.csdn.net/code12hour/article/details/63691403](http://blog.csdn.net/code12hour/article/details/63691403)>
|
||||
# 阿里云搭建 WordPress
|
||||
|
||||
> Ubuntu 16.04 + LAMP 搭建 WordPress 博客
|
||||
|
||||
---
|
||||
|
||||
## 准备工作
|
||||
|
||||
```bash
|
||||
# 更新系统
|
||||
sudo apt-get update && sudo apt-get upgrade -y
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 安装 LAMP
|
||||
|
||||
### 1. 安装 Apache
|
||||
|
||||
```bash
|
||||
sudo apt-get install apache2 -y
|
||||
sudo systemctl start apache2
|
||||
sudo systemctl enable apache2
|
||||
```
|
||||
|
||||
测试:`http://服务器IP` 应看到 Apache 页面。
|
||||
|
||||
### 2. 安装 MySQL
|
||||
|
||||
```bash
|
||||
sudo apt-get install mysql-server -y
|
||||
|
||||
# 安全配置
|
||||
sudo mysql_secure_installation
|
||||
```
|
||||
|
||||
### 3. 安装 PHP
|
||||
|
||||
```bash
|
||||
sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 -y
|
||||
```
|
||||
|
||||
### 4. 安装 PHP 组件
|
||||
|
||||
```bash
|
||||
sudo apt-get install php7.0-gd php7.0-mbstring php7.0-xml php7.0-curl -y
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 配置 WordPress
|
||||
|
||||
### 1. 下载 WordPress
|
||||
|
||||
```bash
|
||||
cd /tmp
|
||||
wget https://cn.wordpress.org/wordpress-6.0-zh_CN.tar.gz
|
||||
tar -xzf wordpress-6.0-zh_CN.tar.gz
|
||||
sudo mv wordpress /var/www/html/
|
||||
```
|
||||
|
||||
### 2. 设置权限
|
||||
|
||||
```bash
|
||||
sudo chown -R www-data:www-data /var/www/html/wordpress
|
||||
sudo chmod -R 755 /var/www/html/wordpress
|
||||
```
|
||||
|
||||
### 3. 创建数据库
|
||||
|
||||
```bash
|
||||
sudo mysql -u root -p
|
||||
|
||||
# 在 MySQL 中执行:
|
||||
CREATE DATABASE wordpress;
|
||||
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY '你的密码';
|
||||
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
EXIT;
|
||||
```
|
||||
|
||||
### 4. 配置 WordPress
|
||||
|
||||
```bash
|
||||
cd /var/www/html/wordpress
|
||||
sudo cp wp-config-sample.php wp-config.php
|
||||
sudo vim wp-config.php
|
||||
```
|
||||
|
||||
修改数据库连接信息:
|
||||
```php
|
||||
define('DB_NAME', 'wordpress');
|
||||
define('DB_USER', 'wpuser');
|
||||
define('DB_PASSWORD', '你的密码');
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 配置 Apache
|
||||
|
||||
### 虚拟主机
|
||||
|
||||
```bash
|
||||
sudo vim /etc/apache2/sites-available/wordpress.conf
|
||||
```
|
||||
|
||||
写入:
|
||||
```apache
|
||||
<VirtualHost *:80>
|
||||
ServerName yourdomain.com
|
||||
DocumentRoot /var/www/html/wordpress
|
||||
|
||||
<Directory /var/www/html/wordpress>
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
### 启用站点
|
||||
|
||||
```bash
|
||||
sudo a2ensite wordpress.conf
|
||||
sudo a2enmod rewrite
|
||||
sudo systemctl restart apache2
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 完成安装
|
||||
|
||||
浏览器访问:`http://服务器IP/wordpress`
|
||||
|
||||
按提示填写:
|
||||
- 网站标题
|
||||
- 用户名
|
||||
- 密码
|
||||
- 邮箱
|
||||
|
||||
---
|
||||
|
||||
## 常用命令
|
||||
|
||||
```bash
|
||||
# 重启 Apache
|
||||
sudo systemctl restart apache2
|
||||
|
||||
# 查看 WordPress 目录
|
||||
ls -la /var/www/html/wordpress/
|
||||
|
||||
# 更新 WordPress(通过 Web 界面)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 安全建议
|
||||
|
||||
1. 修改 WordPress 数据库前缀(默认 `wp_`)
|
||||
2. 安装 SSL 证书启用 HTTPS
|
||||
3. 定期备份数据库和文件
|
||||
4. 设置强密码
|
||||
|
||||
---
|
||||
|
||||
> 参考:[CSDN - LAMP+WordPress 建站](http://blog.csdn.net/code12hour/article/details/63691403)
|
||||
|
||||
Reference in New Issue
Block a user