How to install LARAVEL 5 - php

how to install laravel on hostinger server/ any other free hosting server. I had learned and done working codes in localhost. But i would like to run it on a real server.
Laravel Version : 5
PHP Version Server :5.5.35
1) I had copied the full laravel code to "/home/< username >/"
2) copied the files in /home//laravel/public to /home/< username >/public_html
But it shows an error.
Fatal error: require(): Failed opening required '/home//public_html/../bootstrap/autoload.php' (include_path='.:/opt/php-5.5/pear') in /home//public_html/index.php on line 22
Answer :
Use Heroku Server as #lciamp Suggested in the comment
Clarification :
Please suggest me a list of Payed Servers which support Laravel Framework

Since you have SSH access do this:
Filesystem
SSH into the server
Change directory to the project root
cd /home/< username >
delete the public_html folder
rm -rf public_html
create a symbolic link from public to public_html
ln -s /home/< username >/public /home/< username >/public_html
Install Laravel dependencies
composer install
Change permissions
chmod -R 755 *
chmod -R 777 storage/ bootstrap/cache/
Checklist
Make sure your environment file uploaded and is proper.
If the server is Apache, make sure you uploaded the .htaccess files.
You probably uploaded all the assets, if so you will not need to do bower or npm.
Restart the server.
**In Case of a Limited Shell Environment
Install Laravel dependencies locally and upload the vendor folder with everything else.
Instead of uploading the whole Laravel app to /home/< username >/ upload it to /home/< username >/public_html.
Modify your /home/< username >/public_html/.htaccess to redirect all requests to the public subfolder.
# /home/< username >/public_html/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect All Requests To The Subfolder
RewriteRule ^ /public
</IfModule>
Make sure you have the proper /home/< username >/public_html/public/.htaccess (GitHub).
# /home/< username >/public_html/public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

After you copy the code to your hosting server, you need to install the composer packages required to run Laravel. You can do this using composer install (providing that composer is installed). Otherwise, you need to install composer first.

Related

Laravel, unknown error after deploy to LIFE server, 500 Internal Server Error

I just deployed a laravel 8 project from my local server to a LIFE server, everything went OK apparently, I managed to run composer successfully (composer update), composer doesn't throw any error message, the domain of the LIFE server is linked with the folder /project/public. I have also managed to run php artisan migrate with success, I can see the tables created by artisan in the database, so the application is correctly connected with the database.
I have also changed the permissions of the main project folder to 755 and the permission of the storage folder to 777.
sudo chmod -R 777 ./storage
sudo chmod -R 777 ./bootstrap/cache/
sudo chmod -R 664 /mainprojectfolder
I successfully generate a new KEY with artisan, and I managed to clear the cache with artisan... In other words, I have been through all the tutorials that I found online, but the problem is not resolved.
php artisan key:generate
I have also managed to clear the project cache as the official documentation suggests with:
php artisan config:cache
php artisan route:cache
php artisan view:cache
I have also created the .htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
When I browser the server URL, I see that the browser is correctly redirecting to domain/login, which is correct, as long as I am not logged in the application redirects to the login page. Then the browser displays the classic: 500 Internal Server Error - The server encountered an internal error or misconfiguration and was unable to complete your request...
Unfortunately, I don't have access to the server logs because the server is a shared virtual server, so I can't figure out what the problem exactly is.
Can you guys please suggest?
I finally found the solution after a lot of attempts, the .htaccess file was wrong and I swapped:
RewriteRule ^ index.php [L]
with:
RewriteRule ^ /index.php [L]
I added the / before index.php. This has fixed the problem.

Laravel 5.8 Fresh Deployment Not Working In Hostinger Shared Hosting

