How to set up the Laravel framework on Linux?
To set up the Laravel framework on Linux, you need to follow these steps:
- Make sure your Linux system has installed the necessary dependencies such as PHP, Composer, and MySQL. You can use the following commands for installation:
sudo apt-get update
sudo apt-get install php php-mysql php-mbstring php-xml composer mysql-server
- Install the Laravel framework. Run the following command in the terminal:
composer global require laravel/installer
- Create a new Laravel project. Run the following command in the directory where you want to store the project:
laravel new project-name
This will create a Laravel project named project-name.
- environment variables
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password
- Generate an application key. Run the following command in the terminal:
php artisan key:generate
This will generate a unique key for your application.
- Start the development server. Run the following command to start Laravel’s development server:
php artisan serve
You will see a message similar to “Laravel development server started: http://127.0.0.1:8000” indicating that the server has been successfully started.
Now, you have successfully set up the Laravel framework on Linux and can begin developing your application.