Search code examples
linuxnginxsystemdubuntu-18.04

Problem with nginx install, no idea how to fix


I'm trying to install a nginx server on my laptop (Ubuntu 18.04), for my website.

I followed a tutorial, and it was working well, then I tried to make some modification on website, and there were some errors (it was about my GitHub repository I was trying to clone on /var/www/html, not nginx).

For fixing it, I stopped nginx with SIGKILL on all PID's.

Then I have no idea why but there were some problems, and I removed the /etc/nginx repo (Yes, it was really a bad idea, I know...)

When I try to restart/start nginx now, I get this error :

Job for nginx.service failed because the control process exited with error code.

See "systemctl status nginx.service" and "journalctl -xe" for 
details.

I tried many things I found on internet but it always refers to the configuration file that I deleted.

Is there a way to completely remove nginx from my computer and re-install it properly? I think it's the best option; or a way to fix it, if you know that?


Solution

  • re-installing nginx

    Is there a way to completely remove nginx from my computer and re-install it properly? I think it's the best option. Or a way to fix it, if you know that?

    To remove and re-install the nginx (virtual) package, you can use apt on Ubuntu (being a Debian derivative):

    apt remove -y nginx
    
    apt install -y nginx
    

    analyzing service failure

    Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

    You may consider issuing:

    journalctl -u nginx
    

    to see the exact reason for the error.

    -u stands for and accept the name of a unit and .service suffix can be omitted being the default type for units.

    copying configuration files

    You can clone the nginx source package upstream nginx repository on Debian Salsa as:

    git clone git://salsa.debian.org/nginx-team/nginx
    

    and copy over the conf/ directory contents to /etc/nginx with:

    cp -rv nginx/conf/* /etc/nginx/
    

    -r is for recursive (subdirectories, if any) copy and -v is for verbosity (output of copied files on console screen)