上一節主要實踐了在Lnmp上安裝Yaf擴展,那麼這一節將測試 Yaf 的一個簡單demo的運行。php
1、經過Lnmp 建立 vhost 文件 nginx
[root@localhost yaf-3.0.6]# lnmp vhost add +-------------------------------------------+ | Manager for LNMP, Written by Licess | +-------------------------------------------+ | https://lnmp.org | +-------------------------------------------+ Please enter domain(example: www.lnmp.org): yafstudy.com Your domain: yafstudy.com Enter more domain name(example: lnmp.org *.lnmp.org): n domain list: n Please enter the directory for the domain: yafstudy.com Default directory: /home/wwwroot/yafstudy.com: /home/work/yafstudy Virtual Host Directory: /home/work/yafstudy Allow Rewrite rule? (y/n) y Please enter the rewrite of programme, wordpress,discuz,typecho,sablog,typecho rewrite was exist. (Default rewrite: other): You choose rewrite: other Allow access log? (y/n) y Enter access log filename(Default:yafstudy.com.log): You access log filename: yafstudy.com.log Create database and MySQL user with same name (y/n) n Add SSL Certificate (y/n) n
以上操做執行完以後,能夠產生一個vhost 文件git
經過命令:vim /usr/local/nginx/conf/vhost 進行編輯文件修改內容以下github
[root@localhost /]# cat /usr/local/nginx/conf/vhost/yafstudy.com.conf server { listen 80; #listen [::]:80; server_name yafstudy.com; index index.php; root /home/work/yafstudy; include enable-php.conf; if (!-e $request_filename) { rewrite ^/(.*) /index.php?$1 last; } access_log /home/wwwlogs/yafstudy.com.log; } [root@localhost /]#
修改完畢保存重啓 lnmp.web
其次,查看一下phpinfo()是否正常使用,我繼續往下走。shell
cd /home/work/yafstudyvim
建立一個index.php的文件,寫入 phpinfo(); 而後再瀏覽器上執行目錄;效果以下:瀏覽器
這個時候webserver開始啓動起來了。下面開啓Yaf 的第一次嘗試。bash
2、Yaf 的 demo 運行app
訪問路徑:https://github.com/laruence/yaf
1) 在項目的目錄創建一個臨時的文件夾,下載項目的壓縮包
[root@localhost tmp]# wget https://github.com/laruence/yaf/archive/master.zip
2) 經過:unzip master.zip 進行解壓,而後進入到目錄中
因而可知,yaf_cg 它就是那個能夠生成一個最簡單最簡單的項目結構的框架目錄。
3) 運行一下:./yaf_cg 回車
哦呦,提示要帶上項目名稱,那改爲這個樣子吧: ./yaf_cg yafcici 回車。
哦呦,報錯了嘞;shell_exec() has been disabled for security reasons
這裏是php.ini, 中 disable_functions = shell_exec, scandir, ..........
這裏是禁用的危險函數,不能隨便使用,這裏臨時去掉shell_exec, scandir一下下,僞裝看不見。重啓nginx 便可
繼續執行 : ./yaf_cg yafcici 回車。大功告成!以下圖所示:
操做以下命令,將臨時目錄的代碼拷貝到正式的項目目錄中
[root@localhost yafstudy]# cp -rf ../tmp/yaf-master/tools/cg/output/yafstudy/* ./ [root@localhost yafstudy]# ll total 16 drwxr-xr-x. 7 root root 4096 Jan 23 23:01 application drwxr-xr-x. 2 root root 4096 Jan 23 23:01 conf -rw-r--r--. 1 root root 174 Jan 23 23:01 index.php -rw-r--r--. 1 root root 442 Jan 23 23:01 readme.txt
這樣的話咱們看看項目的訪問狀況,以下圖所示:
能夠看到Demo已經正常運行了。