首頁 後端開發 php教程 yii2框架的下載安裝圖文教程

yii2框架的下載安裝圖文教程

Aug 09, 2017 am 10:36 AM
yii2 圖文 安裝

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;
       }
   }
登入後複製

这是前台项目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;
       }
   }
登入後複製

配置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;
       }
   }
登入後複製

配置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普通模板项目:

 

 

以上是yii2框架的下載安裝圖文教程的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前 By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

Win11系統無法安裝中文語言套件的解決方法 Win11系統無法安裝中文語言套件的解決方法 Mar 09, 2024 am 09:48 AM

Win11系統無法安裝中文語言套件的解決方法

無法在VirtualBox中安裝來賓添加 無法在VirtualBox中安裝來賓添加 Mar 10, 2024 am 09:34 AM

無法在VirtualBox中安裝來賓添加

百度網盤下載成功但是安裝不了怎麼辦? 百度網盤下載成功但是安裝不了怎麼辦? Mar 13, 2024 pm 10:22 PM

百度網盤下載成功但是安裝不了怎麼辦?

如何在Linux上安裝安卓應用程式? 如何在Linux上安裝安卓應用程式? Mar 19, 2024 am 11:15 AM

如何在Linux上安裝安卓應用程式?

在Ubuntu 24.04上安裝和執行Ubuntu筆記應用程式的方法 在Ubuntu 24.04上安裝和執行Ubuntu筆記應用程式的方法 Mar 22, 2024 pm 04:40 PM

在Ubuntu 24.04上安裝和執行Ubuntu筆記應用程式的方法

如何在Ubuntu 24.04上安裝Podman 如何在Ubuntu 24.04上安裝Podman Mar 22, 2024 am 11:26 AM

如何在Ubuntu 24.04上安裝Podman

solidworks2018如何安裝-solidworks2018安裝教學課程 solidworks2018如何安裝-solidworks2018安裝教學課程 Mar 04, 2024 pm 09:00 PM

solidworks2018如何安裝-solidworks2018安裝教學課程

creo怎麼安裝-creo安裝教程 creo怎麼安裝-creo安裝教程 Mar 04, 2024 pm 10:30 PM

creo怎麼安裝-creo安裝教程

See all articles