azure-docs
azure-docs copied to clipboard
Web server information is outdated
I'm trying to follow to setup a PHP/Laravel application based on this documentation. The wwwroot/public/index.php file is simple and prints out "Hello World!" with information from php_info(). Also the wwwroot/.htaccess file is in place as described in this documentation.
- Navigating to https://mysite.azurewebsites.net/public/index.php returns the html with the greeting and information.
- Navigating to https://mysite.azurewebsites.net/index.php returns 404 with "File not found." as the content.
- Navigating to https://mysite.azurewebsites.net returns 403 with "403 Forbidden nginx/1.14.2" as the content.
So I guess Linux based App Services use nginx rather than Apache. Can someone please update the documentation? What should I do? Is it safe to update nginx configuration in /etc/nginx/*?
Please note that I cannot switch to Windows App Service Plan since I am migrating from there to Linux because of PHP 8.0.
I see #79483 already handled this issue. Somehow feedback isn't shown on the documentation page.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: a3209bb1-99cd-9e32-ae48-2605831aee02
- Version Independent ID: 743bc03e-d0d1-1e9e-acb1-52ae01daa0cc
- Content: Configure PHP apps - Azure App Service
- Content Source: articles/app-service/configure-language-php.md
- Service: app-service
- GitHub Login: @cephalin
- Microsoft Alias: cephalin
@yvztzn, Thanks for the feedback. We are taking a look into this and will get back to you soon.
@RyanHill-MSFT suggested in #79483 to mimic Apache rewrite rules. I followed nginx configuration for Laravel applications. I have overwritten the root
, index
, and location /
sections in the /etc/nginx/sites-enabled/default file but I couldn't re-start nginx because web ssh tells me that the systemctl
command was not found (for good reasons I guess). If I restart the app service then the /etc/nginx/sites-enabled/default file will be reset back to its original version.
From the end-user perspective I wish that I deploy an application which may contain rewrite rules in a custom configuration file. In the case there is one (which will be true for Laravel applications) then those should be applied. If that is not possible with nginx (I'm not an expert but it looks like it is very difficult since nginx does not allow per directory configuration) then Apache should be the default for PHP 8.0 apps.
@RyanHill-MSFT also mentions that it is possible to use Apache via custom startup command. In the startup command text box inside of the general settings
I have entered
-
apache2-foreground
, see comment in #79483 and received 403 when navigated to https://mysite.azurewebsites.net -
apache2ctl -D FOREGROUND
, see Customize start-up and received 403 when navigated to https://mysite.azurewebsites.net -
apache2ctl -D FOREGROUND"
, see Customize start-up and received 503 when navigated to https://mysite.azurewebsites.net
Let's suppose I know the right startup command which allows us to use Apache with PHP 8.0. I couldn't find the right property in the ARM template where I can define the start up command. Which one is it?
We are right now blocked as we cannot use PHP 7.3.
yvztzn, Apologies for the delay! we have an official blog on the steps to setup a custom startup script and to modify the existing NGINX site configuration - NGINX Rewrite Rules for Azure App Service Linux PHP 8.x. Yes, Azure App Service on Linux images using PHP 8.x are now bundled with NGINX instead of Apache. The use of .htaccess files will not work for NGINX as these are used for Apache only.
This is a good feedback for the doc enhancement. So, I have assigned the issue to the content author to review further and update the document as appropriate. Thanks again for sharing your valuable feedback.
Thank you. I will have to look into it and will let you know if it worked.
[2.5 hours later] It works. Thank you!
Note to Laravel developers: do not forget to change the line
root /home/site/wwwroot;
to
root /home/site/wwwroot/public;
Thanks for the follow-up yvztzn and sharing the solution that worked for you. Apologies! it took a while to resolve the issue. Thanks your valuable feedback. As mentioned, your feedback has been shared with the content author to update this doc as as appropriate.
A year later.... Documentation is still talking about Apache and using .htaccess - and it don't work. I am having a hard time selling this to developers, who honestly just get super confused with the documentation. And for good reasons.
Could you please update the DOCS?
Hi everyone, I was facing the same issue, but hopefully, I was able to configure Nginx properly by reading these articles:
1.- https://azureossd.github.io/2021/09/02/php-8-rewrite-rule/index.html
2.- https://techcommunity.microsoft.com/t5/apps-on-azure-blog/configure-nginx-for-php-8-linux-azure-app-service/ba-p/3069373
In summary, we had to add some extra configurations to the Nginx configuration file.
The blog mentioned in earlier posts is fine. Just strange that it is a Microsoft blig, and nobody took the time to add the information to the DOCS.
I'm guessing it could also be put into the deployment yaml file when pushed from Github actions or the likes. Ideally there should be an application setting for defining the nginx root.
Apologies for the delayed response. We have relayed this feedback to our product and content team for review and to update the doc appropriately. Thanks!
@AjayKumar-MSFT it has been over 14 months since this documentation issue was raised, and the documentation is still wrong which leads to time wasted diagnosing non-existent errors.
Please prioritize fixing the documentation to remove any notion of Apache for the PHP 8.0+ versions since Ngnix is what is available.
Updates to the doc will be published today. #please-close