[英]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/htdocs
的index.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.