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

來源:互聯網
上載者:User
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普通模板項目:

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.