OPENSHIFT - How do I change the document root? - php

Hi here I was openshift novice users, where before I used the cpanel for my hosting, and I want to switch to openshift, that I ask is how do I change the document root?, if previously on cpanel is Home/public_html/thelifestylelist.com to Home/public_html/thelifestylelist.com/public on openshift? (my index php is on public directory)
Hopefully the picture below can clarify my question.
Thank you.
Sorry i used external link for my image, need at least 15 reputation to attach image. .

This is the order OpenShift search for root directory
IF php/ dir exists THEN DocumentRoot=php/
ELSE IF public/ dir exists THEN DocumentRoot=public/
ELSE IF public_html/ dir exists THEN DocumentRoot=public_html/
ELSE IF web/ dir exists THEN DocumentRoot=web/
ELSE IF www/ dir exists THEN DocumentRoot=www/
ELSE DocumentRoot=/
So you just add the any of this folders.

According to this blog post, there are multiple document roots you can use for your PHP project (or static html project), you can read it here: https://www.openshift.com/blogs/openshift-online-march-2014-release-blog. Since you are using open shift, it would probably be best to just use the document root they provide you by using git to download/upload your files to your gear. You might review this page to help you get started: https://www.openshift.com/get-started

Related

Create a folder in the /root directory

I've tried everything online but I couldn't find a real solution, I have a php file that in local on my computer works perfectly, instead when I load it on my seerver it doesn't create the folder.
the php contains this string to create a new folder:
shell_exec("mkdir /root/users/$username");
I guess that maybe it's a problem of permission, I can just create folders in the var/www folder, dI tried a lot of different way to set my permission but I can't figure it out.
You should use mkdir to create folder or chmod to change permissions functions.
for example:
mkdir('newFolder', 775);
or you want to create on some path. Currently you are in /home/username/public_html/project/
mkdir('subproject', 775); // it will create in `project` folder.
if you want to create with some root like you asked in your question.
mkdir('/root/users/'.$username, 775);
I am sure it will be fix your issue and also a standard way to create.

I can' upload file on my shared folder using laravel

I have a laravel project that i hosted on a shared host. using the system i saw on Laravel Deploy Instruction
So am suppose to upload image, -- user's image. To the public_html folder but since am not in the public_html so the users can't upload their image. since my code lie out side the public_html folder and it doesn't allow write permission for general users. so i tried uploading it to 'storage folder' (ie the my laravel project folder, that is in the sane level as the www 'public_html' folder.) it works i can see the image in the storage folder but i cant access because it is behind the public_html folder. and whatever can't be point to. Example project/storage/app/public is the folder that has the user image if i point to it in <img src="project/storage/app/public/user.png" > it wont display because the browser looks for project/storage/app/public inside the public_html folder whereas it is outside the public_html. So can someone touch on this. Thanks guys. Or is htaccess use in this case?
you need to create symlink to Your storage folder .
please see this answer:
Laravel 5 - How to access image uploaded in storage within View?
the above method given by the link works for offline however not all shared hosting site support artisan Laravel sysmlink. so the absolute and best way to do this is with php symlink() function From PHP MANUAL
so just add this code to your web.php ie project\route\web.php
Route::get('/symlink', function()
{
if(symlink('/home/username/projectfolder/storage/app/public', '/home/username/public_html/storage')){
echo "We rock yea stackoverflow!!!! best programming software";}
});
so the username is the name of your home dir

Some of the directories are accessible from public URL. How to avoid this in yii

In my Yii web application some of the directories are accessible from the public URL (main directory or application folder) like js, css, images etc. How to avoid this problem. This is a major security issue, but I don't know how to fix this. Please help me...
Thanks in advance...
If you're using Apache, you can restrict access to directories doing the following:
Create a .htaccess file in your directory so path/to/directory/to/deny/.htaccess
Open .htaccess and add Deny from all
You have to turn of apache directory listing. Use the link below.
How do I disable directory browsing?
Then change all files and folders permissions of a directory to 644 and 755.
Change all files and folders permissions of a directory to 644/755
Let me know if you need help
Here is some instructions given in documentation.
1) It's important that the directory be writable by the webserver user so that Yii can publish the resources there when needed.
2) When a project has multiple versions (production, testing, development, etc.) do not copy the assets/ folders from one area to another; allow Yii to deploy them automatically in each area.
3) Do not manually edit any file under assets/ - if you have a real need to make a change, find the publishing module, edit the source, delete the subfolder under assets/, and let Yii re-publish the updated files.
4) Do not reference names under the assets/ folder directly (say, to get at some other module's assets). If you need to use that
5) Do not add the contents of the assets/ folder to any source-code control system; these files have master source in other places.
6) It is safe to delete everything under assets/. Yii will re-publish the assets if they are not found under assets/.
Hope it will help you :)

move_uploaded_file and relative path to destination in public_html in home directory?

I'm using OpenSuse 12.2 now. To learn and test PHP code I use public_html directory in my home folder: /home/wojtek/public_html/ I access project files in the following way:
http://localhost/~wojtek/projects/foo/bar.php
But I have not clue how to make move_uploaded_file to work. The server root is /srv/www. I set upload_tmp_dir to /srv/www/tmp (I have really no idea where it should go).
When I set destination of move_upladed_file to /srv/www/images, files landed there. But I'd like to make use of public_html folder as I'm keeping all my files there.
For example having:
public_html/projects/foo/
public_html/projects/foo/bar.php
public_html/projects/foo/images/baz.jpg
Can I somehow use the relative destination ('images/') of move_uploaded_file in the bar.php? So that I can access images relatively in IMG tag like from bar.php?
Sorry if it sounds a bit chaotic but I'm new to PHP.
No you wont be able to access the /srv/www/images folder from the /home/wojtek/public_html/projects/foo/bar.php web page.
Id suggest either
1) setting the move_uploaded_file to /home/wojtek/public_html/projects/foo/images
or
2) using a symbolic link to access the images folder from your public_html folder:
cd /home/wojtek/public_html/projects/foo
ln -s /srv/www/images/
and then it will appear that the images are stored in /home/wojtek/public_html/projects/foo/images, but they will actually still be here /srv/www/images
Its possible that you may run into trouble with permissions using this method however

Access separate docroot in apache

I have a site on a server running Apache2 that resides at docroot /var/www/html. I want to access some of the files on a separate site at docroot /var/www/vhosts/othersite. Is there a way to access these files from the first site?
Thanks,
Chris Birk
You can include them using the include and require calls, or use symlinks to create a soft link in project 1 from project 2. These obviously depend on what you're actually trying to accomplish.
Edit: Oh, also, you could potentially add the folders you want to PATH.
The right way to do this is with mod_rewrite, and there are several ways of mapping URLs to different paths in the documentation here.
The cheatin' way of doing it would be to create a symbolic link from the directory outside the document root to a directory inside the document root, making sure the user Apache runs has can read that directory, and follow symlinks is turned on.
Yet another way of doing it would be to create a subdomain as a VirtualHost, with a document root of that other directory.

Categories