Error 404 Not Found nginx/1.22.0 with App Service and Azure Database for MySQL

Jesús Cova 1 Reputation point
2022-11-27T23:03:41.347+00:00

Hi, I have two services and they are:

  • App service. I installed linux and PHP 8.
  • Azure database for MySQL. Version 5.

I did a small PHP script and it is very basic I click in insert and it stores a new record. It has this files and folders:

  • index.php
  • insert.php
  • connection.php
  • ssl(folder) and it is the BaltimoreCyberTrustRoot.crt

My code for index.php is

<a href="insert.php">
Insert
</a>

My code of insert.php is:

<?php
include('connection.php');
$id = 1;
$numero = 200;
$duenos = 'Pedro Luis2';
$query = "INSERT INTO test (id, numero, duenos) VALUES (".$id.", ".$numero.", '".$duenos."')";

mysqli_query($conn, $query) or die(mysql_error());

My code for connection.php is this one:

<?php
$conn = mysqli_init();
mysqli_ssl_set($conn,NULL,NULL, "ssl/BaltimoreCyberTrustRoot.crt.pem", NULL, NULL);
mysqli_real_connect($conn, 'server', 'user', 'password', 'data_base', 3306, MYSQLI_CLIENT_SSL);
if (mysqli_connect_errno($conn)) {
die('Failed to connect to MySQL: '.mysqli_connect_error());
}

When I go to laravel-jesus-cova-huerta.azurewebsites.net

It displays the button to insert when I click on it, ti displays this:

404 Not Found
nginx/1.22.0

The weird thing is that I run my code in my localhost connected to the mysql azure database it works, but if I run same code in the app service azure and I go to look at it, it does not work and it displays that error, so I wonder what configuration is wrong? or what am I doing wrong? because it is a very small code Thanks

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
994 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,966 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 22,706 Reputation points Moderator
    2022-11-30T16:29:59.057+00:00

    Thanks for reaching here! If you are getting 404 error it means that your web browser was able to connect to the website server or host successfully. But, the requested resource, such as a filename or a specific URL, could not be found.

    Could you please check if asset exists on your server, may be your configuration file is having issue. To check this, open your nginx.conf file and check if your site is utilizing the correct root folder path.

    Also suggest you check the path if it is incorrect. Also, see your configuration file's rewrite rules to make sure they aren't misconfigured.

    Refer to below document link might be helpful:

    https://www.azurephp.dev/2021/09/php-8-on-azure-app-service/
    https://www.schakko.de/2021/09/08/deploying-php-8-0-applications-with-azure-app-service/

    Let us know.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.