azure-docs icon indicating copy to clipboard operation
azure-docs copied to clipboard

Web server information is outdated

Open yvztzn opened this issue 3 years ago • 9 comments

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.

yvztzn avatar Oct 04 '21 23:10 yvztzn

@yvztzn, Thanks for the feedback. We are taking a look into this and will get back to you soon.

AjayKumar-MSFT avatar Oct 05 '21 07:10 AjayKumar-MSFT

@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

image

I have entered

  • apache2-foreground, see comment in #79483 and received 403 when navigated to https://mysite.azurewebsites.net

    image

  • apache2ctl -D FOREGROUND, see Customize start-up and received 403 when navigated to https://mysite.azurewebsites.net

    image

  • apache2ctl -D FOREGROUND", see Customize start-up and received 503 when navigated to https://mysite.azurewebsites.net

    image

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 avatar Oct 05 '21 21:10 yvztzn

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.

AjayKumar-MSFT avatar Oct 10 '21 15:10 AjayKumar-MSFT

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;

yvztzn avatar Oct 12 '21 19:10 yvztzn

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.

AjayKumar-MSFT avatar Oct 27 '21 11:10 AjayKumar-MSFT

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?

mardahl avatar Nov 08 '22 07:11 mardahl

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.

selenearzola avatar Nov 16 '22 17:11 selenearzola

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.

mardahl avatar Nov 16 '22 19:11 mardahl

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 avatar Dec 01 '22 13:12 AjayKumar-MSFT

@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.

CamiloTerevinto avatar Feb 07 '23 13:02 CamiloTerevinto

Updates to the doc will be published today. #please-close

cephalin avatar Aug 16 '23 09:08 cephalin