Deploy with Laravel? - laravel

First Laravel Project.
I want to deploy my Laravel project to a Hoster. I have FTP access to it, but I don't want to tinker with filezilla everytime I change something. Plus my Development and 'Finished' projects has some differences (for example Debugbar and different DataBase authentication. What's the best method to deploy a Laravel Project?

It can be done in many ways. So I am going to give a headstart.
Warning: This might not be everything you need to know. I recommend you to learn more about, deployment,ssh, version controlling, apache vhosts, etc , this is just a headstart
Here is how I do it on my Ubuntu server with apache, php and mysql.
I use Git for version controlling and bitbucket and github for managing repositories.
1 - make my project a git repository.
2 - push the repo to bitbucket.
3 - connect to the remote server through ssh and setup the apache vhosts, databases etc.
create a vhost /etc/apache/sites-available/somesite.com.conf file
add the entry to /etc/hosts file
4 - pull the repo from bitbucket to remote server, create and bring the required changes to the production .env file
5 - do a composer install
6 - run php artisan key:generate and php artisan migrate
7 - turn on the site
run sudo a2ensite somesite.com.conf
run sudo service apache2 reload
now the site its up and ready to go.

Related

Laravel Sail Docker Hub

I've got laravel sail which as I know is few containers (mysql, redis, laravel, ...). Is there an easy way to just pack up the whole thing to ex. Docker Hub and easly download it on production server, and when i update it on localhost and run docker push, just run docker pull. Then everything (like new commands in DockerFile | apt install thing) will be updated and working exacly how it worked on localhost
I read the documentation, but I cannot figure out how docker works and how to easly change project location (Ex. I'm working on project at work, sometimes at home and this will be much easier to run docker push when I need build source code and deploy it)
I'm keeping source code on github, and it's working for dev servers, but to deploy something I have to check all dependencies and DockerFile, .env file and other things to make it works on production.
Thanks for help!
You can use the existing docker-compose.yml and just run docker-compose up -d on production to start all containers. Just be sure to for example disable xdebug on production as it slows down every request.

How to host a Laravel website on Netlify?

I'm trying to host my Laravel website on Netlify.
I was originally using Laravel Forge to deploy and host my website.
The deploy script that was used on Laravel forge was:
cd /home/forge/lucaban.com
git pull origin master
composer install --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.1-fpm reload
if [ -f artisan ]
then
php artisan migrate --force
fi
Is there any way I can host the website on Netlify and run these composer commands? Because I think I can only insert NodeJS commands into the build command input.
I have not yet succeeded getting my website live...
You cannot host a laravel site on Netlify. Check out https://jamstack.org for more about the philosophy behind Netlify's hosting service.
While you can use php in the build environment (composer install should work, though you may want to set PHP_VERSION to 7.2 since the default is 5.6), the build process is intended to create static output files - html, css, js, images, etc - which Netlify can then serve from its CDN without running any more code on the server side. While the comparison is not quite perfect, imagine that the output from your build (limited to 15 minutes and no incoming network connections) is a bunch of files, which are stored on S3 and served as-is. So if you end up with file.php - Netlify would show, not run, the code in the file.
You cannot host a laravel, wordpress, drupal, magento, etc site on Netlify, though it is Netlify and the JAMstack movement's assertion that you don't need a legacy website that runs code at every visit to run much of the web and that there is great value in reducing the dynamic portions of a website to small services, such as form-handling or lambda functions. Here's a case study on a customer who migrated their site from wordpress to Netlify and includes authentication, comments, and e-commerce: https://www.netlify.com/blog/2017/03/16/smashing-magazine-just-got-10x-faster/
You may want to have look at Vapor which is a serverless deployment platform for Laravel:
https://vapor.laravel.com

Moving Laravel project from Windows 7 to Raspbian Jessie

I created a Laravel webapp running on a homestead vm on my Windows 7 machine. I want to take this webapp and move it over to my raspberry pi so it's easily accessible from my other devices, since my decsktop doesn't have a direct connection to my router.
I have my pi setup with apache2 and Laravel all the way to the point that if I create a Laravel project in /var/www using
php ~/composer.phar create-project --prefer-dist laravel/laravel project
Then I can access it through the URL:
192.168.1.232/project/public
However, when I pull the webapp I created on the homestead machine through get and place it in /var/www on the pi, I get a page isnt working, currently unable to handle request error.
Does anyone know what files I would need to change/git ignore to develop Laravel on my windows machine and then pull certain versions to my pi without creating errors?
EDIT: I was able to fix this issue by looking at the git ignored files. Two necessary files, /vendor and .env were being ignored when I pushed my project to git. All I did was recreate the .env file in my project directory on my pi, and move a copy a vendor file over from a project I created on the pi, and my webapp started to work.

How to deploy a Laravel 5 using composer and FTP

I built a project using Laravel 5 on my dev machine and now I'd like to deploy it.
One solution that came to my mind is to upload everything using FTP but I guess there is a better way.
I uploaded the composer.json but I receive tons of errors.
I have ssh/root access but using GIT is not an option.
Make sure you can use composer binary on your server and you are set
upload every file except vendor folder (you may use some FTPS manager that reads git-ignore file and does not upload ignored files)
set permissions to ./storage folder (browse thru this severfault thread)
make sure your web server root is ./public
create env file (that is not going to be changed ever, until you want) and do not overwrite it with "local" env file.
$ composer install (installs everything from composer.lock)
$ composer update (updates from repositories again, do test on local before updating on production)

Deploying Laravel 4 on shared hosting server (hostgator)

I would appreciate your help. I really don't know where else to turn to. I can't deploy a L4 app to Hostgator. I read the guide on the forums, but my shared HG account already has many apps under public_html so deleting it would be catastrophic and a risk I cannot afford to play with.
Is there a way to deploy L4 app like any other normal apps?
What I am trying to do is the following:
home/myuser/public_html/domain.com/laravel/ <--- where the app should live
home/myuser/public_html/domain.com/laravel/dev <--- dev environment
in both of these folders there is a separate git repository (via ssh). with remotes dev and prod
so what I simply want to achieve is:
git push prod
and
git push dev
but when I push, I am getting a message:
dev/bootstrap/../vendor/autoload.php) [function.require]: failed to open stream: No such file or directory
/dev/bootstrap/../vendor/autoload.php' (include_path='.:/opt/php53/lib/php') in
Turns out I had not installed Composer properly.
I solved this by:
adding alias to php 5.3 in .bashrc:
alias php53='/opt/php53/bin/php'
installing Composer:
curl -sS https://getcomposer.org/installer | php53
in composer.json, in the "scripts" replacing php with: /opt/php53/bin/php (alias is not accepted, do not know why)
running
php53 composer.phar install
adding to .htaccess:
AddType application/x-httpd-php53 .php
I created a repository to simplify the installation process(mostly for future visitors) after struggling with it several times.
You can find the repository at https://github.com/ralphowino/laravel-for-hostgator-users or download it via https://github.com/ralphowino/laravel-for-hostgator-users/archive/master.zip

Resources