Install Composer on Azure web apps(Linux)

Sneha Rao 60 Reputation points
2024-02-13T16:27:37.1866667+00:00

I've made a website with Drupal 10, used Composer on my localhost. Then I migrated it to client's server(Azure web app Linux) using Github action CI/CD. The website works great. Now We have new requirement where I have to install library. As we can not install library without composer. I can see composer folder already on the server. How to install composer on the server? If i install will composer folder be overwrite? will it affect on website?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. SnehaAgrawal-MSFT 22,706 Reputation points Moderator
    2024-02-14T12:28:20.3+00:00

    @Sneha Rao Please use following steps in order to install & use composer in Azure App Service Linux

    1. Go to your KUDU console https://<sitename>.scm.azurewebsites.net or you can search Advanced Tools  & click on Go button as shown below:

    image.png

    1. Select WebSSH on the Kudu page to enter into the app container.
    2. Create a directory called ext inside your /home/site folder & download composer.phar by running the following commands : mkdir /home/site/ext curl -sS https://getcomposer.org/installer | php image.png
    3. Once composer.phar is installed , it can be run locally from the directory using php composer.phar, but to access composer globally, it has to be added into /usr/local/bin/composer directory during app container startup. To do this, create the startup.sh under /home/startup.sh like so: cd /home vi startup.sh Press “i” on your keyboard to start editing and add the following. cp /home/site/ext/composer.phar /usr/local/bin/composer Once, added, press Press “Esc”, then “:wq!” and enter to save. image.png
    4. Now provide the startup.sh file in App Service Application by selecting Configuration blade & then selecting General Settings and adding following command (/home/startup.sh) under Startup Command as shown below: image.png
    5. After restarting the application, you can access composer globally in Kudu console & all changes made to application inside /home directory will persist.

    image.png

    Once Composer is installed globally, you can use it to manage dependencies in your PHP projects. Links- https://learn.microsoft.com/en-us/azure/app-service/configure-language-php?pivots=platform-linux

    https://azureossd.github.io/2019/01/29/azure-app-service-linux-adding-php-extensions/

    Let us know if further query.

    3 people found this answer helpful.

0 additional answers

Sort by: Most helpful

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.