Commit 3a4c581d by Larry Ullman

Edited

Looks good!
parent ebc8c155
Installing Yii Installing Yii
============== ==============
You can install Yii in two ways, using [Composer](http://getcomposer.org/) or downloading an archive file. You can install Yii in two ways, using [Composer](http://getcomposer.org/) or by downloading an archive file.
The former is the preferred way as it allows you to install new [extensions](structure-extensions.md) The former is the preferred way, as it allows you to install new [extensions](structure-extensions.md) or update Yii by simply running a single command.
or update Yii by running a single command.
> Note: Unlike with Yii 1, standard installations of Yii 2 results in both the framework and an application skeleton being downloaded and installed.
Installing via Composer <a name="installing-via-composer"></a> Installing via Composer <a name="installing-via-composer"></a>
----------------------- -----------------------
If you do not already have Composer installed, you may get it by following the instructions at If you do not already have Composer installed, you may do so by following the instructions at
[getcomposer.org](https://getcomposer.org/download/), or simply [getcomposer.org](https://getcomposer.org/download/). On Linux and Mac OS X, you'll run the following commands:
* on Linux or Mac, run the following commands:
``` ```
curl -s http://getcomposer.org/installer | php curl -s http://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer mv composer.phar /usr/local/bin/composer
``` ```
* on Windows, download and run [Composer-Setup.exe](https://getcomposer.org/Composer-Setup.exe). On Windows, you'll download and run [Composer-Setup.exe](https://getcomposer.org/Composer-Setup.exe).
Please refer to the [Composer Documentation](https://getcomposer.org/doc/) if you encounter any Please refer to the [Composer Documentation](https://getcomposer.org/doc/) if you encounter any
problems or want to learn more about the Composer usage. problems or want to learn more about Composer usage.
With Composer installed, you can install Yii by running the following command under a Web accessible folder: With Composer installed, you can install Yii by running the following command under a Web-accessible folder:
``` ```
composer create-project --prefer-dist yiisoft/yii2-app-basic basic composer create-project --prefer-dist yiisoft/yii2-app-basic basic
...@@ -31,7 +30,7 @@ composer create-project --prefer-dist yiisoft/yii2-app-basic basic ...@@ -31,7 +30,7 @@ composer create-project --prefer-dist yiisoft/yii2-app-basic basic
The above command installs Yii as a directory named `basic`. The above command installs Yii as a directory named `basic`.
> Tip: If you want to install the latest development version of Yii, you may use the following command > Tip: If you want to install the latest development version of Yii, you may use the following command,
which adds a `stability` option: which adds a `stability` option:
``` ```
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
...@@ -44,39 +43,40 @@ Installing from an Archive File <a name="installing-from-archive-file"></a> ...@@ -44,39 +43,40 @@ Installing from an Archive File <a name="installing-from-archive-file"></a>
Installing Yii from an archive file involves two steps: Installing Yii from an archive file involves two steps:
1. Download the archive file from [yiiframework.com](http://www.yiiframework.com/download/yii2-basic); 1. Download the archive file from [yiiframework.com](http://www.yiiframework.com/download/yii2-basic).
2. Unpack the downloaded file to a Web accessible folder. 2. Unpack the downloaded file to a Web-accessible folder.
Other Installation Options <a name="other-installation-options"></a> Other Installation Options <a name="other-installation-options"></a>
-------------------------- --------------------------
The above installation instructions show how to install Yii in terms of a basic Web application that works out of box. The above installation instructions show how to install Yii, which also creates a basic Web application that works out of box.
It is a good start for small projects or if you just start learning Yii. This approach is a good starting point for small projects, or for when you just start learning Yii.
There are other installation options available: But there are other installation options available:
* If you only want to install the core framework and would like to build an application from scratch, * If you only want to install the core framework and would like to build an entire application from scratch,
you may follow the instructions as explained in [Building Application from Scratch](tutorial-start-from-scratch.md). you may follow the instructions as explained in [Building Application from Scratch](tutorial-start-from-scratch.md).
* If you want to start with a more sophisticated application that supports team development environment, * If you want to start with a more sophisticated application, better suited to team development environments,
you may consider [Advanced Application Template](tutorial-advanced-app.md). you may consider installing the [Advanced Application Template](tutorial-advanced-app.md).
Verifying Installation <a name="verifying-installation"></a> Verifying the Installation <a name="verifying-installation"></a>
---------------------- ----------------------
After installation, you can use your browser to access the installed Yii application with the following URL, After installation, you can use your browser to access the installed Yii application with the following URL:
assuming you have installed Yii in a directory named `basic` that is under the document root of your Web server
and the server name is `hostname`,
``` ```
http://hostname/basic/web/index.php http://hostname/basic/web/index.php
``` ```
(This URL assumes you have installed Yii in a directory named `basic`, directly under the Web server document root directory,
and that the server name is `hostname`.)
![Successful Installation of Yii](images/start-app-installed.png) ![Successful Installation of Yii](images/start-app-installed.png)
You should see the above "Congratulations!" page in your browser. If not, please check if your PHP installation satisfies You should see the above "Congratulations!" page in your browser. If not, please check if your PHP installation satisfies
Yii's requirements by using one of the following approaches: Yii's requirements. You can check if the minimum requirements are met using one of the following approaches:
* Use a browser to access the URL `http://hostname/basic/requirements.php` * Use a browser to access the URL `http://hostname/basic/requirements.php`
* Run the following commands: * Run the following commands:
...@@ -86,8 +86,7 @@ Yii's requirements by using one of the following approaches: ...@@ -86,8 +86,7 @@ Yii's requirements by using one of the following approaches:
php requirements.php php requirements.php
``` ```
You should configure your PHP installation so that it meets the minimum requirement of Yii. You should configure your PHP installation so that it meets the minimum requirements of Yii. Most importantly, you should have PHP 5.4 or above. You should also install
In general, you should have PHP 5.4 or above. And you should install
the [PDO PHP Extension](http://www.php.net/manual/en/pdo.installation.php) and a corresponding database driver the [PDO PHP Extension](http://www.php.net/manual/en/pdo.installation.php) and a corresponding database driver
(such as `pdo_mysql` for MySQL databases), if your application needs a database. (such as `pdo_mysql` for MySQL databases), if your application needs a database.
...@@ -95,32 +94,32 @@ the [PDO PHP Extension](http://www.php.net/manual/en/pdo.installation.php) and a ...@@ -95,32 +94,32 @@ the [PDO PHP Extension](http://www.php.net/manual/en/pdo.installation.php) and a
Configuring Web Servers <a name="configuring-web-servers"></a> Configuring Web Servers <a name="configuring-web-servers"></a>
----------------------- -----------------------
> Info: You may skip this sub-section for now if you are just test driving Yii with no intention > Info: You may skip this subsection for now if you are just test driving Yii with no intention
of deploying it to a production server. of deploying it to a production server.
The application installed according to the above instructions should work out of box with either The application installed according to the above instructions should work out of box with either
an [Apache HTTP server](http://httpd.apache.org/) or an [Nginx HTTP server](http://nginx.org/), on an [Apache HTTP server](http://httpd.apache.org/) or an [Nginx HTTP server](http://nginx.org/), on
either Windows or Linux. Windows, Mac OS X, or Linux.
On a production server, you may want to configure your Web server so that the application can be accessed On a production server, you may want to configure your Web server so that the application can be accessed
via the URL `http://hostname/index.php` instead of `http://hostname/basic/web/index.php`. This via the URL `http://hostname/index.php` instead of `http://hostname/basic/web/index.php`. Such configuration
requires pointing the document root of your Web server to the `basic/web` folder. And you may also requires pointing the document root of your Web server to the `basic/web` folder. You may also
want to hide `index.php` from the URL, as described in the [URL Parsing and Generation](runtime-url-handling.md) section. want to hide `index.php` from the URL, as described in the [URL Parsing and Generation](runtime-url-handling.md) section.
In this subsection, we will show how to configure your Apache or Nginx server to achieve these goals. In this subsection, you'll learn how to configure your Apache or Nginx server to achieve these goals.
> Info: By setting `basic/web` as the document root, you also prevent end users from accessing > Info: By setting `basic/web` as the document root, you also prevent end users from accessing
your private application code and sensitive data files that are stored in the sibling directories your private application code and sensitive data files that are stored in the sibling directories
of `basic/web`. This makes your application more secure. of `basic/web`. Denying access to those other folders is a producent security improvement.
> Info: If your application will run in a shared hosting environment where you do not have the permission > Info: If your application will run in a shared hosting environment where you do not have permission
to modify its Web server setting, you may adjust the structure of your application. Please refer to to modify its Web server configuration, you may still adjust the structure of your application for better security. Please refer to
the [Shared Hosting Environment](tutorial-shared-hosting.md) section for more details. the [Shared Hosting Environment](tutorial-shared-hosting.md) section for more details.
### Recommended Apache Configuration <a name="recommended-apache-configuration"></a> ### Recommended Apache Configuration <a name="recommended-apache-configuration"></a>
Use the following configuration in Apache's `httpd.conf` file or within a virtual host configuration. Note that you Use the following configuration in Apache's `httpd.conf` file or within a virtual host configuration. Note that you
should replace `path/to/basic/web` with the actual path of `basic/web`. should replace `path/to/basic/web` with the actual path for `basic/web`.
``` ```
# Set document root to be "basic/web" # Set document root to be "basic/web"
...@@ -142,8 +141,8 @@ DocumentRoot "path/to/basic/web" ...@@ -142,8 +141,8 @@ DocumentRoot "path/to/basic/web"
### Recommended Nginx Configuration <a name="recommended-nginx-configuration"></a> ### Recommended Nginx Configuration <a name="recommended-nginx-configuration"></a>
You should have installed PHP as an [FPM SAPI](http://php.net/install.fpm) for [Nginx](http://wiki.nginx.org/). You should have installed PHP as an [FPM SAPI](http://php.net/install.fpm) to use [Nginx](http://wiki.nginx.org/).
Use the following Nginx configuration and replace `path/to/basic/web` with the actual path of `basic/web`. Use the following Nginx configuration, replacing `path/to/basic/web` with the actual path for `basic/web`.
``` ```
server { server {
...@@ -183,8 +182,8 @@ server { ...@@ -183,8 +182,8 @@ server {
} }
``` ```
When using this configuration, you should set `cgi.fix_pathinfo=0` in the `php.ini` file When using this configuration, you should also set `cgi.fix_pathinfo=0` in the `php.ini` file
in order to avoid many unnecessary system `stat()` calls. in order to avoid many unnecessary system `stat()` calls.
Also note that when running an HTTPS server you need to add `fastcgi_param HTTPS on;` so that Yii Also note that when running an HTTPS server, you need to add `fastcgi_param HTTPS on;` so that Yii
can properly detect if a connection is secure. can properly detect if a connection is secure.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment