Hello there! toady we are going to see about laravel. what is laravel and how to install it in ubuntu
what is laravel?
Laravel is an open-source PHP framework, which is robust and easy to understand. It follows a model-view-controller design pattern. Laravel reuses the existing components of different frameworks which helps in creating a web application. The web application thus designed is more structured and pragmatic.Laravel offers a rich set of functionalities which incorporates the basic features of PHP frameworks like CodeIgniter, Yii and other programming languages like Ruby on Rails. Laravel has a very rich set of features which will boost the speed of web development.
If you are familiar with Core PHP and Advanced PHP, Laravel will make your task easier. It saves a lot time if you are planning to develop a website from scratch. Moreover, a website built in Laravel is secure and prevents several web attacks.
how to install laravel in ubuntu
Step 1.Install Apache web server
$ sudo apt install apache2
Step 2: install some php certificates
- sudo apt update
- sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
- sudo add-apt-repository ppa:ondrej/php
Step 3: Install PHP and additional PHP extensions
- $ sudo apt install php
- $sudo apt install php{bcmath,xml,fpm,mysql,zip,intl,ldap,gd,cli,bz2,curl,mbstring,pgsql,opcache,soap,cgi}
Version
- $ php -v
Step 4: Create Database for Laravel Application -MariaDB
- $ sudo apt install mariadb-server
Once the database server is installed, log into the MariaDB prompt:
- $ sudo mysql -u root -p
Once logged in create the database, database user, and grant all privileges to
the database user.
- CREATE DATABASE laravel_db;
- CREATE USER 'laravel_user'@'localhost' IDENTIFIED BY ‘1234’;
- GRANT ALL ON laravel_db.* TO 'laravel_user'@'localhost';
- FLUSH PRIVILEGES;
- QUIT;
Step 5: Install Composer
- $ curl -sS https://getcomposer.org/installer | php
Next, move the composer file to the /usr/local/bin path.
- $ sudo mv composer.phar /usr/local/bin/composer
Assign execute permission:
- $ sudo chmod +x /usr/local/bin/composer
Verify the Composer version installed:
- $ composer --version
Step 6: Install Laravel 8 Ubuntu
- $ cd /var/www/html
Now, install Laravel using the composer command, type:
- $ sudo composer create-project laravel/ laravelapp
Change the ownership of the Laravel directory to the webserver user and
also the permissions:
- $ sudo chown -R www-data:www-data /var/www/html/filename
- $ sudo chmod -R 775 /var/www/html/filename/storage
Once the installation is done navigate to the installation directory and check theLaravel version.
- $ cd laravelapp
- $ php artisan
Step 7: Configure Apache to serve Laravel site
- $ sudo vim /etc/apache2/sites-available/laravel.conf
<VirtualHost *:80>
ServerName (IP address)
ServerAdmin admin@example.com
DocumentRoot /var/www/html/laravelapp/public
<Directory /var/www/html/laravelapp>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save the changes and exit the file. Next, enable the Laravel site and Apache
rewrite module using these two commands.
- $ sudo a2ensite laravel.conf
- $ sudo a2enmod rewrite
To apply the changes, restart Apache.
- $ sudo systemctl restart apache2
then open ip
thats all for this blog thank you
Comments