<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] # Web服務器設置 為了使Phalcon應用程序的路由能夠正常工作,您需要設置Web服務器以正確處理重定向。流行Web服務器的安裝說明如下: ## PHP-FPM [PHP-FPM](http://php.net/manual/en/install.fpm.php)(FastCGI Process Manager)通常用于處理PHP文件。如今,PHP-FPM與所有基于Linux的PHP發行版捆綁在一起。 在 **Windows** 上,PHP-FPM通過文件 `php-cgi.exe` 位于PHP分發存檔中,您可以使用此腳本啟動它以幫助設置選項。Windows不支持unix套接字,因此該腳本將在端口`9000`上以TCP模式啟動fast-cgi。 使用以下內容創建文件 `php-fcgi.bat` : ```bat @ECHO OFF ECHO Starting PHP FastCGI... set PATH=C:\PHP;%PATH% c:\bin\RunHiddenConsole.exe C:\PHP\php-cgi.exe -b 127.0.0.1:9000 ``` ## PHP內置Web服務器(面向開發人員) 為了加快Phalcon應用程序在開發中的運行速度,最簡單的方法是使用這個內置的PHP服務器。請勿在生產環境中使用此服務器。您需要以下Nginx和Apache的配置。 ### Phalcon配置 To enable dynamic URI rewrites, without Apache or Nginx, that Phalcon needs, you can use the following router file: 要在沒有Apache或Nginx的情況下啟用動態URI重寫,Phalcon需要,您可以使用以下路由器文件:[.htrouter.php](https://github.com/phalcon/phalcon-devtools/blob/master/templates/.htrouter.php) 如果您使用`Phalcon-Devtools`創建了應用程序,則該文件應該已存在于項目的根目錄中,您可以使用以下命令啟動服務器: ```bash $(which php) -S localhost:8000 -t public .htrouter.php ``` 上面命令的解剖: - `$(which php)` - 將插入PHP二進制文件的絕對路徑 - `-S localhost:8000` - 使用提供的方式調用服務器模式 `host:port` - `-t public` - 定義服務器根目錄,這是php將請求路由到公共目錄中的JS,CSS和圖像等靜態資源所必需的 - `.htrouter.php` - 將為每個請求設置的入口點 然后將瀏覽器指向`http://localhost:8000/`以檢查一切是否正常。 ## Nginx [Nginx](http://wiki.nginx.org/Main) 是一個免費的,開源的,高性能的HTTP服務器和反向代理,以及IMAP/POP3代理服務器。與傳統服務器不同,Nginx不依賴線程來處理請求。相反,它使用更加可擴展的事件驅動(異步)架構。 此體架構在負載下使用較小但更重要的可預測內存量。 Phalcon與Nginx和PHP-FPM提供了一套功能強大的工具,可為PHP應用程序提供最高性能。 ### 安裝Nginx [Nginx官網](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/) ### Phalcon配置 您可以使用以下潛在配置來使用Phalcon設置Nginx: ```nginx server { # Port 80 will require Nginx to be started with root permissions # Depending on how you install Nginx to use port 80 you will need # to start the server with `sudo` ports about 1000 do not require # root privileges # listen 80; listen 8000; server_name default; ########################## # In production require SSL # listen 443 ssl default_server; # ssl on; # ssl_session_timeout 5m; # ssl_protocols SSLv2 SSLv3 TLSv1; # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; # ssl_prefer_server_ciphers on; # These locations depend on where you store your certs # ssl_certificate /var/nginx/certs/default.cert; # ssl_certificate_key /var/nginx/certs/default.key; ########################## # This is the folder that index.php is in root /var/www/default/public; index index.php index.html index.htm; charset utf-8; client_max_body_size 100M; fastcgi_read_timeout 1800; # Represents the root of the domain # http://localhost:8000/[index.php] location / { # Matches URLS `$_GET['_url']` try_files $uri $uri/ /index.php?_url=$uri&$args; } # When the HTTP request does not match the above # and the file ends in .php location ~ [^/]\.php(/|$) { # try_files $uri =404; # Ubuntu and PHP7.0-fpm in socket mode # This path is dependent on the version of PHP install fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; # Alternatively you use PHP-FPM in TCP mode (Required on Windows) # You will need to configure FPM to listen on a standard port # https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/ # fastcgi_pass 127.0.0.1:9000; fastcgi_index /index.php; include fastcgi_params; fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } fastcgi_param PATH_INFO $fastcgi_path_info; # fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; # and set php.ini cgi.fix_pathinfo=0 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~ /\.ht { deny all; } location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires max; log_not_found off; access_log off; } } ``` ### 啟動Nginx 通常從命令行`啟動nginx`,但這取決于您的安裝方法。 ## Apache [Apache](http://httpd.apache.org/) 是許多平臺上流行且眾所周知的Web服務器。 ### Phalcon配置 以下是可用于使用Phalcon設置Apache的潛在配置。這些注釋主要關注`mod_rewrite`模塊的配置,允許使用友好URL和路由器組件。通常,應用程序具有以下結構: ```bash test/ app/ controllers/ models/ views/ public/ css/ img/ js/ index.php ``` #### 根目錄 這是最常見的情況,應用程序安裝在文檔根目錄下的任何目錄中。在這種情況下,我們使用兩個`.htaccess`文件,第一個隱藏應用程序代碼,將所有請求轉發到應用程序的文檔根目錄(`public/`)。 >[danger] 請注意,使用`.htaccess`文件需要安裝apache才能設置`AllowOverride All`選項。 ```apacheconfig # test/.htaccess <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule ((?s).*) public/$1 [L] </IfModule> ``` 第二個`.htaccess` 文件位于`public/`目錄中,這會將所有URI重寫為`public/index.php`文件: ```apacheconfig # test/public/.htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L] </IfModule> ``` 對于在uri參數中使用波斯字母'?'(meem)的用戶,`mod_rewrite`存在問題。要使匹配與英文字符一樣工作,您需要更改`.htaccess`文件: ```apacheconfig # test/public/.htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([0-9A-Za-z\x7f-\xff]*)$ index.php?params=$1 [L] </IfModule> ``` 如果您的uri包含英語以外的字符,您可能需要采用上述更改以允許`mod_rewrite`準確匹配您的路由。 #### Apache配置 如果您不想使用`.htaccess`文件,可以將這些配置移動到apache的主配置文件中: ```apacheconfig <IfModule mod_rewrite.c> <Directory "/var/www/test"> RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule ((?s).*) public/$1 [L] </Directory> <Directory "/var/www/test/public"> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L] </Directory> </IfModule> ``` #### 虛擬服務器 第二種配置允許您在虛擬主機中安裝Phalcon應用程序: ```apacheconfig <VirtualHost *:80> ServerAdmin admin@example.host DocumentRoot "/var/vhosts/test/public" DirectoryIndex index.php ServerName example.host ServerAlias www.example.host <Directory "/var/vhosts/test/public"> Options All AllowOverride All Require all granted </Directory> </VirtualHost> ``` ## Cherokee [Cherokee](http://www.cherokee-project.com/) 是一款高性能的網絡服務器。它非常快速,靈活且易于配置。 ### Phalcon配置 Cherokee提供友好的圖形界面,幾乎可以配置Web服務器中的所有可用設置。 切換root管理員權限, 執行`/path-to-cherokee/sbin/cherokee-admin`以啟動Cherokee ![](https://d33wubrfki0l68.cloudfront.net/01e9a2a9ec102b184876ff738dcc0d3640489390/bdc1b/assets/images/content/webserver-cherokee-1.jpg) 單擊`vServers`創建新的虛擬主機,然后添加新的虛擬服務器: ![](https://d33wubrfki0l68.cloudfront.net/d884d2c92e5cea17cf2508587d9572d903a93bc2/12786/assets/images/content/webserver-cherokee-2.jpg) 最近添加的虛擬服務器必定出現在屏幕的左側欄中。在`Behaviors`選項卡中,您將看到此虛擬服務器的一組默認行為。單擊`Rule Management` 按鈕。刪除標記為`Directory /cherokee\_themes`和`Directory /cherokee\_themes`的那些: ![](https://d33wubrfki0l68.cloudfront.net/93c97b67effdb75c3eb088150eb665c4dc57f6b0/564a3/assets/images/content/webserver-cherokee-3.jpg) 使用向導添加`PHP Language`行為。此行為允許您運行PHP應用程序: ![](https://d33wubrfki0l68.cloudfront.net/01e9a2a9ec102b184876ff738dcc0d3640489390/bdc1b/assets/images/content/webserver-cherokee-1.jpg) 通常,此行為不需要其他設置。添加其他行為,這次是在`Manual Configuration`部分。在`Rule Type`中選擇`File Exists`,然后確保啟用了`Match any file`選項: ![](https://d33wubrfki0l68.cloudfront.net/24e6e6e4df5174fdf04eeeb534e4afdb3d030c15/4de52/assets/images/content/webserver-cherokee-5.jpg) 在`Handler`選項卡中,選擇`List & Send`作為處理程序: ![](https://d33wubrfki0l68.cloudfront.net/c24ffd72cf30a0e8e1396772c1a8ea2b5964edfe/14725/assets/images/content/webserver-cherokee-7.jpg) 編輯`Default`行為以啟用URL重寫引擎。將處理程序更改為`Redirection`,然后將以下正則表達式添加到引擎`^(.\*)$`: ![](https://d33wubrfki0l68.cloudfront.net/26232e3503307c399b1a46270d5d44b42e8841f2/a6861/assets/images/content/webserver-cherokee-6.jpg) 最后,確保行為具有以下順序: ![](https://d33wubrfki0l68.cloudfront.net/edac687841340e8fe5578635b62fe3244ce4877f/048bd/assets/images/content/webserver-cherokee-8.jpg) 在瀏覽器中執行應用程序: ![](https://d33wubrfki0l68.cloudfront.net/52113b335e18f88cd46b83d4aaa0ff2a8e9b5793/eea92/assets/images/content/webserver-cherokee-9.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看