Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've been fumbling through setting up redmine on a unbuntu (12.04) box and somewhere along the line NginX got set up and now apache no longer loads because nginx has already grabbed the port.

I tried removing NginX with the below command but that didn't seem to make any difference. When I restarted the server and pointed my web browser I still got the "Welcome to NginX" message

sudo apt-get purge nginx

I have confirmed that NginX is gone because when I run the above now I get as an output

Package nginx is not installed, so not removed

Yet everytime I start the machine it is running again. I noticed the following for the running processes (if that is helpful)

root       923  0.0  0.0  76784  1280 ?        Ss   03:00   0:00 nginx: master process /usr/sbin/nginx
www-data   925  0.0  0.0  77092  1704 ?        S    03:00   0:00 nginx: worker process
www-data   926  0.0  0.1  77092  2204 ?        S    03:00   0:00 nginx: worker process
www-data   927  0.0  0.0  77092  1704 ?        S    03:00   0:00 nginx: worker process
www-data   928  0.0  0.0  77092  1704 ?        S    03:00   0:00 nginx: worker process

Any advice for bringing back apache2 as the "default" (for lack of a better term) web server?

share|improve this question
2  
If nothing else, you can change /etc/nginx/nginx.conf to have it listen to a different port. –  ceejayoz Oct 16 '12 at 3:06
    
Excellent quick work around! –  paullb Oct 16 '12 at 3:22
add comment

4 Answers

up vote 6 down vote accepted

Depends on how you installed nginx.

If the procedure you used to install it, also installed valid rc scripts, then this will work:

sudo update-rc.d nginx disable

If this gives a output that makes sense, you won't have the problem on reboot.

If an upstart scripit was used, check inside /etc/init/nginx. You may have to change a variable inside this file to disable it.

If it is a source install and you don't know where or how you installed it, use find or locate.

To use locate, run: sudo updatedb

This will index all files for quick finding

Then run: locate nginx

This should give you a lost of nginx files you should (carefully) delete.

share|improve this answer
    
ooh, Reminds me how out of touch I am with old school init. I was thinking of this, then realised I didn't actually remember how to disable something that way. This would be the solution if its startup script related and ngnix dosen't use upstart –  Journeyman Geek Oct 16 '12 at 3:20
    
This worked for me. Thanks –  paullb Oct 16 '12 at 3:22
add comment

I would suggest also killing off the processes. Perhaps the removal process left some of the processes still running.

Obviously, a reboot should take care of this as well. But if you don't want to reboot, you need to manually kill them off since your purge removed the /etc/init.d/nginx script.

Run this from your command line:

kill $(pidof nginx)

It kills off all the nginx processes and should allow you to continue starting up Apache.

If THAT doesn't work, you need to determine what's got that port. You can do that with netstat -natp | grep 80.

That command will show a ':80' port reference in a 'LISTEN' status, along with the process that has that port open. You then kill that particular process off.

share|improve this answer
    
Thanks for your help. Killing ngxins (sudo service nginx stop) lets me run apache properly. However everytime I restart the machine it comes back (please see edits to original question) –  paullb Oct 16 '12 at 3:05
1  
Sounds like you ran some automated installer that downloaded and compiled nginx. All bets are off at this point unless you have access to a log file generated by the install process you ran. –  Magellan Oct 16 '12 at 3:11
    
That's pretty much what I thought. (It's a clean system with a lamp stack and then redmine) –  paullb Oct 16 '12 at 3:23
add comment

I'd guess you have a startup script somewhere that is doing it. Considering its Ubuntu 12.04, chances are its an upstart script (else its an init script, but we use both these days).

You can check to see if there's an upstart job starting ngnix with initctl list If so, you will find a task thats probably called ngnix. You can stop it with stop ngnix, then start apache manually.

Go to /etc/init and look for a file called ngnix.conf (startup scripts in upstart are jobname.conf) - rename it to something not ending with conf or delete it, then restart.

If there's no such file, go check /etc/init.d for the script that starts ngnix.

share|improve this answer
add comment

You should check which nginx package you have actually installed by running:

dpkg -l | grep nginx

In Debian and Ubuntu different nginx packages contain a different set of modules, e.g. you could have the package nginx-extras or nginx-fullinstalled, then you would need to run

aptitude purge nginx-full

nginx is a simple meta package that will install nginx-full as a dependency, but it doesn't need to be installed itself.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.