1. 程式人生 > >Lnmp上安裝Yaf學習(二)

Lnmp上安裝Yaf學習(二)

str 最簡 virtual 去掉 ota 一個 wid home 創建

上一節主要實踐了在Lnmp上安裝Yaf擴展,那麽這一節將測試 Yaf 的一個簡單demo的運行。

一、通過Lnmp 創建 vhost 文件  

[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 文件

技術分享圖片

通過命令:vim /usr/local/nginx/conf/vhost 進行編輯文件修改內容如下

[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.

  其次,查看一下phpinfo()是否正常使用,我繼續往下走。

  cd /home/work/yafstudy

  創建一個index.php的文件,寫入 phpinfo(); 然後再瀏覽器上執行目錄;效果如下:

技術分享圖片

  這個時候webserver開始啟動起來了。下面開啟Yaf 的第一次嘗試。

二、Yaf 的 demo 運行

  訪問路徑: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已經正常運行了。

 

Lnmp上安裝Yaf學習(二)