Creating Laravel Project on Ubuntu

Updated on

This entry includes:

  • How to create Laravel project on Ubuntu?
  • How to install PHP on Ubuntu?
  • How to setup Sail?
  • How to setup an alias for Sail?
  • How to deal with some common errors that might occur during installation?

Install PHP on Ubuntu

On Ubuntu, open terminal, type php and press enter. This should install php on your Ubuntu machine. If there is a prompt for Y/n to download packages, choose Y and press enter.

Create Laravel project

Open your terminal and paste the following command. Click enter to execute.

Note: ‘example-app’ is the name of your application. You can change it to whatever name you prefer.

curl -s https://laravel.build/example-app | bash

After setting up your app. cd into the directory by typing the following command and pressing enter on your terminal.

cd example-app

Setup Sail and install MySQL

After executing the above command, your directory on terminal should change to your php app directory (i.e. the directory where example-app files are stored).

Now, type the following command and press enter.

php artisan sail:install

You should see a list of database names on your terminal. First (0) should be MySQL. To install that, type 0 and press enter.

This could 3-4 mins depending on your internet connection.

Making your PHP app live

After the MySQL installation is done, type the following command on your terminal while you are still in the app directory.

./vendor/bin/sail up

Give it a minute the first time you are starting the app and then type your localhost address on the browser and it should show a Laravel page like below. That’s it, you setup your Laravel project successfully.

Some errors you might face when running your app for first time on Ubuntu after executing the above command. Here is how to deal with them.

Setting up alias for Sail

To make your app live, you have to use the ./vendor/bin/sail up every time. Instead, you can use something called as an alias on Ubuntu and just type sail up to start your app. You can do that this way:

Open a new terminal window. Don’t cd into any directory. Type the following command and press enter.

alias sail='bash vendor/bin/sail’

Now, when you cd into your php add directory, you can just do sail up to start your app.


Hi I'm Sudheer. I'm a MSc Advanced Computer Science student at Swansea University in Wales, UK. I share my learning resources on this blog. These include notes I created on various topics, step by step guides on how to implement things and documentation of whatever projects I'm working on.

Leave a Comment