创建 Nginx 服务器块:WordPress 失败

创建 Nginx 服务器块:WordPress 失败

安装 LEMP 后,我需要根据本教程配置 Nginx 服务器块:

https://www.itzgeek.com/how-tos/linux/ubuntu-how-tos/install-wordpress-with-nginx-and-lets-encrypt-ssl-on-ubuntu-22-04.html

如果我创建一个文件:

sudo nano /etc/nginx/sites-available/server.conf

server {
server_name server www.server;
root /var/www/html/server;
location / {
index index.html index.htm index.php;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

sudo mkdir /usr/share/nginx/html/www.server
echo "<?php phpinfo(); ?>" | sudo tee /usr/share/nginx/html/www.server/index.php
sudo systemctl restart nginx

我收到以下错误:nginx.service 的作业失败,因为控制进程以错误代码退出。有关详细信息,请参阅“systemctl status nginx.service”和“journalctl -xeu nginx.service”。

"systemctl status nginx.service"

返回者:

× nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2022-07-25 23:43:25 UTC; 25s ago
       Docs: man:nginx(8)
    Process: 35414 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
        CPU: 11ms

Jul 25 23:43:25 server1 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 25 23:43:25 server1 nginx[35414]: nginx: [emerg] open() "/etc/nginx/sites-enabled/server" failed (2: No such file or directory) in /etc/nginx/nginx.conf:60
Jul 25 23:43:25 server1 nginx[35414]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 25 23:43:25 server1 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jul 25 23:43:25 server1 systemd[1]: nginx.service: Failed with result 'exit-code'.
Jul 25 23:43:25 server1 systemd[1]: Failed to start A high performance web server and a reverse proxy server.

我反过来做了,并在里面创建了文件:/etc/nginx/conf.d/ 但是它返回了相同的错误,说上面设置的文件上没有文件。

它只在另一个教程中采用的更简单的设置下工作过一次: https://bytexd.com/how-to-install-wordpress-on-ubuntu-using-lemp-stack-nginx/

但是,我不确定使用 Let's Encrypt 安装 WordPress 是否正确。

当回到后者时:

现在,通过后面的教程,我遇到了冲突:

nginx: [warn] conflicting server name "www" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "server" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "server" on 0.0.0.0:80, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/usr/share/nginx/www.theapothecary.app/logs/access.log" failed (2: No such file or directory)
nginx: configuration file /etc/nginx/nginx.conf test failed

Could anyone please help?








答案1

以防万一有人遇到同样的问题。

本教程做到了。lemp=wp

我只需要用 mariadb 替换 mysql,其他所有步骤都经过测试:)

相关内容