使用LNMP(Linux, Nginx, MySQL, PHP)部署WordPress是一个相对简单的过程,以下是详细的步骤:
安装Nginx:
sudo apt-get update
sudo apt-get install nginx
安装MySQL:
sudo apt-get install mysql-server
安装PHP:
sudo apt-get install php-fpm php-mysql
编辑Nginx配置文件:
sudo vim /etc/nginx/sites-available/default
配置示例:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
重启Nginx:
sudo systemctl restart nginx
下载WordPress:
cd /var/www/html
sudo wget https://cn.wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz
配置WordPress:
/var/www/html/wp-config.php
文件,设置数据库信息:sudo vim /var/www/html/wp-config.php
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASSWORD', 'your_database_password');
define('DB_HOST', 'localhost');
创建数据库和用户(如果尚未创建):
sudo mysql -u root -p
在MySQL shell中执行:
CREATE DATABASE your_database_name;
CREATE USER 'your_database_user'@'localhost' IDENTIFIED BY 'your_database_password';
GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_database_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
通过以上步骤,你就可以成功在LNMP环境下部署WordPress网站了。如果在操作过程中遇到问题,可以参考相关的技术文档或寻求专业人士的帮助。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:LNMP如何部署WordPress