Laravel 4.2 in FTP server throwing Error 500 - laravel

I've searched everywhere for a solution. Plus, I tried tracking the error using echo("teste");, but can't find exactly what is wrong, since it works on my local host.
From index.php -> bootstrap/autoload.php -> vender/autoload.php:
I could print a msg until before the foreach in getLoader method of ComposerAutoloaderInitxxxxxx class.
I see it can't complete the require in both bootstrap/autoload.php or bootstrap/start.php
my directories levels are:
public_html/
|__laravel/
|__app/
|__bootstrap/
|__vender/
|__index.php
|__artisan
|__robots.txt
I've changed the paths correctly when moved the files from public/ to laravel root, since I can get into the files required (it just can't finish loading).
I get
500 (Internal Server Error)
Ps.: I uploaded the project through Filezilla, and I only have the FTP access.
Please, could someone help me with this?

Ok first you should not upload a Laravel project via FTP, if you only have an FTP access then you need a real hosting provider that has SSH. You should be able to use the composer command on your production server or you will be in big trouble later :)
Also, assuming this is a cPanel host (based on the public_html folder) the proper way would be to git clone the Laravel project under a folder, remove the public_html folder and create a symbolic link like this.
ln -s ~/laravel/public ~/public_html
This way your document root will point to Laravel's public folder.
Here is more information:
https://laracasts.com/discuss/channels/general-discussion/how-to-install-laravel-in-the-root-directory

Related

How to deploy Laravel project in to shared server

I have a Laravel project, I want to deploy it into the server, the thing is that normally we have index.php and .htaccess inside the public folder, but in my case, I have brought these two files into the root. So I want to know, what are the changes needed in serve?
How can I upload this to server?
Solution 1
Somehow you need to get the ssh access as a shared user from your hosting provider and then you can use git to clone your repository into your server.
Solution 2
You can copy paste all of your project into the server using ftp from your cpanel or relevant control panel.
Solution 3
Use Amazon as your hosting as it gives 1 year free tier access, and also gives you ssh service. Follow the solution 1 after getting this.
Put back the files to the public folder. You can change the root path of your server to your project's public folder.
Follow the steps to do:
Go to /etc/apache2/sites-enabled/
Open the .conf file inside this folder
Change the docuementRoot to /etc/var/www/html/project_name/public
Restart the apache server using the following command:
sudo systemctl restart apache2

500 issue with Laravel

I have seen this answer in many posts but they have not helped me at all. I followed the regular steps to create the laravel project like this:
I cloned from my repository.
I ran composer update.
I added 777 permissions to storage and bootstrap folders.
I have a .env file.
I verfied the .htacces and it's ok.
It is working in locahost, but when I try to replicate it in Hostinger it does not work, it displays the 500 server error. So I wonder what is the problem?
I checked the logs by the way and they were empty. I put the laravel project debugger to true too.
the website url is xellin.com
The debug:
The logs folder:
Thanks.
I think this is a good opportunity to point out how PHP / Laravel / Underlying Server interacts one to each other.
First:
The HTTP server inspects Document Root and .htaccess to get instructions.
If the file is .php (like Laravel), then it CALLS to the php handler.
The php handler could be a FPM version or a Fast CGI version.
-> If an error ocurrs parsing the .htaccess or with the initial interaction between Http Server and PHP... Laravel never runs for real. All ends in a PHP error log
To find out what's wrong, you need to inspect what PHP / Http Server said about the error in their respective logs.
In short words: at this point is not a Laravel error, but a server/php one.
Second:
If Apache/PHP runs well, then PHP executes the Laravel Applicacion Lifecycle... if Laravel encounters a problem, then you will see the usual output error of Laravel Error Handler.
I think this is a must to know to work with web apps in general, because many times developers miss to catch if the problem was with Laravel, or with PHP / Server itself.
As a side note, that's why it is important to know how to choose propper hosting service for Laravel.
Thanks for reading.
You can try to clear cache
Like as
php artisan optimize
Or
You can manually delete cache files which is located in bootstrap folder and inside bootstrap folder you can see cache folder inside cache folder delete all files except git ignore file your issue fix
If you show again this error on live serve then tou can update your composer and then run
php artisan optimize
at first, if you give any of your folders 777 permissions, you are allowing ANYONE to read, write and execute any file in that directory.... what this means is you have given ANYONE (any hacker or malicious person in the entire world) permission to upload ANY file, virus or any other file, and THEN execute that file...so please be careful because IF YOU ARE SETTING YOUR FOLDER PERMISSIONS TO 777 YOU HAVE OPENED YOUR SERVER TO ANYONE THAT CAN FIND THAT DIRECTORY. please read the full explanation from here
the second here is the detailed steps I used to deploy my projects to the server:
run npm run production then update your github repo.
clone the project from GITHUB to server - clone to an outside folder (not public_html folder)
run cd <cloned folder name>
run composer install
run npm install
copy and configure .env file to cloned folder( be sure name is .env not env).
copy all content of cloned_project_folder_name/public to public_html folder
in index.php inside public_html folder edit as below
$app = require_once __DIR__.'/../cloned_project_folder_name/bootstrap/app.php';
require __DIR__.'/../cloned_project_folder_name/vendor/autoload.php';
set your .htaccess properly.
change permission to 755 to index.php and all file in public_html folder
run composer install --optimize-autoloader --no-dev
run php artisan config:cache
run php artisan route:cache
I think I state it all, hope that will help

