Firstly, you don't have to worry about using root user for SSH for App Service.
App Service uses port 2222 for SSH into your app's container, but that doesn't mean that port 2222 is exposed over the Internet. No matter how you use SSH in your app, all SSH traffic is handled through an endpoint on port 443. As a side note, if you're not using SSH, you don't have to worry about closing port 2222 because it's not exposed to the Internet.
(Port 2222 of the container is accessible only within the bridge network of a private virtual network and is not accessible to an attacker on the internet.)
In order to access the SSH port, as one must first login to the Kudu container via HTTPS/it's not exposed to the Internet.
As a best practice:
You shouldn't install components using SSH because they won't persist. “In general it's not recommended to install stuff over SSH since App Service instances are ephemeral so any time there is a VM rotation your app would be broken in that new instance requiring you to SSH and install the component again.”
If you want to install a particular component, make sure that you do it in a Dockerfile so that the component is included in your Docker image. See this documentation for full information on how to do that.
Additionally:
As for as the root folder PHP, 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:
Configure a PHP app for Azure App Service | Change site root:
Please see this for more details - Things You Should Know: Web Apps and Linux
Kindly let us know if this helps or you need any further help/and share more details about your requirement.