I tried to deploy a fresh laravel application. I installed a laravel 5.8 and upload to github repository.
The repository or project folder is working since I tried to run php artisan serve and it successfully shows the laravel home screen page.
I tried to connect in my shared hosting using ssh.
Here's the steps that I've done:
Access thru ssh
create a project folder mkdir my-assignment-calculator then cd my-assignment-calculator
Clone project repository. git clone **repo_url**
Navigate the project folder, cd my-assignment-calculator
Copy .env file, cp .env-example .env
Install composer packages. composer install
Then copy all files in Public folder to public_html folder
Go to public_html then update index.php, nano index.php
In index.php, I update these two lines, the vendor/autoload.php and the bootstrap/app.php
Here's the sample code for #9:
require __DIR__.'/../my-assignment-calculator/my-assignment-calculator/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once
__DIR__.'/../my-assignment-calculator/my-assignment-calculator/bootstrap/app.php';
Here's the structure of my project folder
-public_html
-domains
--my_assignment_calculator
--my_assignment_calculator
---laravel files
The current output is only white screen. I tried to check the developers tools or devtools, there's no error. It's just a white background. It's the same as before.
I tried to check .htaccess file and I didn't touch this file. Here is the .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
So what is the expected output
Should display laravel welcome or home screen page
laravel folder is in root then all your public folder files transfer it into public_html then go to your index file in your public_html configure by adding laravel directory like this:
require __DIR__.'/../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';

How to deploy laravel project on Server?

I built a linux server on digitialocean and installed require software and clone laravel files from github to /var/www/html/. I get this error
"The 138.68.81.200 page isn’t working" in http://138.68.81.200/socialNetwork/public/
Even though uploading migrations and create .env files and storage/* 777 permission.
How can I solve this problem ?
Assuming that you have installed all php packages and dependencies and all project vendors via composer. You just need to add this to /etc/apache2/sites-available/000-default.conf
Alias /socialNetwork /var/www/html/socialNetwork/public/
<Directory "/var/www/html/socialNetwork/public">
AllowOverride All
Order allow,deny
allow from all
</Directory>
And then add this in your /var/www/html/socialNetwork/public/.htaccess :
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
After that:
sudo service apache2 restart

Internal 500 error laravel 5.2

I have a domain say www.example.com and on the root of the domain I have a folder called development. Inside development I have a folder called hunterlp and inside the hunterlp folder all my laravel files are placed when I navigate to http://www.example.com/development/hunterlp/ i am greeted by a 500 internal server error.
I moved all my folders from public to the hunterlp root folder and placed a .htaccess with the following in
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
How can I make my laravel site work in that folder?
please follow this instruction its work for you
1. connect to hosting via SSH
2. install composer
3. in cpanel open Select PHP version and choose 5.4. (I also set phar extension)
4. install laravel: php composer.phar create-project laravel/laravel myproject --prefer-dist
5. copy everything from myproject/public to public_html
6. open public_html/index.php and set:
7. require __DIR__.'/../myproject/bootstrap/autoload.php';
8. $app = require_once __DIR__.'/../myproject/bootstrap/start.php';
for the 7 and 8 steps give the path where you source has so that file find that files
Hope this is works.

laravel 4 project on shared host displays nothing in browser

I have a problem deploying Laravel 4 on shared hosting server. Currently I have access to cpanel with PHP version is 5.3.28 ( with no ssh access ).
I created the laravel project on my localhost and it worked pretty well. Then I uploaded all laravel project files to the server and I have changed url variable in app/config/app.php from http://localhost to the new address. But when I view my page, browser shows just a blank page.
for testing that, I echoed somthing in index.php and it printed well.
but when I echoed here: Route::get('/', function(){ echo "hello"; } ); nothing appeared in the page.
here is my .htacess file beside index.php in public folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Have you checked the permission of your app/storage folder?
You need to make it writable by the web server.
For example, on my mac, my web user is _www. So you can use following command to make it work.
sudo chown -R _www LARAVEL_PROJECT/app/storage
or
sudo chown -R a+w LARAVEL_PROJECT/app/storage

Categories