Skip to content

Commit 7ec034f

Browse files
Merge pull request #248318 from cephalin/cephalin-patch-1-1
https://github.com/MicrosoftDocs/azure-docs/issues/87538
2 parents 824f091 + dc3084f commit 7ec034f

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

articles/app-service/configure-language-php.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ For more information on how App Service runs and builds PHP apps in Linux, see [
230230

231231
## Customize start-up
232232

233-
By default, the built-in PHP container runs the Apache server. At start-up, it runs `apache2ctl -D FOREGROUND"`. If you like, you can run a different command at start-up, by running the following command in the [Cloud Shell](https://shell.azure.com):
233+
If you want, you can run a custom command at the container start-up time, by running the following command in the [Cloud Shell](https://shell.azure.com):
234234

235235
```azurecli-interactive
236236
az webapp config set --resource-group <resource-group-name> --name <app-name> --startup-file "<custom-command>"
@@ -266,17 +266,30 @@ By default, Azure App Service points the root virtual application path (*/*) to
266266

267267
The web framework of your choice may use a subdirectory as the site root. For example, [Laravel](https://laravel.com/), uses the `public/` subdirectory as the site root.
268268

269-
The default PHP image for App Service uses Apache, and it doesn't let you customize the site root for your app. To work around this limitation, add an *.htaccess* file to your repository root with the following content:
269+
The default PHP image for App Service uses Nginx, and you change the site root by [configuring the Nginx server with the `root` directive](https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/). This [example configuration file](https://github.com/Azure-Samples/laravel-tasks/blob/main/default) contains the following snippets that changes the `root` directive:
270270

271271
```
272-
<IfModule mod_rewrite.c>
273-
RewriteEngine on
274-
RewriteCond %{REQUEST_URI} ^(.*)
275-
RewriteRule ^(.*)$ /public/$1 [NC,L,QSA]
276-
</IfModule>
272+
server {
273+
#proxy_cache cache;
274+
#proxy_cache_valid 200 1s;
275+
listen 8080;
276+
listen [::]:8080;
277+
root /home/site/wwwroot/public; # Changed for Laravel
278+
279+
location / {
280+
index index.php index.html index.htm hostingstart.html;
281+
try_files $uri $uri/ /index.php?$args; # Changed for Laravel
282+
}
283+
...
284+
```
285+
286+
The default container uses the configuration file found at */etc/nginx/sites-available/default*. Keep in mind that any edit you make to this file is erased when the app restarts. To make a change that is effective across app restarts, [add a custom start-up command](#customize-start-up) like this example:
287+
288+
```
289+
cp /home/site/wwwroot/default /etc/nginx/sites-available/default && service nginx reload
277290
```
278291

279-
If you would rather not use *.htaccess* rewrite, you can deploy your Laravel application with a [custom Docker image](quickstart-custom-container.md) instead.
292+
This command replaces the default Nginx configuration file with a file named *default* in your repository root and restarts Nginx.
280293

281294
::: zone-end
282295

0 commit comments

Comments
 (0)