17 C
Texas
angeloma
Senior Writer and partner

How to install Laravel PHP Framework on OpenSUSE 15?

OpenSUSE is a Linux distribution, sponsored by SUSE. It is a great new distribution, stable and with outstanding tools like Yast. That’s why more and more developers are using it as their main system, which indicates its broad functionality. So, I will teach you how to install Laravel PHP Framework on OpenSUSE 15.

As you know, we like Laravel, and that’s why we talked about it here. In case you don’t know, Laravel is a PHP framework that pays a lot of mind to the application code. That is to say, it stands out for being very understandable to the user, without leaving aside the speed and security of the data.

So, let’s start to install Laravel PHP Framework on OpenSUSE 15. It’s simple.

0. Prerequisites

The installation of Laravel, should not cost much work, however, there are a series of minimum requirements to be able to do the procedure in the best possible way. First of all, it is necessary to know the Linux terminal.

- Advertisement -

On the other hand, your user must be able to use sudo because packages have to be installed and permission as root is required.

Finally, your computer must be able to run PHP and Apache. Don’t worry, any modern computer should.

1. Upgrade OpenSUSE

The first step to install Laravel PHP on OpenSUSE 15 is to upgrade the operating system. It is recommended to do this at all times.

:~$ sudo zypper up

1.- Upgrade OpenSUSE
1.- Upgrade OpenSUSE

With this your system will have the latest security patches and will be more robust.

2. Install Apache web server

Now you need to install Apache to be able to work more comfortably on your project. To do this, run on a terminal:

:~$ sudo zypper in apache2

2.- Install Apache
2.- Install Apache

Next, enable and start the service.

:~$ sudo systemctl enable apache2
:~$ sudo systemctl start apache2

3.- Start Apache
3.- Start Apache

Set the firewall rule for Apache.

:~$ sudo firewall-cmd --add-service=http --permanent
:~$ sudo firewall-cmd --reload

4.- Set the firewall rule
4.- Set the firewall rule

Now, open your web browser and go to http://IP_SERVER. You will see this.

5.- Apache default page
5.- Apache default page

The image says we don’t have permission to access Apache’s root. Don’t worry, that’s OpenSUSE policy and for now I won’t modify it. So, Apache is installed.

2. Install MariaDB

If you are going to develop in Laravel, you will need a database manager. Laravel supports several, but I will install MariaDB.

:~$ sudo zypper in mariadb

6.- Install MariaDB
6.- Install MariaDB

When the installation is complete. It is necessary to start the MariaDB service. Then, it is time to define a root password using the mysql_secure_installation script.

:~$ sudo systemctl enable mariadb
:~$ sudo systemctl start mariadb

7.- Start the MariaDB service
7.- Start the MariaDB service

:~$ sudo mysql_secure_installation

8.- Using mysql_secure_installation script
8.- Using mysql_secure_installation script

After defining the root password, you will be asked some questions regarding the configuration of the MariaDB server. You can answer as you like, I did it this way.

Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

3. Install PHP

The latest stable version of Laravel requires at least PHP 7.1. It’s a good version. In OpenSUSE 15 version 7.2 is available via official repositories. So there are no problems.

:~$ sudo zypper in php7 php7-openssl php7-pdo php7-mbstring php7-tokenizer php7-xmlreader php7-phar php7-zip php7-xmlwriter php7-ctype php7-json php7-mysql

9.- Insall PHP
9.- Insall PHP

As you can see, I have also installed some PHP modules required by Laravel.

Then, enable PHP module and restart Apache2.

:~$ sudo a2enmod php7
:~$ sudo systemctl apache2

4. Install Laravel PHP Framework

A simple and efficient way to install Laravel PHP Framework on any Linux distribution is with Composer.

Composer is a PHP dependency manager that greatly simplifies the handling of dependencies. So, let’s install it first.

:~$ curl -sS https://getcomposer.org/installer | php
:~$ sudo mv composer.phar /usr/local/bin/composer
:~$ sudo chmod +x /usr/local/bin/composer

10.- Installing Composer
10.- Installing Composer

Next, create a new Laravel project.

:~$ composer create-project --prefer-dist laravel/laravel example

11.- Install Laravel PHP Framework
11.- Install Laravel PHP Framework

Of course, replace example with the name of your project.

12.- Laravel is installed
12.- Laravel is installed

Next, serve your project.

:~$ cd example
:~$ php artisan serve

This will serve you project on http://localhost:8000. However, you can serve the project with a specific host and port. But you have to open the ports.

:~$ sudo firewall-cmd --add-port=8000/tcp --permanent 
:~$ sudo firewall-cmd --add-port=8765/tcp --permanent 
:~$ sudo firewall-cmd --reload
:~$ cd example/
:~$ php artisan serve --host=192.168.250.3 --port=8765

13.- Serve the project
13.- Serve the project

Now, open your web browser and go to http://IP_SERVER:8765/. Or http://localhost:8000 depending on the case.

14.- Laravel default page
14.- Laravel default page

And that’s it.

Conclusion

The installation of Laravel is something simple that can be achieved after a few minutes. Laravel is a very powerful framework that more and more people are using.

Please share this post with your friends.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article