Skip to content

Instantly share code, notes, and snippets.

@dipenparmar12
Last active September 11, 2020 13:10
Show Gist options
  • Save dipenparmar12/7a605559aae5faa9942d0e6298ec5dc3 to your computer and use it in GitHub Desktop.
Save dipenparmar12/7a605559aae5faa9942d0e6298ec5dc3 to your computer and use it in GitHub Desktop.
Install PHP & Laravel on Linux using Composer

How to Install PHP & Laravel on Linux using Composer.

Update the system packages to the latest versions:

sudo apt-add-repository ppa:ondrej/php

sudo apt update && sudo apt upgrade

Installing PHP

Run the following command to install PHP and all required PHP modules:

sudo apt install php7.2-common php7.2-cli

sudo apt install php7.2-gd php7.2-mysql

sudo apt install php7.2-intl php7.2-mbstring

sudo apt install php7.2-bcmath php7.2-imap

sudo apt install php7.2-xml php7.2-zip

sudo apt install php7.2-curl

or just one command

sudo apt install php7.2-common php7.2-cli php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-mbstring php7.2-bcmath php7.2-imap php7.2-xml php7.2-zip

Installing Composer

Composer is a dependency manager for PHP and we will be using it to download the Laravel core and install all necessary Laravel components.

To install composer globally, download the Composer installer and install it by following command.

sudo apt install curl

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Verify the installation by printing the composer version:

composer --version

The output should look something like this:

Composer version 1.8.0....

Installing Laravel

Run the Composer create-project command to install Laravel in the my_app directory:

composer create-project --prefer-dist laravel/laravel my_app

The process may take few minutes and if it is successful the end of the output should look like the following:

Package manifest generated successfully.
> @php artisan key:generate --ansi
Application key set successfully.

Verifying the Installation and Server,

Now you can start the development server by navigating to the Laravel project directory and executing the artisan serve command:

cd my_app

php artisan serve

The output will look something like this:

Laravel development server started: <http://127.0.0.1:8000>

Open your browser, type http://127.0.0.1:8000

Conclusion

Congratulations, you have successfully installed Laravel on your Linux machine. You can now start developing your application.. .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment