193 views
asked in Laravel by

Laravel 11 installed and configured on Ubuntu 24.04 LTS with MySQL Database

1 Answer

answered by

What is Laravel? Laravel is a free and open-source PHP-based web framework for building web applications. It was created by Taylor Otwell and intended for the development of web applications following the MVC(model–view–controller) architectural pattern and based on Symfony. Step 1: Update System Packages First, update and upgrade your Ubuntu system packages to ensure everything is up-to-date: sudo apt update sudo apt upgrade -y Step 2: Install Apache Install Apache, which will serve your Laravel application: sudo apt install apache2 -y Start and enable Apache to start on boot: sudo systemctl start apache2 sudo systemctl enable apache2 Step 3: Install PHP and Required Extensions Laravel requires PHP 8.1 or newer. Install PHP and common extensions:unzip sudo apt install php php-cli php-fpm php-mysql php-xml php-mbstring php-curl php-zip php-bcmath php-gd unzip -y Step 4: Install MySQL Install MySQL Server to manage your databases: sudo apt install mysql-server -y Secure MySQL installation: sudo mysql_secure_installation Log in to MySQL and create a database and user for Laravel: sudo mysql -u root -p CREATE DATABASE laravel_db; CREATE USER 'laravel_user'@'localhost' IDENTIFIED BY 'Admin@123'; GRANT ALL PRIVILEGES ON laravel_db.* TO 'laravel_user'@'localhost'; FLUSH PRIVILEGES; EXIT; Step 5: Install Composer Composer is a dependency manager for PHP. Install it globally: curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer Step 6: Install Laravel 11 Navigate to the web root directory and install Laravel: cd /var/www/html sudo composer create-project --prefer-dist laravel/laravel laravel_app Step 7: Configure Apache for Laravel Create a new Apache virtual host configuration file for your Laravel project: sudo nano /etc/apache2/sites-available/laravel_app.conf Add the following configuration to the file: &ltVirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/laravel_app/public ServerName 192.168.224.135 &ltDirectory /var/www/html/laravel_app/public> AllowOverride All Require all granted &lt/Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> Enable the new site and the mod_rewrite module for Apache: sudo a2ensite laravel_app.conf sudo a2enmod rewrite sudo systemctl restart apache2 Step 8: Configure Laravel Environment Update the .env file in the Laravel project to configure the database connection: sudo nano /var/www/html/laravel_app/.env Modify the database settings: DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_db DB_USERNAME=laravel_user DB_PASSWORD=Admin@123 Now, Migrate the database. cd /var/www/html/laravel_app php artisan migrate Step 9: Set Directory Permissions Ensure Laravel has the correct permissions to write to the necessary directories: sudo chown -R www-data:www-data /var/www/html/laravel_app sudo chmod -R 775 /var/www/html/laravel_app/storage sudo chmod -R 775 /var/www/html/laravel_app/bootstrap/cache Step 10: Test the Laravel Installation Visit your server's IP address or domain in your web browser: http://192.168.224.135/ You should see the Laravel welcome page. Optional: Set Up SSL with Let's Encrypt To secure your Laravel application with SSL, use Certbot: sudo apt install certbot python3-certbot-apache -y Obtain and configure an SSL certificate: sudo certbot --apache -d example.com -d www.example.com Certbot will handle the installation and configuration of the SSL certificate. Step 11: Finalize the Setup Finally, ensure everything is working: http://192.168.224.135/ Your Laravel 11 application should now be fully configured and accessible via your domain or IP address.

Most popular tags

laravel postgresql laravel-10 replication ha postgresql mongodb laravel-11 mongodb database mongodb tutorial ubuntu 24.04 lts streaming-replication mysql database laravel postgresql backup laravel login register logout database mysql php laravel 11 - login with otp valid for 10 minutes. user and admin registration user and admin login multiauth technlogy asp.net asp.net c# mysql master slave replication centos linux laravel sql server schedule backup autobackup postgresql django python haproxy load balancer install self sign ssl laravel 11 gaurds zabbix 7 how to install graylog on ubuntu 24.04 lts | step-by-step asp.net core mvc .net mvc network upload c# ssl integration sql server on ubuntu 22.04 lts mssql server ms sql server sql server user access in postgres mysql password change cent os linux configure replica laravel 11 socialite login with google account google login kubernetes (k8s) install nginx load balancer install install and configure .net 8.0 in ubuntu 24.04 lts php in iis php with iis php tutorial chirags php tutorials chirags php tutorial chirags tutorial laravel 11 guards mongodb sharding metabase business analytics metabase postgresql 16 to postgresql 17 postgresql migration letsencrypt mongodb crud rocky linux laravel custom captcha laravel 11 captcha laravel captcha mongo dll php.ini debian 12 nginx apache nextcloud gitea in ubuntu git gitea npm error node js mysql ndb cluster mysql cluster ssl oracle login register logout in python debian windows shell batch file bat file time stamp date time shopping cart in laravel centos rhel swap memeory rhel 5.5
...