Run PHP script after Azure Web app deployment

Mulansky, Ralf 21 Reputation points

I am having an Azure app Service and I want to upload/deploy an .php file to it an run it right after the upload. I managed to upload it via curl and also start a post deployment script. Unfortunately I can not use the command "php ..." in it because I get an error like: "/opt/Kudu/Scripts/ line 2: exec: php: not found\n" in the logs.
The same occurs if I use the "/api/command" endpoint with the same command. I get the same kind of error in the response.
It seems like the php executable is not known in that environment.
Is there any way to run a php script via the command API or in a post deployment script?

Thanks in advance

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,789 questions
{count} votes

Accepted answer
  1. Andriy Bilous 10,896 Reputation points MVP

    Hello @Mulansky, Ralf

    Here is a simplified diagram of App Service on Linux (almost certain to contain some inaccuracies):

    As the architecture diagram above shows, each container has its /home directory mounted from the file share. This means while the container has everything we need to run the application, the actual application itself is located outside of the container. This allows the Kudu container to also see the application folder. It also allows continuous deployment to deploy to the shared folder and the application is automatically updated without restarting the container.

    When you create a new App Service on Linux, you choose from pre-defined runtime containers - PHP8. However when you push the code to repository and it gets deployed to ASL, the PHP8 container is not going to be the container where the application gets built or custom scripts executed. It is actually going to be in the Kudu container.

    Unfortunately there is no PHP in Kudu container.

    As an option you may use your custom Docker image and add any startup commands you want there

    FROM tiangolo/uwsgi-nginx-flask:python3.6  
    RUN mkdir /code  
    WORKDIR /code  
    ADD requirements.txt /code/  
    RUN pip install -r requirements.txt --no-cache-dir  
    ADD . /code/  
    # ssh  
    ENV SSH_PASSWD "root:Docker!"  
    RUN apt-get update \  
            && apt-get install -y --no-install-recommends dialog \  
            && apt-get update \  
    	&& apt-get install -y --no-install-recommends openssh-server \  
    	&& echo "$SSH_PASSWD" | chpasswd   
    COPY sshd_config /etc/ssh/  
    COPY /usr/local/bin/  
    RUN chmod u+x /usr/local/bin/  
    EXPOSE 8000 2222  
    #CMD ["python", "/code/", "runserver", ""]  
    ENTRYPOINT [""]  

    ENTRYPOINT [""], invokes to start the SSH service and Python server. You can add your deployment script into

    0 comments No comments

0 additional answers

Sort by: Most helpful