Deploy Laravel project on subfolder - php

I'm trying to deploy my Laravel 5.5 project on my web hosting ( PHP version 7.1.xx ).
I have multiple hosting on the same server so when I connect using FTP that what I have:
-WEBSITE NUMBER 1
-- WordPress files
-WEBSITE NUMBER 2
-- WordPress files
-WEBSITE NUMBER 3
-- WordPress files
Now what I want is a subfolder of www.WEBSITENUMBER3.com/app/ running laravel.
So I did 2 folders at the same level:
-WEBSITE NUMBER 1
-- WordPress files
-WEBSITE NUMBER 2
-- WordPress files
-WEBSITE NUMBER 3
-- WordPress files
-- app
-- laravelApp
Inside of app folder I put the files of the Public directory of Laravel, and in the laravelApp folder I put all my laravel project ( except public folder )
Now the problem is that when I visit www.WEBSITENUMBER3.com/app/ all the links are broken, bootstrap doesn't get load because he tries to load :
www.WEBSITENUMBER3.com/bootstrap
instead of www.WEBSITENUMBER3.com/app/bootstrap
so all the things of my Application.
So is there a way to change the root where laravel works?
I found impossible and wrong change all links in Laravel manually to make them absolutely I want to keep them relative.

You should set the right path four your app in the .env file, in the root folder.
The APP_URL line should be set like this:
APP_URL=www.WEBSITENUMBER3.com/app/
After changing the .env, you need to restart the webserver. The additional steps depend on your webserver.

Related

Is there a way to create an Eclipse project excluding the project name in the path?

Not sure how I can explain this better as I am a beginner to Eclipse application.
I have my web directory set up for php pages. For example, /home/www/phpsite. All the source files exist here.
However, whenever I create a project (say 'myProject') and test any files from the existing path, it includes the project folder in the path name:
/home/www/phpsite/myProject/index.php
and this results 'Not Found' error.
How can I run my php pages in /home/www/phpsite/index.php? The project folder name is always included in testing web pages.
I am not trying to use the workspace directory created by Eclipse. I'd like to code and modify pages directly from Eclipse to my web directory.
Thanks
Follow these steps:
Setup www as your workspace
From the menu: File -> Import -> General -> Existing Folder.....
Promote to project:
Choose project type: PHP
Browse for "phpsite" and finish.

Affect on security of Laravel 5 when change folder structure to remove public folder

I'm new in Laravel 5.
I found this Laravel 5 - Remove public from URL on Stack Overflow to remove public folder from my Laravel 5 App. Only I have a question about the security.
When I am removing public from URL, then I have to change the basic folder structure of Laravel 5. Yes, it's working fine without the public from the URL.
But what's about the security of Laravel, because I am changing the default folder structure? Is it secure to use?
You should be pointing your Apache host root to the $LARAVEL_PATH/public directory instead of $LARAVEL_PATH.
The point of having sub directory for www host root instead of project root is that you're not leaking any of your project files through your web server.
Even though all the PHP files have the file suffix .php, malicious user can access your $LARAVEL_PATH/storagedirectory and its subdirectory contents, read your composer.json or package.json to find vulnerable dependencies or read .env file etc.
If you're running on shared hosting and you have mandatory public_html, try installing Laravel outside of that public_html directory and either removing public_html (if empty) and replace it with symlink to $LARAVEL_PATH/public OR if you want the Laravel instance to be subdirectory ofpublic_html, do the same but create symlink from$LARAVEL_PATH/publictopublic_html/$PROJECT_SUBDIR`.
That public directory is there for reason to make project a bit more secure. Solve the actual problem and don't try to break this simple but nice security addition. :)
you this link you provided is not about changing the actual file structure of the framework, this example uses mod_rewrite to rewrite the url of your application. In other words you are telling your server that you would like to point to that directory without the full path is visible to the end user.
Also take a look on the below answers of the link you've provided.
Rename the server.php in the your Laravel root folder to index.php and
copy the .htaccess file from /public directory to your Laravel root
folder. -- Thats it !! :)

How to include separate directories into one project?

I have a folder outside the document root named Base and a folder inside the document root to display HTML pages.
I originally had them separate projects but that's not the ideal situation obviously?
I saw one suggestion to make the directory which holds Base the project root and to exclude everything except the two directories I need. This works but is this the only way to do it?
Settings (Preferences on Mac) | Project | Directories | Add Content Root
This allows you to make any folder as part of the project (will be listed in Project View panel as separate branch).

Using Laravel on a subdomain, where to put public files when have another website on main directory

Currently, I have my live website hosted in the normal way with all files in public_html.
However, I am rewriting my website using Laravel but wish to test it first on a subdomain.
If I am not mistaken, to use Laravel on a live website you should upload all files into the host root except the public files. Which then should be uploaded into the public_html folder.
However how do I go about this when using the subdomain?
I have a structure as so:
root
-- public_html
-- subdomains
-- beta
I could upload all files into beta and create a public folder inside that beta subdomain for the public files? I have tried this but get all sorts of path errors with double public_html/public_html paths etc. Nothing I try seems to work.
I want to keep the live site in tact, but work on the beta version stand alone when I need live testing.
Any help?
make a soft link by using:
ln -s /path/to/public_html/ /path/to/subdomains/beta/public

Install laravel in a subfolder via ftp

I'm working with a server that I can only use FTP, so I have my laravel project in a folder inside www named 'laravel', I want to see my project by clicking domain.com/laravel, inside this www folder I have others folders with others projects I don't think that I can use the root to upload my laravel project like I saw in many tutorials.
Now If I visit domain.com/laravel i only see a list of directories ,Is possible to view my project working at /laravel ??
Thanks!
You would either need to add a custom mod rewrite config or configure your apache virtual host directory to be laravel/public

Categories