Install Laravel on dedicated server's subfolder

So I am having an issue with pushing a Laravel app to production on a dedicated server's subfolder.
Server is run on Apache.
Url I want to push my app would be subdomain.domain.com/project
The structure of my dedicated server is
.cpanel
...
-laravel
-app
-vendor
-...
-public_ftp
-public_html
-folder
-contents of laravels public directory
-ssl
I know that in order not to expose my hidden files I am required to install it in a root directory, but this is not an option because I will be having multiple projects running under subdomain.domain.com/project-1, subdomain.domain.com/project-2 and etc... and all will have a separate laravel installation.
I need a hand in order to achieve that, can anyone give me some advice?
Managed to do it myself, the problem was when i was creating a symlink, so instead i just moved contents of my public directory to public_html/project-1/ and changed index.php path to /../../laravel/
The thing was that I have done it originally but I didnt expect that permissions for storage need to be manually set, that solved my issue and laravel works.
ALWAYS CHECK ERROR LOGS :)
You can place your separate folders in your subdomain with no problem.
The important thing is that you need to point the browser to public/ folder under your laravel projects.
You can create a .htaccess file with the command below in root folder of each project and perform a redirect.
Place the following command in your .htaccess file:
RedirectMatch ^/$ /public/

Make symlink laravel public folder

i've tried push my laravel 5.1 project to server. I want to make a symlink to public_html folder so i can access it like normal.
ln -sv app/crowd/public public_html
i've tried that one. but the symlink is taking the public folder instead of it's content.
ln -sv ~/app/crowd/public ~/public_html
i've tried that one too but it still fail.
any suggestion how to make it works?
If "the symlink is taking the public folder instead of it's content" means that your browser is giving a 403 or saying you can't access the folder, it may mean that you don't have index.php in your DirectoryIndex directive (if you're using Apache - not sure what the equivalent is on nginx).
When you enter a location in your browser and don't include a filename (www.host.com/page.html), the server looks at a list of default pages and sees if one of those is present. If not, it tries to serve the whole directory. Try browsing to www.host.com/index.php and see what you get. If it loads, you just need to update your config. If not, please explain what you see.

How to run laravel 5.0 project on localhost without use php artisan serve

I have created a laravel 5.0 project with php artisan serve, now i need to know how to run laravel 5.0 project run without start php artisan serve, i have already browse lot of websites no one help me..
You need to change "server.php" to "index.php" then copy ".htaccess" from public to root directory.
See: https://stackoverflow.com/a/30053989/3948755
Laravel sever Folder is "public". There is an index.php so you can run you project from there.
Suppose if you using UbuntuOS then you have to create your local server in public directory. Suppose your folder name is laravel_test then go in that directory and run some thing like this
php -S localhost:8000 -t public
If you using windows then access public folder from URL.
localhost/laravel/public
Actually it's bad practise to access folder from URL but for local its good. You also can go with host entry. Just make sure that your target folder is "public" directory.
Normally you would have WAMP/XAMPP installed. You can access Laravel project like below
localhost/laravel/public
But this is not recommended. You should create Virtual host for example
laravel.local that pints to server-root/laravel/public.
this is how you create virtual host.
Or even better go for a Laravel Homestead .
How is your .htaccess file configured?
Try with localhost/laravel/public/index.php
Use http://localhost/projectName/public
It will be work. but in case if you have another Route and you can not access that Route and get the error like " Page Not Found " then please use the following command
sudo a2enmod rewrite
Now open the http://localhost/projectName/public/yourRoute
This is a little late but still applicable, what I like to do (using ubuntu 14.x+) is put my laravel project (let's say Project1) in my var directory, so it would be in /var/Project1, then symlink the public folder to somewhere in /var/www(+/html depending on apache version).
Symlink can be done something like this:
ln -s /var/Project1/public /var/www/html
This keeps your internal files off the grid so to speak, this is untested so if I've missed anything just comment and I will amend this post.
EDIT:
Obviously if your http root is /var/www/html you can put your project in /var/www/Project1
If you have access to xampp or wampp on your operating system you can more or less configure your virtual host like in the instruction below:
https://bestin-it.com/creating-virtualhost-on-your-local-computer-to-start-simple-index-php/
This instruction shows how to run it locally on your PC, but it works generally the same on any hosting portals. In most case in payed portals you have any web panels to configure your public folder that reference to /public folder in laravel folder's structure.

Resources