Question

Can't install PHP without errors...I believe this is preventing me from running scripts...Please help

root@scripts:~# sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
libapache2-mod-php is already the newest version (1:7.0+35ubuntu6).
php is already the newest version (1:7.0+35ubuntu6).
php-mysql is already the newest version (1:7.0+35ubuntu6).
php-mcrypt is already the newest version (1:7.0+35ubuntu6).
0 upgraded, 0 newly installed, 0 to remove and 8 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.2) ...
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-01-02 08:21:22 UTC; 25ms ago
  Process: 10001 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 9996 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

Jan 02 08:21:21 scripts nginx[10001]: nginx: [emerg] listen() to [::]:80, backlog 511 failed ...use)
Jan 02 08:21:21 scripts nginx[10001]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 fail...use)
Jan 02 08:21:21 scripts nginx[10001]: nginx: [emerg] listen() to [::]:80, backlog 511 failed ...use)
Jan 02 08:21:22 scripts nginx[10001]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 fail...use)
Jan 02 08:21:22 scripts nginx[10001]: nginx: [emerg] listen() to [::]:80, backlog 511 failed ...use)
Jan 02 08:21:22 scripts nginx[10001]: nginx: [emerg] still could not bind()
Jan 02 08:21:22 scripts systemd[1]: nginx.service: Control process exited, code=exited status=1
Jan 02 08:21:22 scripts systemd[1]: Failed to start A high performance web server and a rever...ver.
Jan 02 08:21:22 scripts systemd[1]: nginx.service: Unit entered failed state.
Jan 02 08:21:22 scripts systemd[1]: nginx.service: Failed with result 'exit-code'.
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.2) | nginx-full (>= 1.10.3-0ubuntu0.16.04.2) | nginx-light (>= 1.10.3-0ubuntu0.16.04.2) | nginx-extras (>= 1.10.3-0ubuntu0.16.04.2); 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.2.1~) | nginx-full (<< 1.10.3-0ubuntu0.16.04.2.1~) | nginx-light (<< 1.10.3-0ubuntu0.16.04.2.1~) | nginx-extras (<< 1.10.3-0ubuntu0.16.04.2.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)

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
May 16, 2023

Hello,

The error log you’ve provided indicates that Nginx failed to start because it couldn’t bind to it’s ports. The message listen() to [::]:80, backlog 511 failed (98: Address already in use) implies that there is another process already listening on port 80, which is the standard port for web servers.

You can use the netstat or ss tool to check which process is currently using port 80. Here’s how:

sudo netstat -tuln | grep :80

or

  1. sudo ss -tuln | grep :80

These commands will give you a list of processes that are using port 80. Look for the PID (Process ID) of the process that’s using port 80.

As said, it’s most probably Apache, to stop Apache, you can run

  1. sudo systemctl stop apache2
  2. sudo systemctl disable apache2

Then, you can proceed with the installation/starting of your Nginx service.

Ryan Quinn
DigitalOcean Employee
DigitalOcean Employee badge
February 2, 2018

You appear to be trying to install both Apache and Nginx on the same server. libapache2-mod-php is only used for Apache while your output indicates you are running nginx. To use php with nginx you’ll want to set up php-fpm. This guide will walk you through the process.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel