locked
How do I install packages on my Linux Web App (and make them persist)? RRS feed

  • Question

  • I'm trying to install a PHP app on a Azure Linux Web App and one of the prerequisites is Mcrypt.

    I am aware that Mcrypt has been superseded by OpenSSL, but like I said it is a prerequisite for the app I am trying to install, so any commentary around this will not be helpful.

    To get Mcrypt to work, I need to install the "libmcrypt-dev" package, which is easy enough to do manually with:

    apt-get -y install libmcrypt-dev

    But I have found after the app is restarted the package disappears. After some rather extensive searching online I managed to find one blog post from Microsoft back in 2017 which described why this happens, and it makes sense, but isn't particularly helpful.

    https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/#PersistHome

    Files outside of /home are not persisted. The blog post says to install packages via a Dockerfile, and the documentation linked to is again unhelpful. It talks about creating a custom Docker image which seems to be a long and complicated process to achieve a simple task. There has to be an easier way.

    I've tried putting the apt-get command above in the Stack Settings Startup Command to do the install on container startup, but that resulted in a ":( Application Error". Interestingly the diagnostics suggested the package was installing before the container restarted again without reason, possibly due to a startup timeout.

    Could anyone suggest how I could get libmcrypt-dev to install and persist?


    MrGoodBytes

    Friday, May 24, 2019 6:40 AM

All replies

  • Hi,

    Are you using blessed image?

    If yes, then you can use startup script to resolve this. 

    We can have the option to run a custom startup script for our PHP blessed images. This is a very new addition so until documentation is added , you can use the following example. 

    Create a Bash Script - 

    1. Using SSH, go to "/home" directory and create a file called "test.sh" using your favorite editor.
    2. Add following content. 

    #!/bin/bash

     

    apt-get update

    apt-get -y install libmcrypt-dev

    /usr/sbin/apache2ctl -D FOREGROUND

     

    NOTE:  Always ensure that "/usr/sbin/apache2ctl -D FOREGROUND" is in the script or your container will not start. 

    Saving the Changes - 

    1. In the Azure Portal, go to the Application Settings section for your PHP Linux App.
    2. In the "Startup File" section, add "/home/test.sh" and press save.
    Friday, May 24, 2019 8:49 AM