You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/app-service/configure-language-php.md
+21-8Lines changed: 21 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,7 +230,7 @@ For more information on how App Service runs and builds PHP apps in Linux, see [
230
230
231
231
## Customize start-up
232
232
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):
234
234
235
235
```azurecli-interactive
236
236
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
266
266
267
267
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.
268
268
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:
270
270
271
271
```
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
277
290
```
278
291
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.
0 commit comments