Home Backend Development PHP Tutorial Graphic tutorial for downloading and installing the yii2 framework

Graphic tutorial for downloading and installing the yii2 framework

Aug 09, 2017 am 10:36 AM
yii2 Graphics and text Install

1.直接使用归档文件安装yii2的高级模板:

从 yiiframework.com 下载归档文件。

下载yii2的高级模板的压缩文件,

将yii-advanced-app-2.0.12文件夹复制到项目的目录中如下:

查看yii-advanced-app-2.0.12的子集目录发现有backend和frontend,backend为后台项目, frontend为 前台项目:

配置后台项目和前台的项目web服务如下:

这是后台项目backend的nginx配置:

server {
       root   D:/test/yii2_test/yii-advanced-app-2.0.12/advanced/backend/web/;
       index index.php index.html;
       server_name dev.yii2_backend.com;
       # set $yii_bootstrap "index.html";
       set $yii_bootstrap "index.php";
charset utf-8;
location / {
               index $yii_bootstrap;
               try_files $uri $uri/ $yii_bootstrap?$args;
               if (!-e $request_filename) {
                         rewrite (.*) /index.php/$1;
               }
       }
location ~ ^/(protected|framework|nbproject|themes/\w+/views) {
               deny  all;
       }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
               expires      30d;
       }
location ~ .*\.(js|css)?$ {
               expires      7d;
       }
#avoid processing of calls to unexisting static files by yii
       location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
               try_files $uri =404;
       }
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
       #
       location ~ \.php$ {
fastcgi_split_path_info  ^(.+\.php)(.*)$;
#let yii catch the calls to unexising PHP files
               set $fsn /$yii_bootstrap;
               if (-f $document_root$fastcgi_script_name){
                       set $fsn $fastcgi_script_name;
               }
#fastcgi_next_upstream error timeout invalid_header http_500 http_503 http_404;
               #fastcgi_pass unix:/var/run/php5-fpm.sock;
               fastcgi_pass 127.0.0.1:9000;
               include fastcgi_params;
               fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
               fastcgi_param  PATH_INFO                $fastcgi_path_info;
               fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
}
location ~ /\.ht {
               deny  all;
       }
   }
Copy after login

这是前台项目frontend的nginx配置:

server {
       root   D:/test/yii2_test/yii-advanced-app-2.0.12/advanced/frontend/web/;
       index index.php index.html;
       server_name dev.yii2_frontend.com;
       # set $yii_bootstrap "index.html";
       set $yii_bootstrap "index.php";
charset utf-8;
location / {
               index $yii_bootstrap;
               try_files $uri $uri/ $yii_bootstrap?$args;
               if (!-e $request_filename) {
                         rewrite (.*) /index.php/$1;
               }
       }
location ~ ^/(protected|framework|nbproject|themes/\w+/views) {
               deny  all;
       }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
               expires      30d;
       }
location ~ .*\.(js|css)?$ {
               expires      7d;
       }
#avoid processing of calls to unexisting static files by yii
       location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
               try_files $uri =404;
       }
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
       #
       location ~ \.php$ {
fastcgi_split_path_info  ^(.+\.php)(.*)$;
#let yii catch the calls to unexising PHP files
               set $fsn /$yii_bootstrap;
               if (-f $document_root$fastcgi_script_name){
                       set $fsn $fastcgi_script_name;
               }
#fastcgi_next_upstream error timeout invalid_header http_500 http_503 http_404;
               #fastcgi_pass unix:/var/run/php5-fpm.sock;
               fastcgi_pass 127.0.0.1:9000;
               include fastcgi_params;
               fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
               fastcgi_param  PATH_INFO                $fastcgi_path_info;
               fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
}
location ~ /\.ht {
               deny  all;
       }
   }
Copy after login

配置hosts文件如下:

127.0.0.1 dev.yii2_backend.com
127.0.0.1 dev.yii2_frontend.com

通过dev.yii2_backend.com访问后台项目:

通过dev.yii2_frontend.com访问前台项目如下:

2. 使用归档文件安装yii2的普通模板

下载yii2的普通模板如下:

复制普通模板文件到项目目录:

查看该项目子集目录列表:

在该项目的配置文件中设置cookieValidationKey:

在config/web.php文件中设置cookieValidationKey为true

为该项目配置nginx:

server {
       root   D:/test/yii2_test/yii-basic-app-2.0.11/basic/web/;
       index index.php index.html;
       server_name dev.yii2_basic.com;
       # set $yii_bootstrap "index.html";
       set $yii_bootstrap "index.php";
charset utf-8;
location / {
               index $yii_bootstrap;
               try_files $uri $uri/ $yii_bootstrap?$args;
               if (!-e $request_filename) {
                         rewrite (.*) /index.php/$1;
               }
       }
location ~ ^/(protected|framework|nbproject|themes/\w+/views) {
               deny  all;
       }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
               expires      30d;
       }
location ~ .*\.(js|css)?$ {
               expires      7d;
       }
#avoid processing of calls to unexisting static files by yii
       location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
               try_files $uri =404;
       }
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
       #
       location ~ \.php$ {
fastcgi_split_path_info  ^(.+\.php)(.*)$;
#let yii catch the calls to unexising PHP files
               set $fsn /$yii_bootstrap;
               if (-f $document_root$fastcgi_script_name){
                       set $fsn $fastcgi_script_name;
               }
#fastcgi_next_upstream error timeout invalid_header http_500 http_503 http_404;
               #fastcgi_pass unix:/var/run/php5-fpm.sock;
               fastcgi_pass 127.0.0.1:9000;
               include fastcgi_params;
               fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;
#PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
               fastcgi_param  PATH_INFO                $fastcgi_path_info;
               fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
}
location ~ /\.ht {
               deny  all;
       }
   }
Copy after login

配置hosts文件:

127.0.0.1 dev.yii2_backend.com
127.0.0.1        dev.yii2_frontend.com
127.0.0.1        dev.yii2_basic.com

重启nginx:

nginx -s reload

通过dev.yii2_basic.com访问yii2普通模板项目:

 

 

The above is the detailed content of Graphic tutorial for downloading and installing the yii2 framework. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution to the problem that Win11 system cannot install Chinese language pack Solution to the problem that Win11 system cannot install Chinese language pack Mar 09, 2024 am 09:48 AM

Solution to the problem that Win11 system cannot install Chinese language pack

Unable to install guest additions in VirtualBox Unable to install guest additions in VirtualBox Mar 10, 2024 am 09:34 AM

Unable to install guest additions in VirtualBox

What should I do if Baidu Netdisk is downloaded successfully but cannot be installed? What should I do if Baidu Netdisk is downloaded successfully but cannot be installed? Mar 13, 2024 pm 10:22 PM

What should I do if Baidu Netdisk is downloaded successfully but cannot be installed?

How to install Android apps on Linux? How to install Android apps on Linux? Mar 19, 2024 am 11:15 AM

How to install Android apps on Linux?

How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 Mar 22, 2024 pm 04:40 PM

How to Install and Run the Ubuntu Notes App on Ubuntu 24.04

How to install Podman on Ubuntu 24.04 How to install Podman on Ubuntu 24.04 Mar 22, 2024 am 11:26 AM

How to install Podman on Ubuntu 24.04

How to install solidworks2018-solidworks2018 installation tutorial How to install solidworks2018-solidworks2018 installation tutorial Mar 04, 2024 pm 09:00 PM

How to install solidworks2018-solidworks2018 installation tutorial

How to install creo-creo installation tutorial How to install creo-creo installation tutorial Mar 04, 2024 pm 10:30 PM

How to install creo-creo installation tutorial

See all articles