-
-
Notifications
You must be signed in to change notification settings - Fork 91
Update getting started according to new app template #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
08b305b
d925bd4
4dd052a
d289af8
d500dce
48614de
8869175
e120b88
f9415d5
7af5f1b
76ed0f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Configuring web servers: Apache | ||
|
|
||
| Use the following configuration in Apache's `httpd.conf` file or within a virtual host configuration. Note that you | ||
| should replace `path/to/app/public` with the actual path for `app/public`. | ||
|
|
||
| ```apacheconfig | ||
| # Set document root to be "app/public" | ||
| DocumentRoot "path/to/app/public" | ||
|
|
||
| <Directory "path/to/app/public"> | ||
| # use mod_rewrite for pretty URL support | ||
| RewriteEngine on | ||
|
|
||
| # if $showScriptName is false in UrlManager, do not allow accessing URLs with script name | ||
| RewriteRule ^index.php/ - [L,R=404] | ||
|
|
||
| # If a directory or a file exists, use the request directly | ||
| RewriteCond %{REQUEST_FILENAME} !-f | ||
| RewriteCond %{REQUEST_FILENAME} !-d | ||
|
|
||
| # Otherwise forward the request to index.php | ||
| RewriteRule . index.php | ||
|
|
||
| # ...other settings... | ||
| </Directory> | ||
| ``` | ||
|
|
||
| In case you have `AllowOverride All` you can add `.htaccess` file with the following configuration instead of | ||
| using `httpd.conf`: | ||
|
|
||
| ```apacheconfig | ||
| # use mod_rewrite for pretty URL support | ||
| RewriteEngine on | ||
|
|
||
| # if $showScriptName is false in UrlManager, do not allow accessing URLs with script name | ||
| RewriteRule ^index.php/ - [L,R=404] | ||
|
|
||
| # If a directory or a file exists, use the request directly | ||
| RewriteCond %{REQUEST_FILENAME} !-f | ||
| RewriteCond %{REQUEST_FILENAME} !-d | ||
|
|
||
| # Otherwise forward the request to index.php | ||
| RewriteRule . index.php | ||
|
|
||
| # ...other settings... | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Configuring web servers: General | ||
|
|
||
| On a production server, if you don't use Docker, configure your web server to serve only the application's public files. | ||
| Point the document root of your web server to the `app/public` folder. | ||
|
|
||
| > Info: If you're running your Yii application behind a reverse proxy, you might need to configure | ||
| > [Trusted proxies and headers](../../../guide/en/security/trusted-request.md). | ||
|
|
||
| ## Specific server configurations | ||
|
|
||
| - [Nginx](nginx.md) | ||
| - [Apache](apache.md) | ||
| - [Lighttpd](lighttpd.md) | ||
| - [Nginx Unit](nginx-unit.md) | ||
| - [IIS](iis.md) | ||
|
Check notice on line 15 in cookbook/en/configuring-webservers/general.md
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Configuring web servers: IIS | ||
|
Check warning on line 1 in cookbook/en/configuring-webservers/iis.md
|
||
|
|
||
| When you use [IIS](https://www.iis.net/), host the application in a virtual host (Website) where the document | ||
|
Check notice on line 3 in cookbook/en/configuring-webservers/iis.md
|
||
| root points to the `path/to/app/public` folder and configure the website to run PHP. | ||
| In that `public` folder, place a file named `web.config` at `path/to/app/public/web.config`. | ||
| Use the following content: | ||
|
|
||
| ```xml | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <configuration> | ||
| <system.webServer> | ||
| <directoryBrowse enabled="false" /> | ||
| <rewrite> | ||
| <rules> | ||
| <rule name="Hide Yii Index" stopProcessing="true"> | ||
| <match url="." ignoreCase="false" /> | ||
| <conditions> | ||
| <add input="{REQUEST_FILENAME}" matchType="IsFile" | ||
| ignoreCase="false" negate="true" /> | ||
| <add input="{REQUEST_FILENAME}" matchType="IsDirectory" | ||
| ignoreCase="false" negate="true" /> | ||
| </conditions> | ||
| <action type="Rewrite" url="index.php" appendQueryString="true" /> | ||
| </rule> | ||
| </rules> | ||
| </rewrite> | ||
| </system.webServer> | ||
| </configuration> | ||
| ``` | ||
|
|
||
| Also, the following list of Microsoft's official resources could be useful to configure PHP on IIS: | ||
|
Check notice on line 31 in cookbook/en/configuring-webservers/iis.md
|
||
|
|
||
| 1. [How to set up your first IIS website](https://support.microsoft.com/en-us/help/323972/how-to-set-up-your-first-iis-web-site) | ||
|
Check notice on line 33 in cookbook/en/configuring-webservers/iis.md
|
||
| 2. [Configure a PHP Website on IIS](https://docs.microsoft.com/en-us/iis/application-frameworks/scenario-build-a-php-website-on-iis/configure-a-php-website-on-iis) | ||
|
Check notice on line 34 in cookbook/en/configuring-webservers/iis.md
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Configuring web servers: lighttpd | ||
|
Check notice on line 1 in cookbook/en/configuring-webservers/lighttpd.md
|
||
|
|
||
| To use [lighttpd](https://www.lighttpd.net/) >= 1.4.24, put `index.php` in the web root and add the following to the configuration: | ||
|
|
||
| ``` | ||
| url.rewrite-if-not-file = ("(.*)" => "/index.php/$0") | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Configuring web servers: NGINX Unit | ||
|
Check notice on line 1 in cookbook/en/configuring-webservers/nginx-unit.md
|
||
|
|
||
| Run Yii-based apps using [NGINX Unit](https://unit.nginx.org/) with a PHP language module. | ||
|
Check notice on line 3 in cookbook/en/configuring-webservers/nginx-unit.md
|
||
| Here is a sample configuration. | ||
|
Check notice on line 4 in cookbook/en/configuring-webservers/nginx-unit.md
|
||
|
|
||
| ```json | ||
| { | ||
| "listeners": { | ||
| "*:80": { | ||
| "pass": "routes/yii" | ||
| } | ||
| }, | ||
|
|
||
| "routes": { | ||
| "yii": [ | ||
| { | ||
| "match": { | ||
| "uri": [ | ||
| "!/assets/*", | ||
| "*.php", | ||
| "*.php/*" | ||
| ] | ||
| }, | ||
|
|
||
| "action": { | ||
| "pass": "applications/yii/direct" | ||
| } | ||
| }, | ||
| { | ||
| "action": { | ||
| "share": "/path/to/app/public/", | ||
| "fallback": { | ||
| "pass": "applications/yii/index" | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
|
|
||
| "applications": { | ||
| "yii": { | ||
| "type": "php", | ||
| "user": "www-data", | ||
| "targets": { | ||
| "direct": { | ||
| "root": "/path/to/app/public/" | ||
| }, | ||
|
|
||
| "index": { | ||
| "root": "/path/to/app/public/", | ||
| "script": "index.php" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| You can also [set up](https://unit.nginx.org/configuration/#php) your PHP environment or supply a custom `php.ini` | ||
| in the same configuration. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Configuring web servers: Nginx | ||
|
|
||
| To use [Nginx](https://wiki.nginx.org/), install PHP as an [FPM SAPI](https://secure.php.net/install.fpm). | ||
|
Check notice on line 3 in cookbook/en/configuring-webservers/nginx.md
|
||
| Use the following Nginx configuration, replacing `path/to/app/public` with the actual path for | ||
| `app/public` and `mysite.test` with the actual hostname to serve. | ||
|
|
||
| ```nginx | ||
| server { | ||
| charset utf-8; | ||
| client_max_body_size 128M; | ||
|
|
||
| listen 80; ## listen for ipv4 | ||
| #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 | ||
|
|
||
| server_name mysite.test; | ||
| root /path/to/app/public; | ||
| index index.php; | ||
|
|
||
| access_log /path/to/basic/log/access.log; | ||
| error_log /path/to/basic/log/error.log; | ||
|
|
||
| location / { | ||
| # Redirect everything that isn't a real file to index.php | ||
| try_files $uri $uri/ /index.php$is_args$args; | ||
| } | ||
|
|
||
| # uncomment to avoid processing of calls to non-existing static files by Yii | ||
| #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { | ||
| # try_files $uri =404; | ||
| #} | ||
| #error_page 404 /404.html; | ||
|
|
||
| # deny accessing php files for the /assets directory | ||
| location ~ ^/assets/.*\.php$ { | ||
| deny all; | ||
| } | ||
|
|
||
| location ~ \.php$ { | ||
| include fastcgi_params; | ||
| fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
| fastcgi_pass 127.0.0.1:9000; | ||
| #fastcgi_pass unix:/var/run/php8-fpm.sock; | ||
| try_files $uri =404; | ||
| } | ||
|
|
||
| location ~* /\. { | ||
| deny all; | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| When you use this configuration, also set `cgi.fix_pathinfo=0` in the `php.ini` file | ||
| to avoid many unnecessary system `stat()` calls. | ||
|
|
||
| Also, note that when running an HTTPS server, you need to add `fastcgi_param HTTPS on;` so that Yii | ||
| can detect if a connection is secure. | ||
Uh oh!
There was an error while loading. Please reload this page.