I have been waiting to write this post for maybe 2 weeks… I struggled so much with setting up Laravel in my Ubuntu, that I said to myself: When I finally get done with installing and running up this shit, I will share the way I did it in the most clarified and easy way that I found, so people don’t have to suffer like I did… I went through try-outs with Homestead, no Homestead, getting the base laravel-master project, and tons of other stuff, but… yeah, doesn’t matter anymore. Let’s continue…
Well, if you are kind of a newbie in Linux and in setting up your PHP environment by yourself (like I am), then this post is gonna be OF GREAT HELP to you (or at least I hope so… ahihihi).
Let’s cut through the crap of “why is Laravel cool”, “why this and that and blah blah”. If you’ve decided to use it and you have stopped on this post, then why change your mind from this technology? – let’s get some stuff done. So, I will separate the post in 2 sections: first for Linux and then for Windows installation of the framework.
Linux
Note: this is a guide of how to install and set up Laravel without Homestead.
Did you try the Laravel installation guide from the official website? If you did try it and you are here, then I have two things to say to you: poor you and I know that feel, bro… When I read the guide now, I do understand its steps and what I have to do, but this is only after I have gone through all the “on my own” research and try-outs and have finally succeeded to install Laravel and set it up correctly. Otherwise, when I first went through that guide, I was like “you wot, mate?!“. And all those if you prefer / you might need / etc. expression in the explanations are really not helping in resolving the mystery. So, basically, I am going to repeat the steps from the official guide, but explaining them in a lot easier way to understand, plus some additional stuff that you would need, in order for everything to run smoothly, instead of thinking “what the hell am I missing now?!“.
0. Install PHP and Curl
Firstly, open a terminal and run the following 2 lines of commands separately:
which php which curl
In case you get output similar to:
/urs/bin/php /usr/bin/curl
Then you can go directly to step 1. Getting to the real deal…
I consider the case of a freshly installed Ubuntu (as it was for me), without PHP installed, so just open a terminal and run the following command:
sudo apt-get install php5
After it’s done, we install Curl:
sudo apt-get install curl
1. Getting to the real deal – Install Composer
Now, that you have both PHP and Curl installed, let’s actually do what we came for – install Composer (the default PHP dependency interpeter, blah, blah, some deep stuff…). Run the following command:
curl -sS https://getcomposer.org/installer | php
And now, it is recommended to move the generated composer.phar file to our /usr/bin/local directory, so that we can access Composer from anywhere in the Terminal. Do that with the following command:
sudo mv composer.phar /usr/local/bin/composer
Then try simply typing composer in the Terminal (no matter where you are atm) and if you get a “fancy” title, drawn with slashes, and then lots of Composer available commands, then everything is good in the hood!
2. Install PHP mcrypt and activate it
Be patient! There is still some crap ahead, before actually getting to installing Laravel itself.
Well, what is omitted in most posts is the consideration that you might NOT have this thingy set up (as in my case, of course…). And because you are lazy and don’t want to search for what the hell is going on, and because we are here to get everything as easily as possible, just run the following command:
Well, what is omitted in most posts is the consideration that you might NOT have this thingy set up (as in my case, of course…). And because you are lazy and don’t want to search for what the hell is going on, and because we are here to get everything as easily as possible, just run the following command:
sudo apt-get install php5-mcrypt
And now activate mcrypt:
sudo php5enmod mcrypt
Now run the following command: php -i | grep mcrypt
And if you see something like that:
And if you see something like that:
mcrypt mcrypt support => enabled mcrypt_filter support => enabled mcrypt.algorithms_dir => no value => no value mcrypt.modes_dir => no value => no value
then EVERYTHING IS GOING ACCORDING TO THE PLAN !!! YEAAAAAAAAAHHHH !!!
3. Install Laravel, finally !
Whew… if you have gone all the way down here successfully, then wipe your armpits from the sweat and continue navigating to the directory where you want your project to reside. F.e., mine is in ~/developer/workspace/web, so I run cd ~/developer/workspace/web (okay, I admit, this is total noob stuff, but I am trying to write the post for a broad audience…
)
Okay, Laravel needs 2 things: PHP and Composer. We’ve got these 2 things already, so, as you are in your desired directory for placing your project, simply run the following command:
composer create-project laravel/laravel name_of_your_project_ahihihi
Wait for all the shit to download and set up. I hope you’re not watching “adult movies” at the same time, so that your Internet connection is slow as f***…
If you don’t see any red fields and stuff, and you get the last line to be looking like this:
If you don’t see any red fields and stuff, and you get the last line to be looking like this:
Application key [A LOT OF RANDOM SYMBOLS IN HERE] set successfully.
then EVERYTHING IS STILL GOING ACCORDING TO THE PLAN !!!
4. Check if all the crap is correctly installed and set up and open your project’s damn home page to see if “you have arrived”
Navigate to your project’s directory and run the ls command. You should see smth like this:
app bootstrap composer.lock phpunit.xml readme.md vendor artisan composer.json CONTRIBUTING.md public server.php
This means your first Laravel project has been generated successfully. You can go pee now… it’s been a lot of pressure…
Now, don’t forget to be in your project’s directory when you call Artisan to serve your project. Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. (copied from the official Laravel website). So… run the following command:
php artisan serve
or
php -S localhost:8000 -t public/
And you (if everything is fine, again…) should see the following line:
Laravel development server started on http://localhost:8000
Yes, yes, you guessed it right… open your browser and type localhost:8000 in the URL bar.
If you see this:
If you see this:

then you can go to sleep peacefully. It’s been a lot of stress for today…
If you don’t get this page, then you can go crouch in the corner of the room and cry silently… and try installing Laravel again, tomorrow.
If you don’t get this page, then you can go crouch in the corner of the room and cry silently… and try installing Laravel again, tomorrow.
I recommend you checking out these tuts: https://laracasts.com/series/laravel-from-scratch/
No comments:
Post a Comment