Upload laravel 5 project to share hosting - php

im newbie with laravel. i have problems when uploading my laravel project to my shared hosting.
when i go into my domain.com/laravel/public/ , i cant see anything. they return it with blank page. no error at all. i dont understand.
i try to follow all instructions in internet, but all i got is nothing.
i change index.php inside of public folder.
from this :
require __DIR__.'/../bootstrap/autoload.php';
into :
$app = require_once __DIR__.'/../bootstrap/app.php';
i also modify my .htaccess file into
RewriteEngine On
RewriteCond %{REQUEST_URI} !^awesome-project
RewriteRule ^(.*)$ awesome-project/$1 [L]
but still all i got is blank page.
what can i do to solve this issue?

I'm assuming you're running Apache2? Check your site conf file and make sure the document root is pointed to the public folder.

you should be getting a 404 error if path is incorrect. A white page with a new Laravel installation usually means you need to check the permissions of your storage folders.
From the Laravel 5 documentation:
"Directories within the storage and the bootstrap/cache directories should be writable by your web server"

You should restore your Laravel files to original state, then you must set your host to a laravel/public directory. It will work only if you'll do both steps.
If you have trouble with setting up your web server, you can find an instruction for Apache here:
http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost
Also, don't forget to restart your web server after doing all the changes.

Related

How can I upload my local Laravel web project to server?

I work on a website which i made from Laravel and now i need to push it to the server and go live. I'm new to Laravel hosting. Earlier I did coding by pure php and those days i just push the project to server and it works. My server is one.com and this is what i get when i copy my content and try to access the page.
please help me on this manner! thank you
Option 1: Use .htaccess
if it isn't already there, create an .htaccess file in the Laravel root directory. Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)
Edit the .htaccess file so that it contains the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Laravel has an Entry Point (which is the index.php File). This File lives inside the public folder. To go L-I-V-E with a Laravel Project, you have to set your Document Root to point to the public Directory.
Right now, you can only access your Site by navigating to: http://van.lesthi.com/public/
At the moment of this writing; accessing the URL above throws somewhat of an SQL Error, which you may want to fix first....

Setup laravel in shared hosting

I'm trying to setup laravel (5.4.12) in shared hosting. Following this tutorial I had deleted my public_html and created soft-link for public_html to public folder of laravel project. I had successfully setup laravel (5.3.29) following the same tutorial for my previous project. But this time when I try to open base url it downloads index.php file of public directory of laravel folder. Can anyone help me out.
You can do it without deleting public_html folder.
for routing to public forlder just add these lines to .htaccess files
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
Normally PHP files are downloaded when the web server isn't configured to serve PHP files. Sounds like you need to talk to your hosting provider.
Finally found the solution. The issue was with PHP version. I had selected PHP version 7.1.0RC4,I changed it to 7.0.12 and the problem is gone.
Laravel 5 setup without artisan serve command
Rename the server.php in the your Laravel root folder to index.php
copy the .htaccess file from /public directory to your Laravel root
folder.

Laravel website on a shared webhost that does not provide any shell?

I have a laravel 5 site on my localhost. I want to launch it on a shared host but the host is neither providing me with the shell nor it has composer installed. Can I still launch my website on this host? If yes then how? If the answer is no then what should I do?
Yes you can upload via file manager if you wish. Follow below steps
Check the server configuration of PHP 5.4 (this because every little change on .htaccess file may change that config)
Create a directory in the same level of public_html and put your project inside that folder (except public folder).
Put the content of public (L5) directly on public_html (don't overwrite the .htaccess file)
Inside public_html all files of public directory of Laravel 5 resides now.
Go to index.php and edit the line 22
#From this
require __DIR__.'/../bootstrap/autoload.php';
#To this
require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';
and on line 36
#From this
$app = require_once __DIR__.'/../bootstrap/app.php';
#To this
$app = require_once __DIR__.'/../[framework-folder]/bootstrap/app.php';
Then edit the .htaccess file and add some lines
RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ /$1 [L]
Hope this works. Worked for me.
You can but you need to upload your local directory after a composer install, including vendor and .env using and FTP client. I wouldn't recommend it though, it makes development really hard. Maybe look into a paas like Heroku to get you started for free.
You also need to make sure that the shared hosting supports the following:
PHP >= 5.5.9
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
as take from the docs

how to make htaccess Rewriterule for a file on root?

I am using Yii framework, I have a file on the website root named test.php, I want to make a rule that redirects this link "staging.mysite.com/p/test" to this file. what I did:
RewriteRule ^p/test$ test.php [QSA,L]
But I got this error
Internal Server Error
Application runtime path "/var/www/staging.mysite.com/protected/_ws/runtime" is not valid. Please make sure it is a directory writable by the Web server process.
It says your runtime folder is missing.
try create a runtime folder under /var/www/staging.mysite.com/protected/_ws/
and make the permission to be 775
Then try again?

.htaccess file won't respond on localhost:63342 in PhpStorm

I'm using the IDE PhpStorm 7.1.4 and trying to make an .htaccess file to stop users from going into a specific directory.
My folder structure is like this:
I want to make it so that users can't go in the /app folder or any folders inside that folder. For this, I've figured out that I can use this piece of code inside .htaccess:
Options -Indexes
I'm using the PHP web server from PHPStorm itself (which goes to localhost:63342/projectname/folderinproject/etc/etc/).
Problems
When directing to the page to the /app folder, I get an 404 error,
saying the index file doesn't exist.
When I have made an index.php file inside the /app folder, and I am redirecting to the /app folder, it just loading up the index.php.
When doing this with just a normal HTML project and opening the index.html via my windows explorer, the same problem occurs
Question
How can I make it so that my project would actually respond on the .htaccess file and wont allow me or other users to go into the /app folder?
EDIT
I figured out that when I copy all my files from my project to the c:\xampp\htdocs\ folder and turn on my Apache server inside of XAMPP, the .htaccess file is working whenever I open it via my regular browser (without selecting index.php in PhpStorm and choosing Open in browser...).
Is there any way I can do this same thing in PhpStorm without moving all the files?
If you are using the default configured web server, you are actually using PHP's new web server feature, which doesn't listen to .htaccess files. Only Apache listens to .htaccess files.
If you are wanting to test this functionality, you can either setup a VM running Linux and test, or setup WAMP on your system and run from there.
EDIT 1
Ok, can you add a little more detail about the exact problem? When you access localhost/app/ it is displaying the index.php file, instead of the 404. Does the application work entirely through the index.php file? If so, is the index.php file in the app or public?
EDIT 2
Ok, here's what you need to do. Place an .htaccess file in the root of your app directory. Clear the contents of this .htaccess and place the line DENY from ALL. You can keep the .htaccess file in the root of the project.
EDIT 3
PHPStorm is going to use the PHP Engine's web server. If you add the XAMPP location as a deployment path, it's fairly quick to deploy to. You can even setup PHPStorm to automatically deploy files to the XAMPP location on save. Here's the walk-through on the JetBrains site JetBrains Config.
The .htaccess plugins are mainly for editing and formating, not for modifying PHP Engine's server environment.
Using mod_alias is even easier:
Redirect 301 /app /new_directory
But if you have rewrite rules in your htaccess file already, then you need to stick with using mod_rewrite:
RewriteRule ^app/(.*)$ /new_directory/$1 [L,R=301]

Categories