简体   繁体   English

如何在ubuntu上停止apache服务器

[英]How to stop an apache server on ubuntu

I'm trying to set up my django project to use nginx as its webserver on an EC2 Ubuntu instance following http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html . 我正在尝试设置我的django项目,以便在http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html之后的EC2 Ubuntu实例上使用nginx作为其网络服务器。 As part of this I need to install/test if nginx is active with: 作为其中的一部分,我需要安装/测试nginx是否处于活动状态:

sudo apt-get install nginx
sudo /etc/init.d/nginx start    # start nginx

then surfing to it my amazon dns at port 80. 然后在80号港口冲浪我的亚马逊dns。

When I do this and cause an error I see: 当我这样做并导致错误时,我看到:

mod_wsgi.listener_port      

'80'    

mod_wsgi.listener_host      

''    

CONTEXT_DOCUMENT_ROOT       

'/var/www/html'    

SERVER_SOFTWARE       

'Apache/2.4.7 (Ubuntu)'    

SCRIPT_NAME       

u''    

mod_wsgi.enable_sendfile      

'0'    

mod_wsgi.handler_script       

''    

SERVER_SIGNATURE      

'<address>Apache/2.4.7 (Ubuntu) Server at ec2-**-**.us-west-2.compute.amazonaws.com Port 80</address>\n'    

REQUEST_METHOD      

'GET'    

PATH_INFO       

u'/index'    

SERVER_PROTOCOL       

'HTTP/1.1'    

QUERY_STRING      

''    

HTTP_USER_AGENT       

'Mozilla/5.0 (Windows NT 6.1; rv:35.0) Gecko/20100101 Firefox/35.0'    

HTTP_CONNECTION       

'keep-alive'    

SERVER_NAME       

'ec2-**-**.us-west-2.compute.amazonaws.com'    

REMOTE_ADDR       

'107.0.193.131'    

mod_wsgi.request_handler      

'wsgi-script'    

wsgi.url_scheme       

'http'    

PATH_TRANSLATED       

'/home/ubuntu/tproxy/tp/tp/wsgi.py/index'    

SERVER_PORT       

'80'    

wsgi.multiprocess       

True    

mod_wsgi.input_chunked      

'0'    

SERVER_ADDR       

'172.31.28.196'    

DOCUMENT_ROOT       

'/var/www/html'    

mod_wsgi.process_group      

''    

SCRIPT_FILENAME       

'/home/ubuntu/tproxy/tp/tp/wsgi.py'    

SERVER_ADMIN      

'webmaster@localhost'    

wsgi.input      

<mod_wsgi.Input object at 0x7fdd5e046af0>    

HTTP_HOST       

'ec2-**-**.us-west-2.compute.amazonaws.com'

So obviously a running apache 2 server. 所以很明显是一个运行的apache 2服务器。 following http://httpd.apache.org/docs/2.2/stopping.html , I tried: http://httpd.apache.org/docs/2.2/stopping.html之后 ,我试过:

(env1)ubuntu@ip-172-31-28-196:~/tproxy/tp$ apachectl -k stop
httpd (pid 1132?) not running

This did not work. 这没用。 How can I shut off the apache server? 如何关闭apache服务器?

I've always done it with 我一直都是这样做的

sudo apachectl stop

However that won't stop it from starting again at boot time. 但是,这不会阻止它在启动时再次启动。 Also there may be some sort of supervisor script that will re-launch the service if it notices that it's been stopped. 此外,可能存在某种管理程序脚本,如果它注意到它已被停止,它将重新启动该服务。

There are a couple things you should look at. 你应该看几件事。 First find out what is actually running on port 80 using a command like this. 首先使用这样的命令找出端口80上实际运行的内容。

lsof -i -P | grep :80

Whatever is running on port 80 will come back with a PID looking like this 无论在端口80上运行什么,都会返回一个看起来像这样的PID

httpd  1046  apache2 10u  IPv4  5203  0t0  TCP  xxx.xxx.xxx.xxx:80 (LISTEN)

That is what you want to kill. 这就是你要杀的东西。

Lastly if all else fails you can try to send a Kill TERM sig to the Parent by using the pidFile approach as follows. 最后,如果所有其他方法都失败了,您可以尝试使用pidFile方法向父节点发送Kill TERM sig,如下所示。

kill -TERM `cat /usr/local/apache2/logs/httpd.pid`

This will kill off all children and then the Parent will exit. 这将杀死所有孩子,然后家长将退出。 If you kill off child httpd processes you will see new httpd processes come back because the parent is still active. 如果您终止子httpd进程,您将看到新的httpd进程返回,因为父进程仍处于活动状态。

sudo service apache2 stop

请再次参考此链接 ,谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Apache服务器上运行cakephp应用程序? [UBUNTU] - How to run a cakephp app on an apache server? [UBUNTU] 如何通过ssh检查ubuntu服务器上php和apache的存在 - How to check the presence of php and apache on ubuntu server through ssh Lua与Linux(Ubuntu Server)上的Apache错误? - Lua with Apache on Linux (Ubuntu Server) errors? 更新后Ubuntu服务器错误与Apache一致 - After update Ubuntu server error accord with apache Apache2:托管多个站点(Ubuntu 服务器 - Apache2: Hosting Multiple Sites (Ubuntu Server 笔记本电脑在ubuntu服务器上的Apache子域 - Apache subdomains on ubuntu server from laptop 如何在Ubuntu Linux上启动和停止基于Apple的Swift生产服务器(由我编写的程序)? - How to start and stop the Apple's Swift based productive server (program written by me) on Ubuntu linux? 如何在Ubuntu服务器上设置权限以允许Apache用户和第二个用户写入Web目录? - How to set permissions on Ubuntu server to allow Apache user and second user to write to web directory? 如何在Ubuntu上正确启动/停止CouchDB 2.0 - How to properly start/stop CouchDB 2.0 on Ubuntu ubuntu服务器管道在第一次退出时停止进程终止 - ubuntu server pipeline stop process termination when the first exit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM