Linux, Apache, PHP, MySQL Administrators Forums

Go Back   Linux, Apache, PHP, MySQL Administrators Forums > LAMP Forums > PHP - Hypertext Preprocessor

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-13-2009, 08:33 AM
Junior Member
 
Join Date: Aug 2009
Posts: 9
Question cannot read from above directory

Hi all,

i am sure some of you had already stumped on a case similar to mine, but i cannot find any pointers to the right directorion.
The problem is this: I have a file conf.inc.php, which has the credentials to access the Mysql Database. According to some experts, this kind of file should not reside in the same directory has the website, but instead in a upper directory, for security reasons. I have done that, but it seems that although i have a include in the index.php file, the conf.inc.php never gets read and a Apache error appears on the webpage (Access denied for user 'apache'@'localhost' (using password: NO)).
The directory tree is this:
/html
conf.inc.php
/site
index.php

Odd stuff:
1) if i copy the conf.inc.php into the /site directory, the website works perfectly (although the include file points to the above directory) canīt understand this behaviour.
2) if i add the apache user to mysql, the error says that there is no database selected.

Any help would be appreciated.

Thanks in advance,
Nelson.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-13-2009, 10:02 AM
zoticai+c's Avatar
Ambiguos Variable
 
Join Date: Jan 2009
Posts: 3,163
Default

Hi Nelson,

Welcome to LAMP Admins!

Can you show us how you are including your conf.inc.php from index.php

Cheers
__________________
···dotmanila···
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-13-2009, 05:04 PM
Junior Member
 
Join Date: Aug 2009
Posts: 9
Default

Hi,

i am including the file using the following sintax:

include("../conf.inc.php");

I also have tried another way which i copied from an article on the web, and it was something like :

include ($_SERVER['DocumentRoot']."../conf.inc.php"); //right now i am not sure if this is correct, but was something similar to that.

Thanks,
Nelson
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-13-2009, 05:15 PM
zoticai+c's Avatar
Ambiguos Variable
 
Join Date: Jan 2009
Posts: 3,163
Default

Try this instead:

PHP Code:
require_once dirname(dirname(__FILE__)) . '/sites/conf.inc.php'
Cheers
__________________
···dotmanila···
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-13-2009, 08:31 PM
Junior Member
 
Join Date: Aug 2009
Posts: 9
Default

ok,

i have replaced the include line by this one:

require_once ('../conf.inc.php') or die ("Could not read DB connection file");

Now the webpage simply does not load. No errors, nothing. Just a blank wepage.How weird is that?


nelson
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-13-2009, 08:47 PM
Junior Member
 
Join Date: Aug 2009
Posts: 9
Default

A few more informations...

the web tree is like this:
- /html
........conf.inc.php
|----/site
..............index.php

the DocumentRoot is pointing to the /site directory.

In Microsoft IIS, there is an option ("Enable Parents Path") a person has to check in order to be able to read the parent directory. Is there an option like that in Apache?

thanks,
nelson
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 08-14-2009, 12:18 AM
zoticai+c's Avatar
Ambiguos Variable
 
Join Date: Jan 2009
Posts: 3,163
Default

Can you check if safe_mode is On from your phpinfo();
__________________
···dotmanila···
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 08-14-2009, 02:05 PM
Junior Member
 
Join Date: Aug 2009
Posts: 9
Default

safe_mode is off
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 08-14-2009, 02:07 PM
Junior Member
 
Join Date: Aug 2009
Posts: 9
Default

Here is the result of the phpinfo (sorry for the output):

System Linux centos1 2.6.18-128.1.6.el5 #1 SMP Wed Apr 1 09:19:18 EDT 2009 i686
Build Date Apr 7 2009 08:01:33
Configure Command './configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter'
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php.ini
Scan this dir for additional .ini files /etc/php.d
additional .ini files parsed /etc/php.d/dbase.ini, /etc/php.d/ldap.ini, /etc/php.d/mysql.ini, /etc/php.d/mysqli.ini, /etc/php.d/pdo.ini, /etc/php.d/pdo_mysql.ini, /etc/php.d/pdo_sqlite.ini
PHP API 20041225
PHP Extension 20050922
Zend Extension 220051025
Debug Build no
Thread Safety disabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, http, ftp, compress.bzip2, compress.zlib, https, ftps
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, bzip2.*, zlib.*

This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

PHP Credits

Configuration

PHP Core

Directive Local Value Master Value
allow_call_time_pass_reference Off Off
allow_url_fopen On On
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors Off Off
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 2047 2047
expose_php On On
extension_dir /usr/lib/php/modules /usr/lib/php/modules
file_uploads On On
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .:/usr/share/pear:/usr/share/php .:/usr/share/pear:/usr/share/php
log_errors On On
log_errors_max_len 1024 1024
magic_quotes_gpc Off Off
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
mail.force_extra_parameters no value no value
max_execution_time 30 30
max_input_nesting_level 64 64
max_input_time 60 60
memory_limit 16M 16M
open_basedir no value no value
output_buffering 4096 4096
output_handler no value no value
post_max_size 8M 8M
precision 14 14
realpath_cache_size 16K 16K
realpath_cache_ttl 120 120
register_argc_argv Off Off
register_globals Off Off
register_long_arrays Off Off
report_memleaks On On
report_zend_debug On On
safe_mode Off Off
safe_mode_exec_dir no value no value
safe_mode_gid Off Off
safe_mode_include_dir no value no value
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
serialize_precision 100 100
short_open_tag On On
SMTP localhost localhost
smtp_port 25 25
sql.safe_mode Off Off
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 2M 2M
upload_tmp_dir no value no value
user_dir no value no value
variables_order EGPCS EGPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
y2k_compliance On On
zend.ze1_compatibility_mode Off Off
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 08-14-2009, 03:09 PM
zoticai+c's Avatar
Ambiguos Variable
 
Join Date: Jan 2009
Posts: 3,163
Default

Ok I overlooked you directory structure from before, try this instead:

PHP Code:
require_once dirname(dirname(__FILE__)) . '/conf.inc.php'
__________________
···dotmanila···
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:11 AM.


Community hosted with DotManila Consulting
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2