我之前已经安装了Apache2,现在当我尝试再次运行它时,它不会。
我的Apache2设置是:
jatin@jatin-ubuntu:/var/run$ apache2 -V Server version: Apache/2.2.14 (Ubuntu) Server built: Nov 18 2010 21:17:19 Server's Module Magic Number: 20051115:23 Server loaded: APR 1.3.8, APR-Util 1.3.9 Compiled using: APR 1.3.8, APR-Util 1.3.9 Architecture: 32-bit Server MPM: Prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="" -D SUEXEC_BIN="/usr/lib/apache2/suexec" -D DEFAULT_PIDLOG="/var/run/apache2.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types" -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"
当我这样做时,出现以下错误:
jatin@jatin-ubuntu:/var/run$ httpd status No command 'httpd' found, did you mean: Command 'dhttpd' from package 'dhttpd' (universe) Command 'xttpd' from package 'xtide' (universe) Command 'thttpd' from package 'thttpd' (universe) httpd: command not found
我的/etc/apache2/ports.conf
如下所示:
# If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default # This is also true if you have upgraded from before 2.2.9-3 (ie from # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and # README.Debian.gz #NameVirtualHost *:80 Listen 80 #<IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. # Listen 443 #</IfModule> #<IfModule mod_gnutls.c> # Listen 443 #</IfModule>
我的sites-available
目录有这两个文件:
jatin@jatin-ubuntu:/etc/apache2$ cd sites-available/ jatin@jatin-ubuntu:/etc/apache2/sites-available$ ls default default-ssl
当我查看sites-enabled
目录时,它没有任何内容:
jatin@jatin-ubuntu:/etc/apache2/sites-available$ cd ../sites-enabled/ jatin@jatin-ubuntu:/etc/apache2/sites-enabled$ ls
我的/var/log/apache2/error.log文件显示了这一点:
[Sat Mar 26 17:54:08 2011] [error] [client 127.0.0.1] File does not exist: /htdocs [Sat Mar 26 17:54:15 2011] [error] [client 127.0.0.1] File does not exist: /htdocs [Sat Mar 26 17:54:23 2011] [notice] caught SIGTERM, shutting down [Sat Mar 26 17:54:26 2011] [notice] Apache/2.2.14 (Ubuntu) DAV/2 SVN/1.6.6 configured -- resuming normal operations
我在网上读到,这已经做了一些与服务器根没有正确设置,因此它寻找/ htdocs文件夹。
问题:
httpd status
不显示任何内容? ports.conf
文件中是否正确? Listen
只有一行没有注释。 sudo /etc/init.d/apache2 restart/stop/start
一切正常,但打开http://localhost/
或http://localhost:80/
或http://localhost:8080/
??? 因为你没有安装httpd
。 也许你的意思是/etc/init.d/httpd status
? Ubuntu系统上的等效命令是/etc/init.d/apache2 status
。
如果你只是要运行一个网站,那么它应该没问题。 如果你想让更多的网站作为虚拟主机运行,你还需要取消对NameVirtualHost
注释。
当你使用a2ensite命令来启用一个站点时,它们会被创build
a2ensite default
将通过创build链接启用默认网站。
sudo /etc/init.d/apache2 restart/stop/start
一切工作正常… 看看你的问题中的错误信息,他们会表示你没有看到任何东西。 您将看到一个404 Not Found错误消息。 这是因为您没有启用任何网站。
我怀疑你的意思是DocumentRoot ,如果没有configurationDocumentRoot ,那么Apache默认为/ htdocs。 使用上面的命令启用一个站点,看看会发生什么。 你应该得到一个信息,说“ 它工作 …”
我记得有一段时间服务回来抱怨说,“嘿,这将不会在未来工作 – 你应该使用服务的东西停止/启动/重新启动”
我以为这是Apache,但是当我跑时:
sudo /etc/init.d/apache2 restart
它今天没有给出这个警告信息,但我认为你也可以这样做
sudo service apache2 restart
我会检查/ etc / apache2 / sites-available / default,并确保文档根目录设置为:
DocumentRoot /var/www
你使用tasksel安装Apache还是在安装过程中?