虛擬機器安裝 PHPHub5(一)

thinkcc發表於2017-04-11

開啟 PHPHUB5 官網

訪問GITHUB圖示 -->> 去往PHPHUB5的GITHUB專案

虛擬機器環境

nginx version 1.10.0 need Nginx 1.8+
php version 7.0.7 need PHP 5.6+
mysql version 5.7.11 need Mysql 5.7+
redis version 3.2.0 need Redis 3.0+
memcached version 1.4.25 need Memcached 1.4+
完全符合PHPHUB5的要求

1、克隆程式碼到本地

git clone https://github.com/summerblue/phphub5.git

2、由於不知道什麼是HOMESTEAD,所以我直接進行COMPOSER安裝依賴包(如果COMPOSER是外庫,可以去喝杯茶了)

cd phphub5
composer install

  • Generating optimized class loader
  • Compiling common classes
  • 提示上面的兩行,表示COMPOSER安裝成功

3、生成配置檔案(我更願意說複製一份配置檔案)

cp .env.example .env

4、使用安裝命令

php artisan est:install


  • php artisan key:generate
  • [ErrorException]
  • shell_exec() has been disabled for security reasons
  • 使用上述命令後,提示錯誤,意思為shell_exec()未開啟,請找到php.ini開啟。
  • 上述修改完成後,繼續執行會卡住。輸入:
  • yes
  • 並回車。
  • 提示錯誤

  • Application In Production! *

  • Do you really wish to run this command? (yes/no) [no]:
  • [PDOException]
  • SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)


  • php artisan est:init-rbac
  • [PDOException]
  • SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

  • 以上錯誤未mysql,提示沒有這個使用者(homestead),請返回第3步,在你複製完.env檔案後,修改此檔案內mysql的配置

6、配置HOST檔案我這裡寫的是127.0.0.1,在虛擬機器外面我可以也繫結這個域名,到這個虛擬機器的內網或區域網IP

echo "127.0.0.1 phphub5.app" | sudo tee -a /etc/hosts

7、php部分安裝完成(測試在本機配置域名指向虛擬機器IP成功,需要新增NGINX裡的SERVER來配對域名)
共享一份phphub5或算是laravel的nginx.server配置

    server {
                    listen 80 default_server;
                    #listen [::]:80 default_server ipv6only=on;
                    server_name phphub5.app;
                    index index.html index.htm index.php;
                    root  /home/wwwroot/default/phphub5/public;

                    #error_page   404   /404.html;
                    include enable-php.conf;

                    location /nginx_status
                    {
                            stub_status on;
                            access_log   off;
                    }

                    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                    {
                            expires      30d;
                    }

                    location ~ .*\.(js|css)?$
                    {
                            expires      12h;
                    }

                    location ~ /\.
                    {
                            deny all;
                    }

                    location / {
            try_files $uri $uri/ /index.php?$query_string;
                    }

                    location ~ \.php$ {
                                    fastcgi_pass 127.0.0.1:9000;
                                    fastcgi_index index.php;
                                    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                                    include fastcgi_params;
                    }
                    access_log  /home/wwwlogs/phphub5.access.log;
    }
  • 請修改 .env 檔案為 APP_ENV=local 和 APP_DEBUG=true 。
  • 首頁地址:http://phphub5.app/
  • 管理後臺:http://phphub5.app/admin/
  • 在開發環境下,直接訪問後臺地址即可登入 1 號使用者。
  • 在使用上述方法後訪問phphub5.app的時候,提示error
  • Connection timed out [tcp://127.0.0.1:6379]
  • 上面的redis問題,1是請求不到,有可能是redis啟動不完善。2是redis有警報什麼的,我設定完重啟下好了。
  • 訪問 phphub5.app/admin/ 報404錯誤
  • 是由於沒有在nginx.server中加上最重要的一個路由,所有請求都走index.php。如下:

    location / {
    try_files $uri $uri/ /index.php?$query_string;
    }

今天暫時書寫到這裡,明天繼續,先睡覺了。

本作品採用《CC 協議》,轉載必須註明作者和本文連結

相關文章