We’re working on a new project in Laravel 5.6 and along the way plan on providing tutorials for several of the Laravel functions and guides. Even a simple Laravel install can seem daunting to someone new on the scene with Composer, Migrations, etc….but using Laravel speeds up the development process and helps you build a really clean and efficient web application.
First we’re running on CentOS 7 64-bit with an Apache – PHP 7.1 and PHP-FPM enabled on the account. For setting the path really only the operating system is relevant, but pointing it out in all our tutorials as we work from SSH.
So you’re reading the documentation on how to install Laravel. Right from the start you’ll notice there isn’t a direct download of the files on their installation documentation any longer. They want you to use Composer and it does make things really easy. We’ll assume you don’t have Composer installed on your system yet.
This downloads the latest release of Composer onto your system. Now at this point it’s only setup to run in your local environment/folder. Chances are once you use Composer you’ll adopt it in other projects as well. So let’s set it up to work globally/server-wide, it’s only one more command.
mv composer.phar /usr/local/bin/composer
This will move the composer.phar file you just downloaded over to the above directory for global use. Next let’s setup laravel/installer globally.
composer global require "laravel/installer"
Make sure to place the composer’s systemwide vendor bin directory in your $PATH so the Laravel executable can be located by your system. If you’re having trouble with this you can follow our guide on How To Set a Systemwide $PATH for Composer and Laravel.
Now the hard part is done and we’re ready to install Laravel. We don’t want the files owned by root, but by the user who will be developing the application. We’ve already setup an account for them so we’ll jump over now.
su - newappuser
Now we’re in the /home/newappuser/ directory, we’ll go one folder deeper.
We’re already in the folder where we want to install Laravel, so go ahead and type the following to setup and install your new Laravel project. Keep in mind “blog” from the command below can be swapped out with any name you want to call your new project.
laravel new blog
The command will run for a few seconds/minutes depending on your server hardware, once completed run a directory listing “ls” in SSH and you will see the newly created folder (named as the above) “blog”. You’re all set now, just browse to domain.com/blog/public and you will see the Laravel splash page.
You may have noticed that in the URL we’re navigating to the /public folder which is where Laravel serves it’s site. You can update your document root or setup htaccess rules so that you can browse to domain.com/blog and see the website. We’ve written a guide on How to Setup an .htaccess file for redirecting to Laravel’s Public Folder.
Leave any questions down below in the comments and we’ll be happy to answer or create new tutorials.