Laravel Project Setup

First, get composer if you don’t already have it (Windows):¬†https://getcomposer.org/Composer-Setup.exe

I like to use the composer installer (as opposed to the Laravel Installer). Open command prompt and move into www directory (or wherever you want your project to live).

composer create-project laravel/laravel name-of-project

 

This will create the directory “name-of-project” and place all the laravel files inside at the same time.

Create a database. Use utf8_unicode_ci for the collation.

Next, open up the .env file located at the project root and edit the settings for your project. If using Git, go ahead and edit the .gitignore to add your IDE specific files and any other files you want to ignore. (Tip for Phpstorm users: the .idea folder is not visible within the directory tree inside the IDE. You only see it if you view the files from outside Phpstorm.)

Run

php artisan migrate

to migrate the included migrations.

Laravel on Bluehost Shared Hosting

Project Code

Create new directory at root called “laravel” and put entire project minus the public folder there. Create a new .env file and call it .env.production. Change the values inside that file to reflect the production environment. Upload that file to the production server and rename it to .env.

Public Code: Subdomain

Do this if you want to put the public folder into a subdomain (like for testing). Create your subdomain through cPanel and your directory structure will be /public_html/subdomain. Clear out the “subdomain” folder.

In the public folder, create a new file and call it bluehost.index.php or whatever – just so you know it’s the index file only for the live site. Copy the contents of index.php into it.

Then, change

`require __DIR__.'/../bootstrap/autoload.php';`

to

`require __DIR__.'/../../laravel/bootstrap/autoload.php';`

Change

`$app = require_once __DIR__.'/../bootstrap/app.php';`

to

`$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';

// set the public path to this directory
// so that public_path() still works
$app->bind('path.public', function() {
    return __DIR__;
});`

Now upload the contents of your public folder to the subdomain directory. Rename bluehost.index.php to index.php.

Set up Laravel Environment on Elementary OS

Install Apache, PHP, MySQL

You can probably skip this part if you’re going to only use Homestead. Just skip down to Install Composer.

Apache

Add Apache respository

sudo add-apt-repository ppa:ondrej/apache2

Install Apache

sudo apt-get update
sudo apt-get install apache2

Continue reading “Set up Laravel Environment on Elementary OS”