简体   繁体   English

Web浏览器不在htdocs目录中显示index.html - Apache

[英]Web browser not displaying the index.html in the htdocs directory - Apache

The installation path of my Apache web server is /usr/local/apache2 . 我的Apache Web服务器的安装路径是/usr/local/apache2

I start the server using a apachectl start command and when i type localhost in my Web Browser it displays a Apache 2 Test Page powered by CentOS and not the index.html in /usr/local/apache2/htdocs . 我使用apachectl start命令启动服务器,当我在Web浏览器中键入localhost ,它显示由CentOS驱动Apache 2测试页,而不是/usr/local/apache2/htdocsindex.html Does any one know the reason for this? 有人知道这个的原因吗?

Also there are two conf.d files in my system. 我的系统中还有两个conf.d文件。 One is in /etc/httpd/conf and other one is in /usr/local/apache2/conf (where i installed Apache). 一个在/etc/httpd/conf ,另一个在/usr/local/apache2/conf (我安装了Apache)。 Any reasons for this? 有什么理由吗? Please help 请帮忙

Firstly, I'm guessing you have built apache from source - was there a specific reason for doing this? 首先,我猜你已经从源代码构建了apache - 有没有具体的理由这样做? I usually find systems are a lot more manageable if you use the standard distribution packages or use new packages from other repos if you need later versions. 如果您使用标准分发包,或者如果您需要更高版本,则使用其他repos中的新包,我通常会发现系统更易于管理。

If you don't have a specific need for using locally-built apache, I'd recommend removing it then installing apache using the normal CentOS repositories. 如果您没有使用本地构建的apache的特定需求,我建议删除它,然后使用普通的CentOS存储库安装apache。

Next (or first, if you are staying with the locally-built apache), run: httpd -V 接下来(或者首先,如果你继续使用本地构建的apache),运行: httpd -V

For example, one of my systems returns: 例如,我的一个系统返回:

[me@here ~]# httpd -V
Server version: Apache/2.2.3
Server built:   Jun  6 2012 10:00:36
Server's Module Magic Number: 20051115:3
Server loaded:  APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
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="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

The output will tell you where its true config file is, in this case /etc/httpd/conf/httpd.conf - that way you'll know which config is the one actually being used. 输出将告诉您其真实配置文件的位置,在本例中为/etc/httpd/conf/httpd.conf - 这样您就可以知道哪个配置是实际使用的配置。

Once you know which config files are being used, you can check them to see where the document root is - it might be in /var/www/html/ instead of /usr/local/apache2/htdocs or just about anywhere. 一旦你知道正在使用哪些配置文件,你可以检查它们以查看文档根目录的位置 - 它可能位于/var/www/html/而不是/usr/local/apache2/htdocs或几乎任何地方。

When you know where the document root is, then check and make sure the files and directories are readable by apache (or whatever user apache is running as - the first column from ps aux | grep httpd will tell you that) 当您知道文档根目录的位置时,请检查并确保apache可以读取文件和目录(或者正在运行的任何用户apache - 来自ps aux | grep httpd的第一列将告诉您)

Next check the logfiles, typically /var/log/httpd/error_log and also the system logs in /var/log/messages and /var/log/secure 接下来检查日志文件,通常是/var/log/httpd/error_log以及/var/log/messages/var/log/secure的系统日志

Lastly, if you are running a recent CentOS which has SELinux enabled, and you have built apache yourself you'll almost certainly be in a world of pain. 最后,如果您正在运行最近启用了SELinux的CentOS,并且您自己构建了apache,那么您几乎肯定会陷入痛苦的世界。 You can try getenforce to see if SELinux is active, and setenforce 0 to disable it (for testing). 您可以尝试使用getenforce来查看SELinux是否处于活动状态,并使用setenforce 0来禁用它(用于测试)。

暂无
暂无

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

相关问题 为什么 Apache 不允许从 index.html 中访问 web 根目录之外的文件? - Why doesn't Apache allow access to files outside the web root from within index.html? 我创建了一个 simple.onion 站点,但 Tor 浏览器没有显示我的 index.html 文件,而是显示了我的文件夹 - I've created a simple .onion site, but instead of the Tor browser displaying my index.html file, it displays my folders apache 重定向 /url1/* 到 /url1/index.html - apache redirect /url1/* to /url1/index.html Apache on CentOS在配置路由到“ Index.html”(大写“ I”)时出现问题 - Apache on CentOS issue configuring routing to “Index.html” (uppercase“I”) wget 克隆一个网站,链接到目录而不是 index.html - wget to clone a website, with links to directory not index.html ubuntu 网络服务器上的 apache2 拒绝访问所提供索引以外的任何其他文件的权限。html - apache2 on ubuntu webserver rejects permission to access any other file than the delivered index.html 安装SDX麻烦org.apache.cocoon.ResourceNotFoundException:没有管道匹配的请求:index.html - Installing SDX trouble org.apache.cocoon.ResourceNotFoundException: No pipeline matched request: index.html Apache 虚拟主机不在域名处为虚拟主机“index.html”提供服务 - Apache Virtual Host isn't Serving Virtual Host 'index.html' at Domain Name 访问某些index.php或index.html时出现Apache 403错误,尽管每个都有相似的权限 - Apache 403 error from accessing certain index.php or index.html despite having similar permissions for each 保护htdocs目录 - Protect htdocs directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM