How to install Yii PHP Framework on Debian 9 and Ubuntu 18.04?

0
344
Yii PHP Framework
Yii PHP Framework

Every day we find new and better web applications. This is because more and more are being developed for the web with languages like Python, Ruby or PHP. The latter has several powerful frameworks such as Yii. Today, I will show you how to install Yii PHP on Debian 9 and Ubuntu 18.04.

In order to be pragmatic and flexible, Yii PHP was born. It is a framework for object-oriented PHP development that uses the architectural pattern MVC. What makes it ideal for developing many web applications such as forums, information sites or virtual shopping.

With Yii PHP you will have no licensing problems because it is open source (BSD Licence) which makes it ideal for community, educational or long-range projects.

So, let’s install Yii PHP Framework on Debian 9 and Ubuntu 18.04.

Install Apache web server

If you are going to start developing in PHP is necessary, install a web server. There are several options like Apache web server or Ngnix. Both valid and very good. However, for this tutorial, I will use the Apache web server.

Open a Terminal and run this command:

Then, enable and start the service.

Next, open a web browser and go to HTTP://localhost. If you see this, everything is OK.

Apache default page
Apache default page

Install Yii PHP Framework

Installing Yii PHP is simply because I will do it via Composer which is a dependency manager for PHP that really does wonders. So, the first step is to install Composer.

Open a terminal and run:

1.- Installing Composer
1.- Installing Composer

Now, make composer available to all users from the terminal in the form of a command.

2.- Installing Composer
2.- Installing Composer

Now, install Yii PHP Framework using Composer.

Note: You can change example for the name you want.

3.- Install Yii PHP Framework
3.- Install Yii PHP Framework
4.- Installing Yii PHP Framework
4.- Installing Yii PHP Framework

Now, move the created folder. In my case is example.

5.- Moving the created folder to apache document root
5.- Moving the created folder to apache document root

Next, move to the directory.

To avoid dependency problems with Composer, it is necessary to edit a file inside the example folder.

And add the following:

Like this:

6.- Editing the composer file on the project folder
6.- Editing the composer file on the project folder

Now, let’s make a Virtualhost for Yii PHP.

Copy the Apache default site configuration file. Then, edit it.

And add the following:

One more thing, for all Yii applications the document root is /var/www/html/PROJECT_FOLDER/web. In my case, the VirtualHost file for Yii will be something like this.

7.- Creating a VirtualHost for Yii PHP
7.- Creating a VirtualHost for Yii PHP

Then, it is necessary to assign the corresponding permissions to the folder. It is also necessary to change the owner of the folder to avoid permission problems.

8.- Settings the appropriate permissions to project folder
8.- Settings the appropriate permissions to the project folder

Next, enable the VirtualHost, the rewrite module and finally, restart Apache.

8.- Making the last configurations to Yii
9.- Making the last configurations to Yii

Now start the Yii service. By default, Yii uses port 8080 but you can specify another port if it is busy or unavailable.

10.- Starting Yii PHP
10.- Starting Yii PHP

Now, open your web browser and go to HTTP://localhost:8888.

11.- Yii default page
11.- Yii default page

That message indicates that everything went right.

Conclusion

Yii e sun framework PHP for the development of simple and complex applications standing out for its high performance. It is open source and very well supported at the community level.

Please share this article through your social networks.

Spread the love
  • 7
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here