Why did all my require_once calls that are written with paths like ../.../ this folder/thifile.php broke as soon as I deployed my website?
Are they wrong? On the localhost they were working just fine.
I got his errorfailed to open stream: No such file or directory in , and my file structure has not changed after I deployed it
Are you sure the paths point to the same places? If you have a different directory structure on your deployed site, relative paths like "../../etc" may not point to the same files.
I didn't bring my chrystal ball, so you might need to explain some more, but
You host has a different system than you (windows vs linux?), so the / and \ are not compatible?
There was some other problem (hard to guess, since you didn't provide an error)
Not enough rights to read the files
A virtual directory, so you can't go back in the structure like that, cause you're getting a different (real) dir?
Its definitely a path issue. Try going to the files u included using http://yourdomain/path/you/included
Related
First time asking a question here but I'm really stuck.
Basically I'm trying to install a Silverstripe 3.1 cms on a subdomain as a development site, on my main domain I already have a Silverstripe 2.4 site running.
The first thing that comes up is this error, "development" is the subdomain folder.
Warning: require_once(framework/dev/install/DatabaseConfigurationHelper.php): failed to open stream: No such file or directory in /home/usr/public_html/subdomain/framework/dev/install/install.php5 on line 39
I check if the file is there and it is, then I check if the filepath is wrong because the file that is calling require_once has a full path from home/ but that can't be it because I've been able to install Silverstripe on my localhost.
I google redirecting (I've had no experience with it before) and find stuff on htaccess related to Silverstripe but none were problems that I was having, i.e. there are .htaccess files in main directory and subdomain. Not too sure if they're conflicting but I have tried RewriteEngine Off on my subdomain. I mostly leave the default Silverstripe .htaccess files as they are.
Even declaring different suPHP_ConfigPath's i.e.
main website: home/usr/public_html/
subdomain: home/usr/public_html/subdomain
At this point I look back at the error and try hacking the require_once filepath, changing it to
$_SERVER["DOCUMENT_ROOT"] . '/framework/dev/install/DatabaseConfigurationHelper.php
It mostly works but the requirements check page is void of css and any fails to GET any images
I am able to check all the requirements though passing everything but the File Permissions check:
"Does the webserver know where files are stored?" failed. Showing me the filepath it tried being the absolute path of a file prepended with the path to the subdomain. Looking at the code my hack was never intended to work.
Did I miss something? I'm not very knowledgeable with servers but I've done everything I can think of, is there anything I can do?
Hey thanks for your suggestion but I think it was meant for addon domains? I only wanted a subdomain for testing purposes.
What I ended up doing was to avoid installing Silverstripe on the server and instead install it on my laptop and then upload that to the server. It worked fine after copying the appropriate database and fixing Silverstripe's BaseURL to '/'
We recently have adquired the credentials to fully play with our website hosted outside.
So we need to mount it locally on a XAMPP stack to fully deploy the site and asociated database.
It've been already done, and everything seems to work properly except for the images in the site.
It is a DRUPAL site. Some images are "full path coded", so they work as we can expect, but major of them are just relative path coded.
Now, I've everything mounted on localhost. Let's say the folder with the site it's called "web".
Then i've everything on:
c:/xampp/htdocs/web/.......
So I access to it via: http://localhost/web/
I've tested that all the non viewing images, if I append the "http://localhost/web/" on the 'src="/site/..."' they are accessible and look right.
So, is there a way to via .htaccess add the "http://localhost/web/" on those URLs who hasn't it? It doesn't only happens with images, it's just related with all the links, urls, srcs, whatever which is just "relative pathed".
I've already tried the "RewriteBase /web", but it doesn't work.
Need help to solve this so, please.
In summarize, the site online is just mounted on the root, so everything works, fully or just relativetly pathed. But in my case, I've got the development site inside a folder, so I need it to work too!
Much appreciated.
If this is a Drupal 7 site (might work for Drupal 6) make sure you have a tmp directory set. Go to admin/config/media/file-system and look for the temporary directory. Also confirm that you have this directory on your root, which for XAMPP is the htdocs folder.
This might be a file permission that can be caused by incorrect .htaccess settings (This link may help: https://www.drupal.org/node/2140629) in the folder set as your temporary directory.
This may also be a document root error. You can change that by editing the DocumentRoot setting in C:\xampp\apache\conf\httpd.conf.
This stackoverflow link may help if none of the above suggestions bear fruit: https://drupal.stackexchange.com/questions/30113/configuring-the-temporary-directory
I've just got a new PC, running Win7/64. My current projects are all on my Macbook. Of course I could just move the projects over but I like the portability so my ideal scenario is my work syncing across the computers. This is simple with most types of files using LAN file sharing, but when it comes to my Wordpress sites I hit some problems. Here's what I've tried so far:
Sharing my htdocs folder and then accessing it in the browser through http://my.ip.address:portnumber/directory. This works except a crucial problem - <?php bloginfo('template_url); ?> thinks the site's root is localhost instead of my.ip.address, which breaks all my root links like stylesheets.
Creating a shortcut to my Macbook's shared MAMP/htdocs folder inside my PC's XAMPP/htdocs folder. Not actually sure if it's possible to access shortcut files at all through the browser, I tried a few different combinations of /s that didn't work. This was a longshot anyway really.
I understand I need to somehow get the PHP generated after it arrives to my computer, but I really don't know how I'd go about making that happen.
Any help much appreciated.
Add the following to your wp-config.php file, and it will fix your issue in #1
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
I have a file located in my CakePHP root folder placed under a folder named cron. Path is:
c:/wamp/www/project/cron/daily.php
This file requires another file placed inside vendor folder of cake structure, like this:
require("/../vendors/phpMailer/class.phpmailer.php");
And i run this daily.php from task scheduler. This is the scenario in my development site.(Windows system). It works fine as expected. When i migrated the project to Ubuntu(production site), the require statement started causing issues; it cant find the required file. I made a small change there, like this:
require("../vendors/phpMailer/class.phpmailer.php"); <= removed the preceding slash
And it worked. So my doubt is, is there a difference in how parent directory notation work in widows and Linux? If so, how can i overcome this? Its not feasible to remove a slash every time I move the project from my development site(windows) to production site (Linux).
I tried this:
require("./../vendors/phpMailer/class.phpmailer.php");
It worked in linux. But gave "no such file directory" error in windows. It seems windows works only with:
require("/../vendors/phpMailer/class.phpmailer.php");
Solution
From #TWCrap's help problem was solved as follows:
require(dirname(__FILE__)."/../vendors/phpMailer/class.phpmailer.php");
It works in both windows and linux(* tears of joy *). But in windows it produces path as:
C:\wamp\www\project\cron/../vendors/phpMailer/class.phpmailer.php
This path looks ugly and i hope it wont cause probs in future!
-Thanks guys!
AS i remember, when you put 1 dot infront of the line, you start at the directory you are. So then the line must look like this:
require("./../vendors/phpMailer/class.phpmailer.php");
And that should work at windows and linux....
Do not use absolute paths if you really do not need so. It's safer and better to correctly set include_path so in case of move you just need to adjust one setting instead of digging thru whole project and all its files.
So my doubt is, is there a difference in how parent directory notation work in widows and Linux?
Paths starting with / (i.e. /foo/bar) are absolute paths as starting / indicates root folder. On Windows you got drive letter there.
I also suggest using require_once to avoid duplicated requires (which is OK if you mix HTML with code, but "spaghetti code" is not recommended anyway), but may cause problems with code
The problem is that, at least on a UNIX system, when you start with a preceding slash on a file path you start at the root.
You should either write ./../* or just ../ ond both systems. It should work both.
I am developing a website on php, I have installed wamp on my personal computer and my website files are in the www folder of wamp.
now considering www as my root folder i have a template folder in the root folder and header.inc.html file in the template folder. when I try to include this header.inc.html file in any other php file using an absolute path include('/template/header.inc.html'); it gives me error "Failed to open stream: No such file or directory", but when I create a simple html link using the same absolute path it works perfectly and opens the file. below is my test code
<?php
echo 'headerfile';
include('/template/header.inc.html');
?>
if I give the full path for example C:/wamp/www/template/header.inc.html to the include function it works fine.
I am confused that this problem is occurring on my wamp server only and it would work perfectly on any webhost server, or maybe the same problem will exist on a webhost
I would appreciate any help that would clarify my confusion, Thanks.
Absolute paths on the server start from the server's hard disk (C:\).
Absolute paths on the client start from the root of the website (http://example.com/).
You can make use of __DIR__ to make some file on disk relative to the php-file on disk itself:
include(__DIR__.'/template/header.inc.html');
This should solve your issue.
The difference is not that easy to explain because both types of paths - even related - are two pair of shoes. I suggest you start with a very basic HTML website tutorial that explains how to link on your website and where files are located and how that is related to the webserver configuration.
HTML pages live in the client's browser that know nothing about your server's folder structure, and they're relative to the domain name eg. http://example.com/.
PHP programs run on the server side and they deal with the server folders. You shouldn't hardcode full paths in your php programs, because it will cause problems whenever you'll move them between the development server and the live host (just to name an example). Therefore in php files you should either use relative paths to your file, or use the __DIR__ magic constant that gets substituted with the directory where the php file is.
1.) First approach: include('template/header.inc.html');
2.) Second approach: include(__DIR__ .'/template/header.inc.html');
In your case (working on a development machine) both the client and the server is the same box, that might be confusing you.