Laravel installation on Linux
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.4 php7.4-cli php7.4-mbstring php7.4-xml php7.4-bcmath php7.4-json php7.4-tokenizer php7.4-gd php7.4-xmlrpc php7.4-curl php7.4-zip
sudo apt-get install curl
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer
composer global require laravel/installer
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
mkdir laravel_project
cd laravel_project
composer create-project --prefer-dist laravel/laravel projectName
cd projectName
php artisan serve
Explanation:
1. sudo apt-get update
: Updates the list of available packages and their versions, ensuring the system has the latest information about available software.
2. sudo apt-get install software-properties-common
: Installs the software-properties-common package, which provides an abstraction of the used apt repositories.
3. sudo add-apt-repository ppa:ondrej/php
: Adds a Personal Package Archive (PPA) for PHP maintained by Ondřej Surý.
4. sudo apt-get update
: Updates the package list again to include the newly added PHP repository.
5. sudo apt-get install php7.4 ...
: Installs PHP 7.4 along with various PHP extensions required by Laravel.
6. sudo apt-get install curl
: Installs the Curl package, which is a command-line tool for transferring data with URLs.
7. curl -sS https://getcomposer.org/installer | php
: Downloads and installs Composer (a dependency manager for PHP) by running the installation script retrieved via cURL.
8. sudo mv composer.phar /usr/local/bin/composer
: Moves the Composer executable to a directory in the system's PATH for global access.
9. sudo chmod +x /usr/local/bin/composer
: Grants executable permissions to the Composer binary.
10. composer global require laravel/installer
: Installs the Laravel installer globally using Composer.
11. echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
: Adds the Composer global bin directory to the system's PATH permanently by appending a configuration line to the .bashrc file.
12. source ~/.bashrc
: Reloads the .bashrc file to apply the changes made to the PATH.
13. mkdir laravel_project
: Creates a directory named "laravel_project" (replace with desired project name).
14. cd laravel_project
: Changes the current directory to the newly created "laravel_project" directory.
15. composer create-project --prefer-dist laravel/laravel projectName
: Creates a new Laravel project named "projectName" (replace with desired project name) using Composer and the Laravel installer.
16. cd projectName
: Enters the newly created Laravel project directory.
17. php artisan serve
: Starts the PHP built-in server, allowing you to run the Laravel application locally for development purposes.