nginx 用户密码:

rks48beu  于 2023-01-12  发布在  Nginx
关注(0)|答案(1)|浏览(159)

我有一个nodejs后端托管在AWS EC2 Ubuntu 20.04示例上。
当我ssh到我的服务器时,一切都正常工作。今天我试着配置nginx,所以我website.com在sites-available里面创建了www.example.com文件。
website.com

server {
        listen 80;
        listen [::]:80;

         root /home/ubuntu/apps/yelp-app/client/build;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name api.website.com www.api.website.com;

        location / {
                try_files $uri /index.html;
        }

         location /api {
            proxy_pass http://localhost:3001;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }

}

保存该文件后,我运行了以下命令:

sudo ln -s /etc/nginx/sites-available/website.com /etc/nginx/sites-enabled/

从文档中,为了启用新站点,我需要使用以下命令重新启动nginx:

systemctl restart nginx

不幸的是,它一直要求输入ubuntu用户密码,而我从来没有设置过。
有人能帮我吗?
当我运行journalctl -xe -u nginx时,我得到的是:

-- Subject: A start job for unit nginx.service has begun execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit nginx.service has begun execution.
-- 
-- The job identifier is 23231.
Jan 11 12:44:45 ip-172-31-40-105 nginx[164236]: nginx: [emerg] a duplicate default server for 0.0.0.0:80 in >
Jan 11 12:44:45 ip-172-31-40-105 nginx[164236]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jan 11 12:44:45 ip-172-31-40-105 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FA>
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- An ExecStartPre= process belonging to unit nginx.service has exited.
-- 
-- The process' exit code is 'exited' and its exit status is 1.
Jan 11 12:44:45 ip-172-31-40-105 systemd[1]: nginx.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- The unit nginx.service has entered the 'failed' state with result 'exit-code'.
Jan 11 12:44:45 ip-172-31-40-105 systemd[1]: Failed to start A high performance web server and a reverse pro>
-- Subject: A start job for unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- A start job for unit nginx.service has finished with a failure.
-- 
-- The job identifier is 23231 and the job result is failed.
eivnm1vs

eivnm1vs1#

首先运行root,然后重新启动。

sudo su 
systemctl restart nginx

相关问题