Update from Sync Service

This commit is contained in:
FNS Service
2026-04-21 20:33:24 +08:00
parent 10cf64e83b
commit 909857f835
4 changed files with 530 additions and 95 deletions

View File

@@ -1,82 +1,142 @@
WordPress的安装与配置
下载wordpress
[plain] view plain copy
# 阿里云管理 WordPress
> WordPress 安装与配置
---
## 下载并安装
```bash
# 下载 WordPress
wget https://wordpress.org/latest.zip
安装unzip:
[plain] view plain copy
# 安装解压工具
apt-get install unzip
解压和后续操作
[plain] view plain copy
# 解压到网站目录
unzip -q latest.zip -d /var/www/html/
cd /var/www/html/wordpress
# 移动文件到根目录
cp -a * ..
rm -r wordpress/
rm -rf wordpress/
# 设置权限
chown www-data:www-data -R /var/www/html/
创建上传目录:
[plain] view plain copy
```
---
## 创建上传目录
```bash
mkdir -p /var/www/html/wp-content/uploads
chown www-data:www-data -R /var/www/html/wp-content/uploads
mysql相关操作
创建mysql账户
[plain] view plain copy
mysql -u root -p
[sql] view plain copy
```sql
CREATE DATABASE wordpress character set utf8 collate utf8_bin;
```
GRANT ALL PRIVILEGES on wordpress.* to 'wpuser'@'localhost' identified by 'your_password';
FLUSH PRIVILEGES;
exit
编辑配置文件
[plain] view plain copy
---
## 创建数据库
```bash
mysql -u root -p
```
```sql
CREATE DATABASE wordpress CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost' IDENTIFIED BY '你的密码';
FLUSH PRIVILEGES;
EXIT;
```
---
## 配置 WordPress
```bash
cd /var/www/html
mv wp-config-sample.php wp-config.php
vim wp-config.php
[plain] view plain copy
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress'); /** MySQL database username */
define('DB_USER', 'wpuser'); /** MySQL database password */
define('DB_PASSWORD', 'your_password'); /** MySQL hostname */
define('DB_HOST', 'localhost');
```
设置固定链接:
如果是设置了虚拟主机的话这部分可能和下面的操作不一样我也不太清楚可以去google搜一下
[plain] view plain copy
vim /etc/apache2/sites-available/000-default.conf
[plain] view plain copy
[...]
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName server1.example.com
修改数据库连接:
```php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wpuser');
define('DB_PASSWORD', '你的密码');
define('DB_HOST', 'localhost');
```
---
## 配置固定链接
### 1. 修改 Apache 配置
```bash
sudo vim /etc/apache2/sites-available/000-default.conf
```
添加:
```apache
<Directory /var/www/html/>
AllowOverride All
AllowOverride All
</Directory>
[...]
就是在里面添加上ServerName到</Directory>这一段
允许URL的重写以及Apache2的重启
[plain] view plain copy
a2enmod rewrite
service apache2 restart
创建.htaccess文件
[plain] view plain copy
```
### 2. 启用 rewrite 模块并重启
```bash
sudo a2enmod rewrite
sudo systemctl restart apache2
```
### 3. 创建 .htaccess
```bash
touch /var/www/html/.htaccess
chown :www-data /var/www/html/.htaccess
chmod 664 /var/www/html/.htaccess
```
添加wordpress安全保护其实我也不太懂具体作用
访问 https://api.wordpress.org/secret-key/1.1/salt/
然后打开wp-config.php
[plain] view plain copy
vim /var/www/html/wp-config.php
[plain] view plain copy
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
---
## 安全密钥
访问https://api.wordpress.org/secret-key/1.1/salt/
复制生成的密钥,添加到 `wp-config.php`
```php
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
将其对应填入。
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
```
---
## 常用命令
```bash
# 重启 Apache
sudo systemctl restart apache2
# 查看 WordPress 文件
ls -la /var/www/html/
# 更新权限
sudo chown -R www-data:www-data /var/www/html/
```
---
## 访问 WordPress
浏览器打开:`http://服务器IP`
按提示完成安装即可。