i am getting error when i try to install nginx on ubuntu azure vm

Salman 21 Reputation points
2021-07-04T16:31:29.247+00:00

Hi there,
I am a new to this field. I am getting an error when i try to install nginx on ubuntu using azure VM.
when i try to see the status of nginx using "systemctl status nginx"
i am getting this

● 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 Sun 2021-07-04 16:21:44 UTC; 15s ago
Docs: man:nginx(8)
Process: 3182 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 3191 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Jul 04 16:21:42 nginx nginx[3191]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 04 16:21:42 nginx nginx[3191]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jul 04 16:21:43 nginx nginx[3191]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 04 16:21:43 nginx nginx[3191]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jul 04 16:21:43 nginx nginx[3191]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Jul 04 16:21:43 nginx nginx[3191]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Jul 04 16:21:44 nginx nginx[3191]: nginx: [emerg] still could not bind()
Jul 04 16:21:44 nginx systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jul 04 16:21:44 nginx systemd[1]: nginx.service: Failed with result 'exit-code'.
Jul 04 16:21:44 nginx systemd[1]: Failed to start A high performance web server and a reverse proxy server.

Please help me to fix this issue

Thanks in advance

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,111 questions
0 comments No comments
{count} votes

Accepted answer
  1. Arman ali 86 Reputation points
    2021-07-04T16:54:58.377+00:00

    Hello,

    As I see your Nginx status it seems port 80 is already being used by another software ( most probably apache ).
    In this case, first, you have to remove the apache from your server then try to install Nginx on your server.

    First, use these commands to remove the apache

    sudo apt remove apache2
    

    then use this command to auto-remove unnecessary things
    sudo apt autoremove
    and then you can try to install nginx on your ubuntu machine.

    or if you already installed use this command to start the nginx .

    sudo systemctl start nginx
    

    and now check the nginx status by using this command:

    sudo systemctl status nginx
    

    I hope this will help you.

    2 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful