centso7安装Wordpress
时间: 2024-11-09 22:20:10 浏览: 16
在CentOS 7上安装WordPress,您需要遵循以下步骤:
1. **更新系统**:
```sh
sudo yum update -y
sudo yum install epel-release -y # 安装EPEL仓库,提供额外的软件包
```
2. **安装必要软件**:
```sh
sudo yum install httpd php php-mysql MariaDB-server -y
```
3. **设置MySQL**:
- 首先启动MariaDB服务并设置自动启动:
```sh
sudo systemctl start mariadb
sudo systemctl enable mariadb
```
- 创建一个新的数据库用户和数据库:
```sql
sudo mysql -u root -p
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress_user'@'localhost' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
exit;
```
4. **下载和解压WordPress**:
```sh
wget https://wordpress.org/latest.tar.gz
tar -xvf latest.tar.gz
```
5. **配置WordPress**:
- 进入解压后的文件夹:
```sh
cd wordpress
```
- 创建wp-config.php文件:
```sh
cp wp-config-sample.php wp-config.php
nano wp-config.php
```
- 更新数据库连接信息,并保存文件。
6. **创建WordPress目录和文件权限**:
```sh
sudo mkdir /var/www/html/wordpress
sudo chown -R apache:apache /var/www/html/wordpress
```
7. **移动WordPress到Web根目录**:
```sh
sudo mv * /var/www/html/
rm -rf latest.tar.gz wp-config-sample.php
```
8. **启用Apache虚拟主机**:
编辑`httpd.conf`或`/etc/httpd/conf.d/vhosts.conf`,添加指向WordPress的新虚拟主机配置。示例:
```conf
<VirtualHost *:80>
ServerName your_wordpress_domain.com
DocumentRoot /var/www/html/wordpress
ErrorLog /var/log/httpd/wordpress_error.log
CustomLog /var/log/httpd/wordpress_access.log combined
</VirtualHost>
```
9. **重启Apache服务**:
```sh
sudo systemctl restart httpd
```
10. **访问WordPress安装向导**:
使用浏览器访问 `http://your_wordpress_domain.com` ,按照向导完成WordPress的初始设置。
阅读全文