In php there is any method to get a separate website's root directory?I know only the ftp details of the website.In my program i want to login to the ftp server using ftp details and create a folder in the website's root directory.For that I want to know the root directory of the website.Using ftp_nlist() it shows all directories.From that i want to identify which is the root directory of the website.How can i do this?
These are the steps in my script
Login to the ftp server using ftp_connect() and ftp_login()
Fetch the website's root directory
create a folder in that directory
You mentioned that you have access to FTP, thus you can use this line to find out the absolute path of the index.php:
$directory = dirname($_SERVER['PHP_SELF']);
Related
In an Apache linux server,
Can I put SQLite database in a folder before root folder(public-html folder where index.php file could be placed in) of server and give the database folder full time read and write access permission(600)?
I want to copy a file from /folder to /subdomain using
copy($src,$dest);
However I get a Failed to open stream ...
When I check with
is_writable($dest_folder);
The subdomain folder is not writable.
The subdomain is created using the DirectAdmin api
So the folder has the owner of the domain and php has as owner Apache.
I think thats the problem, however I could not find to bypass this (chmod seems to not working or I am doing something wrong)
Provide the full path and use chmod.
chmod($path.$file.".".$extension, 0777);
Otherwise the problem has to do with groups and chown.
chown($subdomain, $user_name);
In php is it possible to get a website's root directory using ftp details?
Using ftp_nlist() function it displays all directories.I want only the root directory.
No. The FTP server doesn't know that - the web root directory is something that only the web server knows, and the FTP server isn't in communication with that.
I have one website, not i want when i upload this site on live server it should ask for database username, password, site url..etc. Something like website installer. It is working fine in LOCAL system.
Now my problem is: i need to change RewriteBase in .htaccess file. But this file is located at root of site. So i am getting permission issue to create new file or edit/copy file which is located at root.
Warning: rename(generate.htaccess,.htaccess): Permission denied
Warning: copy(.htaccess): failed to open stream: Permission denied
What should i do. Please help.
Thanks.
To Create/Modify file on root directory you must have to give 0777 permission to your root directory. This is not a good practice.
I suggest create empty .htaccess or other required file with 777 permission initially. Before writing content in that file first check write permission after that copy content from source file (in your case from where you trying to copy).
Hope this may help.
I'm building a webpage which has a page allowing users to log in, called login.php. This page is located in the same root directory as my index.html page. When I open up index.html and go to click on the login link, I get this error message:
Fatal error: Unknown: Failed opening required '/websites/testsite.com/www/login.php' (include_path='.:/usr/share/pear') in Unknown on line 0
I have no idea why this isn't working because my index page (and every other page that I have made thus far) links to that same login.php page, which exists in the same directory. Any advise?
If it helps, I'm running Arch Linux with Apache HTTPD 2.2 and PHP 5.3.8. Thank you!
EDIT:
I forgot to mention some extra information. Since I'm working on this website with another person, we each have "local" copies of this website in our user directories. (I say local, but it's really our user directories on the same server which is hosting the public version of this website). Apache is set up to allow user directories (http://thisismytestwebsite.com/~myusername), which is how we view our "local" copies. When I go to click on the login link, the page loads up fine. Everything that we have is backed up using Git, and everything that we have is synchronized properly (we just checked).
Check if the file you're trying to open exists, and that the path is an absolute path.
It's fairly easy to generate a relative path from one file to another:
dirname(__FILE__) . "/../include.php";
Will include the file 'include.php' from one folder up from where the current file is.
__FILE__ is a magic PHP constant, use it!
Probably the apache process is blocked from reading the index.php file due to file system permissions.
Try to adjust permissions (chmod) and ownership (chown) of the file according to your working index.html