How to deploy Yii2 Advanced application on a shared Hosting
Steps for deploying yii2 advanced app on a shared hosting
(note : You need to have ssh access to the server, if not: contact your hosting provider)
Generating a SSH Key Pair : open terminal and type the following
ssh-keygen -t dsa
OR
ssh-keygen -t rsa
The out put will be similar to
Generating public/private dsa key pair. Enter file in which to save
the key (~/.ssh/id_dsa): Press [Enter] key Enter passphrase (empty
for no passphrase): Press [Enter] key Enter same passphrase again:
Press [Enter] key Your identification has been saved in ~/.ssh/id_dsa
Your public key has been saved in ~/.ssh/id_dsa.pub The key
fingerprint is:
OR
Generating public/private dsa key pair. Enter file in which to save
the key (~/.ssh/id_dsa): Press [Enter] key Enter passphrase (empty
for no passphrase): Press [Enter] key Enter same passphrase again:
Press [Enter] key Your identification has been saved in ~/.ssh/id_dsa
Your public key has been saved in ~/.ssh/id_dsa.pub The key
fingerprint is:
- Create a directory as .ssh (note the preceding dot) under /home// for your hosting package on the remote host. You will then have to create a file named authorized_keys inside this .ssh directory
- Copy the content of the local ~/.ssh/id_dsa.pub or ~/.ssh/id_rsa.pub file into the authorized_keys file
For connecting your server, open terminal and enter following
ssh -l user remote-server
Replace user with your cpanel username and remote-server with your remote server host name. Enter your cpanel password, terminal will login your remote server using ssh.
Clone your application from git repository
git clone https://username@gitlab.com/username/repository.git public_html
Go to public_html do the following
curl -sS https://getcomposer.org/installer | php
php composer.phar global require "fxp/composer-asset-plugin:1.0.0"
php init
Set environment as Production (recommended)
php composer.phar update
This will download all dependencies and setup your app, don't forget to configure database in main configuration file.
How to install Yii2 framework - advanced template on shared hosting?
You can install it locally and run init to generate the missing files, like described here. After that just upload the application to the shared host through FTP.
Also, Yii2 Practical-A App might be useful to you.
I want to host yii application
Yii applications runs on any servers/hosts that support php.
In this case you need a server or host that support mysql too.
Its related to your website traffic that choice sharing hosting or VPS.
In your application have to exists a file named requirement.php
that shows Yii requirements, of course in Yii2. For Yii1:
- Requirements ¶ After installing Yii, you may want to verify that your server satisfies Yii's requirements. You can do so by accessing
the requirement checker script via the following URL in a Web browser:
http://hostname/path/to/yii/requirements/index.php Yii requires PHP
5.1, so the server must have PHP 5.1 or above installed and available to the web server. Yii has been tested with Apache HTTP server on
Windows and Linux. It may also run on other Web servers and platforms,
provided PHP 5.1 is supported.
However is better your host be on LAMP platform.
Related Topics
Fatal Error - Too Many Open Files
Array Merge on Multidimensional Array
Clean Way to Throw PHP Exception Through Jquery/Ajax and JSON
PHP JSON Encode Output Number as String
Using Comparison Operators in a PHP 'Switch' Statement
Creating a Related or Similar Posts Using PHP & MySQL
Generating Ssh Keys for 'Apache' User
How to Make MySQLi Connect Function
Working with Two Entity Managers in the Same Bundle in Symfony2
Windows 7 PHP + Symfony2 Terribly Slow
In Laravel How to Add Values to a Request Array
How to Remove a Key and Its Value from an Associative Array
Orm/Dao/Datamapper/Activerecord/Tablegateway Differences
Using Regular Expressions to Extract the First Image Source from HTML Codes