ddsdjn 发表于 2017-12-25 11:56:28

linux 下 apache相关;启动、停止、重启命令;配置文件位置等等

  Linux系统为Ubuntu
  一、Start Apache 2 Server /启动apache服务
  # /etc/init.d/apache2 start
  or
  $ sudo /etc/init.d/apache2 start
  二、 Restart Apache 2 Server/重启apache服务
  # /etc/init.d/apache2 restart
  or
  $ sudo /etc/init.d/apache2 restart
  三、Stop Apache 2 Server/停止apache服务
  # /etc/init.d/apache2 stop
  or
  $ sudo /etc/init.d/apache2 stop
  ======================================================================================================================================
  关于Ubuntu配置文件apache2 httpd.conf位置
关于ubuntu配置文件,严格地说Ubuntu的Apache(或者应该说Linux下的Apache?我不清楚其他发行版的 apache软件包)的配置文件是 /etc/apache2/apache2.conf,Apache在启动时会自动读取这个文件的配置信息。而其他的一些配置文件,如 httpd.conf等,则是通过Include指令包含进来。在apache2.conf中可以找到这些Include行:引用# Include module configuration:Include /etc/apache2/mods-enabled/*.loadInclude /etc/apache2/mods-enabled/*.conf # Include all the user configurations:Include /etc/apache2/httpd.conf# Include ports listingInclude /etc/apache2/ports.conf……# Include generic snippets of statements Include /etc/apache2/conf.d/# Include the virtual host configurations:Include /etc/apache2/sites-enabled/结合注释,可以很清楚地看出每个配置文件的大体作用。当然,你完全可以把所有的设置放在apache2.conf或者httpd.conf或者任何一个配置文件中。Apache2的这种划分只是一种比较好的习惯。  安装完Apache后的最重要的一件事就是要知道Web文档根目录在什么地方,对于Ubuntu而言,默认的是/var/www。怎么知道 的呢?apache2.conf里并没有DocumentRoot项,httpd.conf又是空的,因此肯定在其他的文件中。经过搜索,发现在 /etc /apache2/sites-enabled/000-default中,里面有这样的内容:
引用NameVirtualHost *<VirtualHost *>ServerAdmin webmaster @localhost DocumentRoot /var/www/这里是另一篇文章   http://blog.csdn.net/deepwishly/article/details/38266877  =========================================================================================
  修改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;
  只有默认的80端口才不需要手动输入,其他都要手动输入,貌似没有配置这个东西的地方
页: [1]
查看完整版本: linux 下 apache相关;启动、停止、重启命令;配置文件位置等等