在Linux系统下,LNMP代表的是Nginx、MySQL、PHP这种网站服务器架构。以下是在LNMP中部署WordPress网站的步骤:
sudo apt update
sudo apt install nginx
sudo yum install epel-release
sudo yum install nginx
sudo apt install mysql-server
sudo yum install mariadb-server mariadb
sudo apt install php libapache2-mod-php php-mysql php-cli
sudo yum install php php-mysqlnd php-fpm php-cli
/usr/share/nginx/html
或/var/www/html
)。/etc/nginx/sites-available/default
),确保以下配置正确:server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
root /usr/share/nginx/html; # 或者 /var/www/html
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # 根据你的PHP版本调整
}
location ~ /\.ht {
deny all;
}
}
sudo systemctl restart nginx
sudo mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
wp-config-sample.php
文件重命名为wp-config.php
,并编辑该文件,填入数据库名称、用户名和密码:define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'yourpassword');
define('DB_HOST', 'localhost');
http://yourdomain.com
),按照屏幕上的说明完成WordPress的安装过程。以上步骤是在LNMP环境中部署WordPress的基本流程。在实际操作中,可能还需要进行一些额外的配置,例如设置SSL证书以实现HTTPS访问、配置邮件发送功能、优化数据库性能等。此外,确保所有软件和依赖都是最新版本,以获得更好的性能和安全性。