apache start, stop, restart command under linux
Basic operation method:
This article assumes that your apahce installation directory is /usr/local/apache2, these methods are suitable for any situation
apahce start command:
recommended /usr/local/apache2/bin/apachectl start apaceh start
apache stop command
/usr/local/apache2/bin/apachectl stop stop
apache restart command:
/usr/local/apache2/bin/apachectl restart restart
To restart the Apache server without interrupting current connections, you should run:
/usr/local/sbin/apachectl graceful
If apache is installed as a linux service, you can use the following command to operate:
service httpd start start
service httpd restart restart
service httpd stop stop the service
Linux system is Ubuntu
1. Start Apache 2 Server / start apache service
# /etc/init.d/apache2 start
or
$ sudo /etc/init.d/apache2 start
2. Restart Apache 2 Server / restart apache service
# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart
3. Stop Apache 2 Server / stop apache service
# /etc/init.d/apache2 stop
or
$ sudo /etc/init.d/apache2 stop
======================================================================================================================================
关于Ubuntu配置文件apache2 httpd.conf位置
安装完Apache后的最重要的一件事就是要知道Web文档根目录在什么地方,对于Ubuntu而言,默认的是/var/www。怎么知道 的呢?apache2.conf里并没有DocumentRoot项,httpd.conf又是空的,因此肯定在其他的文件中。经过搜索,发现在 /etc /apache2/sites-enabled/000-default中,里面有这样的内容:
=========================================================================================
修改ubuntu下apache默认端口
ths@ths:/etc/apache2$ sudo vi ports.conf 这里修改2个地方
ths@ths:/etc/apache2/sites-enabled$ sudo vi 000-default 这里面修改该一个地方。然后别忘了 重启apache服务器。修改了端口之后需要手动在localhost后加上端口号,e.g: localhost:8080;