nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
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; 根据你的PHP版本调整
}
location ~ /\.ht {
deny all;
}
}
重启Nginx服务以应用更改:
bash
sudo systemctl restart nginx
4、配置数据库(如果需要)
如果你的网站使用数据库,你需要创建一个数据库并导入数据。
创建数据库
使用MySQL命令行工具:
bash
sudo mysql -u root -p
然后执行以下SQL语句:
sql
CREATE DATABASE your_database_name;
CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_username'@'localhost';
FLUSH PRIVILEGES;
EXIT;
导入数据
如果你有SQL备份文件,可以使用以下命令导入数据:
bash
mysql -u your_username -p your_database_name < path_to_your_backup.sql