-1

I am getting the following error while trying to install nginx.

I have hosted a reactjs app on the machine and intend to setup reverse proxy with nginx

Reading package lists... Done
Building dependency tree
Reading state information... Done
nginx is already the newest version (1.10.3-0ubuntu0.16.04.3).
The following packages were automatically installed and are no longer required:
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 22 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up nginx-core (1.10.3-0ubuntu0.16.04.3) ...
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
● 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 Tue 2018-12-18 13:41:07 IST; 4ms ago
  Process: 10014 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Dec 18 13:41:07 -systemd[1]: Starting A high performance web s....
Dec 18 13:41:07  nginx[10014]: nginx: [emerg] unknown directiv...8
Dec 18 13:41:07  nginx[10014]: nginx: configuration file /etc/...d
Dec 18 13:41:07  systemd[1]: nginx.service: Control process ex...1
Dec 18 13:41:07  systemd[1]: Failed to start A high performanc....
Dec 18 13:41:07  systemd[1]: nginx.service: Unit entered faile....
Dec 18 13:41:07  systemd[1]: nginx.service: Failed with result....
Hint: Some lines were ellipsized, use -l to show in full.
dpkg: error processing package nginx-core (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
 nginx depends on nginx-core (>= 1.10.3-0ubuntu0.16.04.3) | nginx-full (>= 1.10.3-0ubuntu0.16.04.3) | nginx-light (>= 1.10.3-0ubuntu0.16.04.3) | nginx-extras (>= 1.10.3-0ubuntu0.16.04.3); however:
  Package nginx-core is not configured yet.
  Package nginx-full is not installed.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.
 nginx depends on nginx-core (<< 1.10.3-0ubuntu0.16.04.3.1~) | nginx-full (<< 1.10.3-0ubuntu0.16.04.3.1~) | nginx-light (<< 1.10.3-0ubuntu0.16.04.3.1~) | nginx-extras (<< 1.10.3-0ubuntu0.16.04.3.1~); however:
  Package nginx-core is not configured yet.
  Package nginx-full is not installed.
  Package nginx-light is not installed.
  Package nginx-extras is not installed.

dpkg: error processing package nginx (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          Errors were encountered while processing:
 nginx-core
 nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)
SID
  • 13
  • 2
  • 1
    Where's the rest of the messages? – Michael Hampton Dec 14 '18 at 13:40
  • Thanks for adding the error messages! The important bit there is the line that says `[emerg] unknown directiv....`. That tells us that something's wrong with the nginx configuration. You should be able to get more information by running `journalctl -l` or by looking in `/var/log/messages` or `/var/log/nginx/error_log`. Please include those as well, and I think someone will be able to help you! – Jenny D Dec 18 '18 at 11:29
  • @JennyD thanks a lot for the input. I found the issue in error_log of nginx and learned there was a typo in the default file, I fixed it & everything works. I am relatively new to managing my own servers. Thanks a ton for your reply. – SID Dec 18 '18 at 13:49
  • I'm glad it worked! If you've got the time, it would be kind if you could add both the issue you found and the solution to the question.Then someone else with the same problem can find the answer here. (You can answer your own question here, it's even encouraged when you find the solution!) – Jenny D Dec 18 '18 at 13:53

1 Answers1

1

Few suggestions: Make sure no other web server is running before installation. Uninstall Nginx including configuration files. Install Nginx from the official Nginx repository although you don't have to.

jwalker
  • 98
  • 7
  • 1
    The first issue was that Nodejs machine on Lightsail has preconfigred Apache Server running at port 80. The Second Issue was a typo mistake in default file at /etc/nginx/sites_enabled Went through the error logs of nginx at /var/log/nginx/error_log and it clearly stated the typo, fixed it & voila . Everything works. :) Thanks @jwalker & JennyD for the solution. – SID Dec 18 '18 at 13:58