Yii (pronounced Yee or [ji:]) is a free and open-source, quick, excessive efficiency, safe, versatile but pragmatic, and environment friendly generic internet programming framework for growing every kind of internet functions utilizing PHP.

On this article, you’ll learn to set up the newest model of the Yii framework in Ubuntu LTS (long-term assist) releases to begin growing fashionable PHP Net functions.

Platform Assist

Yii holds the next Ubuntu LTS (long-term assist) releases:

  • Ubuntu 20.04 LTS (“Focal”)
  • Ubuntu 18.04 LTS (“Bionic”)
  • Ubuntu 16.04 LTS (“Xenial”)

Necessities

  • A operating occasion of the Ubuntu server.
  • A LEMP stack with PHP 5.4.zero or above.
  • A Composer – an application-level bundle supervisor for the PHP.

There are two methods to put in Yii, utilizing the Composer bundle supervisor or by putting in it from an archive file. The previous is the beneficial method, because it allows you to set up new extensions or replace Yii by a single command.

Putting in Yii Framework by way of Composer in Ubuntu

If you happen to don’t have Composer put in, you’ll be able to set up it utilizing the next instructions, which can later set up Yii and handle its dependencies.

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

How to Install the Ubuntu Yii PHP FrameworkSet up Composer in Ubuntu

After you have composer put in, transfer into the listing /var/www/html/ which can retailer your internet functions or web sites recordsdata, then set up the Yii bundle utilizing the composer (substitute testproject with the title of your internet software’s listing).

$ cd /var/www/html/
$ composer create-project –prefer-dist yiisoft/yii2-app-basic testproject

How to Install the Ubuntu Yii PHP FrameworkSet up Yii Framework in Ubuntu

Operating Yii Utilizing PHP Growth Server

At this level, you might be prepared to begin utilizing the Yii framework for improvement. To run the PHP improvement server, transfer into the testprojects listing (your listing title needs to be completely different relying on what you specified within the earlier command), then launch the event server. By default, it ought to run on port 8080.

$ cd /var/www/html/testproject/
$ php yii serve

How to Install the Ubuntu Yii PHP FrameworkRun Yii Growth Server

To run the event server on one other port, for instance, port 5000, use the –port flag as proven.

$ php yii serve –port=5000

How to Install the Ubuntu Yii PHP FrameworkRun Yii Growth Server on Totally different Port

Then open your internet browser and navigate utilizing the next deal with:

http://SERVER_IP:8080
OR
http://SERVER_IP:5000

Operating Yii Mission in Manufacturing Utilizing an NGINX HTTP Server

To deploy and entry a Yii software in manufacturing, requires an HTTP server reminiscent of NGINX, Apache/HTTPD, or every other supported Net server software program.

To entry the Yii software with out typing your port, you could create the required DNS A file to level your area to your Yii framework software server.

How to Install the Ubuntu Yii PHP FrameworkSet Area A Document for Yii Utility

For this information, we’ll present how one can deploy a Yii software with NGINX. So, you could create a digital host or server block configuration file underneath the /and so on/nginx/sites-available/ listing on your software in order that NGINX can serve it.

$ sudo vim /and so on/nginx/sites-available/testproject.me.conf

Copy and paste the next configuration in it (substitute testprojects.me and www.testprojects.me along with your area title). Additionally specify the means NGINX will move FastCGI requests to PHP-FPM, on this instance, we’re utilizing a UNIX socket (/run/php/php7.4-fpm.sock):

server {
set $host_path “/var/www/html/testproject”;
#access_log /www/testproject/log/entry.log predominant;

server_name testprojects.me www.testprojects.me;
root $host_path/internet;
set $yii_bootstrap “index.php”;

charset utf-8;

location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}

location ~ ^/(protected|framework|themes/w+/views) {
deny all;
}

#keep away from processing of calls to unexisting static recordsdata by yii
location ~ .(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}

# move the PHP scripts to FastCGI server listening on UNIX socket
location ~ .php {
fastcgi_split_path_info ^(.+.php)(.*)$;

#let yii catch the calls to unexising PHP recordsdata
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
embody fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fsn;

#PATH_INFO and PATH_TRANSLATED might be omitted, however RFC 3875 specifies them for CGI
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fsn;
}

# stop nginx from serving dotfiles (.htaccess, .svn, .git, and so on.)
location ~ /. {
deny all;
access_log off;
log_not_found off;
}
}

Save the file and shut it.

Then test the NGINX configuration syntax for correctness, whether it is Okay, allow the brand new software as proven:

$ sudo nginx -t
$ sudo ln -s /and so on/nginx/sites-available/testprojects.me.conf /and so on/nginx/sites-enabled/testprojects.me.conf

Then restart the NGINX service to use the brand new adjustments:

$ sudo systemctl restart nginx

Return to your internet browser and navigate along with your area title.

http://testprojects.me
OR
http://www.testprojects.me

How to Install the Ubuntu Yii PHP FrameworkEntry Yii Utility Utilizing Area

Allow HTTPS on Yii Purposes Utilizing Let’s Encrypt

Lastly, you could allow HTTPS in your web site. You possibly can both use a free Let’s Encrypt SSL/TLS certificates (which is automated and acknowledged by all fashionable internet browsers) or purchase a certificates from a business CA.

If you happen to resolve to make use of a Let’s Encrypt certificates, it may be mechanically put in and configured utilizing the certbot software. To put in certbot, you could set up snapd to put in it.

$ sudo snap set up –classic certbot

Then use certbot to acquire and set up/configure your free SSL/TLS certificates to be used with NGINX internet server (present a legitimate e-mail for renewal and observe the prompts to finish the set up):

$ sudo certbot –nginx

How to Install the Ubuntu Yii PHP FrameworkAllow HTTPS on Yii Nginx Utility

Now go to your internet browser as soon as extra time to verify that your Yii software is now operating on HTTPS (keep in mind HTTP ought to mechanically redirect to HTTPS).

http://testprojects.me
OR
http://www.testprojects.me

How to Install the Ubuntu Yii PHP FrameworkYii Utility Operating on HTTPS

For extra info reminiscent of connecting your software to a database, see the Yii framework documentation from the official Yii undertaking web site. Give it a try to share your ideas about Yii or ask any questions by way of the suggestions kind under.

If You Admire What We Do Right here On TecMint, You Ought to Take into account:

TecMint is the quickest rising and most trusted neighborhood website for any sort of Linux Articles, Guides and Books on the net. Thousands and thousands of individuals go to TecMint! to look or browse the hundreds of printed articles accessible FREELY to all.

If you happen to like what you might be studying, please think about shopping for us a espresso ( or 2 ) as a token of appreciation.

How to Install the Ubuntu Yii PHP Framework

We’re grateful on your by no means ending assist.

yii vs laravel,yii run application,yii tutorial,yii2 download,how to run yii project in xampp,could not open input file: yii,how to install yii framework on ubuntu,download yii php framework,install yii framework using composer,install yii framework centos 7,yii serve,yii2 advanced,how to install yii using composer,install yii2 advanced