Laravel

Install Laravel on Ubuntu

Here are steps to install Laravel into your Ubuntu.

  1. Update Package Lists: Ensure your package lists are up-to-date by running:
    sudo apt update

  2. Install PHP and Required Extensions: Laravel requires PHP and several extensions. Install them using the following command:
    sudo apt install php php-cli php-mbstring php-xml php-zip php-json php-mysql php-curl

  3. Install Composer: Composer is a dependency manager for PHP, required for Laravel. Run the following commands to download and install Composer:
    sudo apt install curl php-cli php-mbstring unzip
    cd ~
    curl -sS https://getcomposer.org/installer -o composer-setup.php
    sudo php composer-setup.php –install-dir=/usr/local/bin –filename=composer

  4. Install Node.js and npm: Laravel Mix requires Node.js and npm. You can install them using the following commands:
    sudo apt install nodejs npm

  5. Install Laravel Installer: Laravel provides a convenient installer for setting up new projects. Install it globally using Composer:
    composer global require laravel/installer

  6. Add Composer Global Bin Directory to PATH: Ensure that Composer’s global bin directory is in your system’s PATH so that you can run the Laravel executable globally:
    echo ‘export PATH=”$HOME/.config/composer/vendor/bin:$PATH”‘ >> ~/.bashrc source ~/.bashrc

  7. Create a New Laravel Project: Once Laravel Installer is installed, you can create a new Laravel project using the following command:
    laravel new my-project

    Replace my-project with your preferred project name.

  8. Set Permissions (Optional): If you encounter any permission issues, especially when writing to storage or bootstrap/cache directories, you might need to adjust the permissions. For example:
    sudo chown -R www-data:www-data /path/to/your/laravel/directory sudo chmod -R 775 /path/to/your/laravel/directory/storage sudo chmod -R 775 /path/to/your/laravel/directory/bootstrap/cache

  9. Replace/path/to/your/laravel/directory with the actual path to your Laravel project directory.

  10. For creating file use:
    sudo touch /etc/apache2/sites-available/devlaravel.conf
    Now open the file :
    sudo nano /etc/apache2/sites-available/devlaravel.conf

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    <VirtualHost *:80>
    ServerName www.devlaravel.com
    DocumentRoot /var/www/html/laravel/
    </VirtualHost>

  11. Now need to run few more commands.

    sudo a2ensite devlaravel.conf
    sudo a2enmod rewrite
    sudo service apache2 status

  12. After that add your domain in host file.
    Folder Path : /etc/host
    127.0.0.1 www.devlaravel.com

Abhinay Singh

Abhinay Singh

About Author

Leave a comment

Your email address will not be published. Required fields are marked *