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
Related
I want to deploy the Laravel project to my shared hosting.
When I go to my site main domain (example.com) It displays all directory and files but (example.com/public) works fine.
What if I just create an index.php file in the project root directory with following code
<?php
header('Location: ./public');
?>
It just redirects me to example.com/public.
Just tell me if there will be an issue that may occur at any point?
I am new to Laravel.
I don't care to remove the public directory. I only care if someone goes to example.com then it just redirects example.com/public to work fine.
Update
Just keep it short and simple answer (Yes/No) then explain it.
Is there will be an issue that occurs with the above steps (actions)? (Yes/No)
did you point your vhost to to the public directory?
For Apache
DocumentRoot [Laravel root direcoty]/public
For Nginx
root [Laravel root direcoty]/public;
Laravel Deploment
I'd suggest the easy way, by create a symbolic link of public_html and link it to your laravel project's public directory. don't forget to set your project folder permission.
here's the example: https://blog.netgloo.com/2016/01/29/deploy-laravel-application-on-shared-hosting/
This is Bablu Ahmed. I want to upload my laravel 5.5 project into cpanel and my domain is an addon domain name is w3public.com and it's root directory is not inside the public_html it is outside the public_html (www.w3public.com). I have separated the project's files into two directories, one is www.w3public.com and another is laravel and I moved public folder's files into www.w3public.com and all other files into the laravel folder in cpanel that is given in screenshot below. I have also modified the index.php file of www.w3public.com as follows:
require __DIR__.'/../../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
But it is not working. Can anyone help me with appropriate solutions?
Screenshot:
Your application should be installed in www.w3public.com and then change the root path from cpanel domains to the public folder inside laravel.
The best way to transfer files is git or the likes, but if they don't have it (usually is the case in shared hosting), you should use a ftp client, and if they don't allow that either, you can upload files/folders from cpanel (way too slow sadly).
If you use git be careful since by default vendor folder is in the .gitignore (you have to run "composer update --no-dev" after all the files are transferred)
Make sure also that your ".env" (usually in .gitignore too, so you prob have to make one) file have your server database info.
I have an addon domain like this :
/public_html/mysite
Site is available from the following address:
www.mysite.com
now I want to install laravel on this addon site.
I've copied all folders insdie mysite directory :
but when I enter www.mysite.com on my browser it shows content of my laravel project :
solved:
How to install laravel inside an addon domain
There are different ways you can install laravel inside an addon domain. Here is one of the easiest ways to do it.
Go to your CPanel and open Softaculous Apps Installer.
Look for Laravel Installer and open it. Carefully select the addon domain where you want to install Laravel.
Click Install. If there was no previous install then it would take 3-4 seconds.
Now go to the File Manager and open that specific domain folder. You will see All the laravel files there.
Now if you have an existing project that you want to upload on this domain simply make a zip file of your project and upload & extract inside this domain folder.
ONE LAST THING
When you install Laravel using Softaculous Apps Installer you get a redirect from domain to /public. To resolve this open index.php file (Not the one inside the public folder, one that is outside). Remove all the code from it and just paste the code given below.
<?php
header('Location: public/');
?>
And that is it. This should work for you.
Is it a shared hosting you're using if yes then :
Put the content of public (L5) directly on public_html (be aware of don't overwrite the .htaccess file accidentally)
Now in
then modify your index.php and your bootstrap.php and it will work just fine
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 !! :)
I need to setup Symfony on a shared host that runs on windows IIS. The domain directs to the root folder of the host. Which means no /public_html or /htdocs.
Is there any way to configure Symfony in a way that if I move the contents in "/web" to the root folder of my shared hosting account with the rest of the folders (app, config, tests etc...) , it would still work ?
Yes definitely you can do this.
Just do:
Open - lib\symfony\config\sfProjectConfiguration.class.php
Find - $this->setWebDir($rootDir.DIRECTORY_SEPARATOR.'web'); function
Modify - "web" folder by whatever path or directory you want
On linux, you can do symbolic links to a directory. The windows equivalent of a symlink to the root directory named web would solve your problem I guess...
Symfony on IIS
In the first case, the webserver is only used for our symfony project, and the URL is something like http://myproject/.
Assuming the directory in which you created the directory myapp is c:\myproject\, configure the root directory of your server to be c:\myproject\web (in IIS administration console).