[{"data":1,"prerenderedAt":606},["ShallowReactive",2],{"post-\u002Finstall-composer-on-ubuntu":3},{"page":4,"translation":476,"nav":478,"related":591,"random":600},{"id":5,"title":6,"body":7,"categories":458,"category":460,"date":461,"description":462,"draft":463,"extension":464,"image":465,"kind":460,"lang":466,"meta":467,"navigation":468,"path":469,"readingTime":451,"seo":470,"slug":471,"stem":471,"tags":472,"translationKey":471,"type":459,"updated":474,"__hash__":475},"posts\u002Finstall-composer-on-ubuntu.md","How to Install Composer on Ubuntu \u002F Linux",{"type":8,"value":9,"toc":448},"minimark",[10,69,72,75,80,174,176,181,184,187,212,215,248,250,254,257,260,290,294,297,344,351,353,357,364,385,388,396,399,411,413,417,420,432,435,441,444],[11,12,13,21],"blockquote",{},[14,15,16,17],"p",{},"💡 ",[18,19,20],"strong",{},"TL;DR:",[22,23,24,31,55],"ul",{},[25,26,27,30],"li",{},[18,28,29],{},"Goal:"," Install Composer (the PHP package manager) globally on Ubuntu (20.04 \u002F 22.04 \u002F 24.04 LTS) and Debian-based systems.",[25,32,33,36,37,41,42,41,45,41,48,41,51,54],{},[18,34,35],{},"Pre-requisites:"," PHP CLI and common extensions (",[38,39,40],"code",{},"curl",", ",[38,43,44],{},"php-cli",[38,46,47],{},"php-mbstring",[38,49,50],{},"git",[38,52,53],{},"unzip",") must be installed first.",[25,56,57,60,61,64,65,68],{},[18,58,59],{},"Global Access:"," Install to ",[38,62,63],{},"\u002Fusr\u002Flocal\u002Fbin\u002Fcomposer"," to allow running the ",[38,66,67],{},"composer"," command system-wide.",[14,70,71],{},"Composer is a popular dependency and package manager used in most PHP projects. If you are a PHP developer, installing Composer is the next step after you install the web and database servers on your development environment. Installing Composer is not that hard on Windows, and the good news is that it is even easier on Ubuntu (tested on Ubuntu 20.04, 22.04, and 24.04 LTS).",[73,74],"hr",{},[76,77,79],"h3",{"id":78},"required-packages-for-composer-on-ubuntu","Required Packages for Composer on Ubuntu",[81,82,83,100],"table",{},[84,85,86],"thead",{},[87,88,89,94,97],"tr",{},[90,91,93],"th",{"align":92},"left","Package Name",[90,95,96],{"align":92},"Purpose \u002F Description",[90,98,99],{"align":92},"Why Composer Needs It",[101,102,103,118,132,146,160],"tbody",{},[87,104,105,112,115],{},[106,107,108],"td",{"align":92},[18,109,110],{},[38,111,44],{},[106,113,114],{"align":92},"PHP Command Line Interface.",[106,116,117],{"align":92},"Required to run PHP code and Composer scripts in the terminal.",[87,119,120,126,129],{},[106,121,122],{"align":92},[18,123,124],{},[38,125,47],{},[106,127,128],{"align":92},"Multi-byte String extension.",[106,130,131],{"align":92},"Handles non-ASCII strings in packages and dependencies.",[87,133,134,140,143],{},[106,135,136],{"align":92},[18,137,138],{},[38,139,40],{},[106,141,142],{"align":92},"Command-line tool for transferring data.",[106,144,145],{"align":92},"Used to download the Composer installer script.",[87,147,148,154,157],{},[106,149,150],{"align":92},[18,151,152],{},[38,153,50],{},[106,155,156],{"align":92},"Version control system.",[106,158,159],{"align":92},"Downloads packages hosted on GitHub\u002FGitLab directly.",[87,161,162,168,171],{},[106,163,164],{"align":92},[18,165,166],{},[38,167,53],{},[106,169,170],{"align":92},"Archive utility for ZIP files.",[106,172,173],{"align":92},"Extracts compressed dependency packages from Packagist.",[73,175],{},[177,178,180],"h2",{"id":179},"_1-install-php-and-required-dependencies-first","1. Install PHP and Required Dependencies First",[14,182,183],{},"You need to install PHP first if it is not already available on your system.",[14,185,186],{},"First, update the package manager's database:",[188,189,194],"pre",{"className":190,"code":191,"language":192,"meta":193,"style":193},"language-bash shiki shiki-themes github-light github-dark","sudo apt update\n","bash","",[38,195,196],{"__ignoreMap":193},[197,198,201,205,209],"span",{"class":199,"line":200},"line",1,[197,202,204],{"class":203},"sScJk","sudo",[197,206,208],{"class":207},"sZZnC"," apt",[197,210,211],{"class":207}," update\n",[14,213,214],{},"Next, install PHP CLI and other utilities using the following command:",[188,216,218],{"className":190,"code":217,"language":192,"meta":193,"style":193},"sudo apt install curl php-cli php-mbstring git unzip -y\n",[38,219,220],{"__ignoreMap":193},[197,221,222,224,226,229,232,235,238,241,244],{"class":199,"line":200},[197,223,204],{"class":203},[197,225,208],{"class":207},[197,227,228],{"class":207}," install",[197,230,231],{"class":207}," curl",[197,233,234],{"class":207}," php-cli",[197,236,237],{"class":207}," php-mbstring",[197,239,240],{"class":207}," git",[197,242,243],{"class":207}," unzip",[197,245,247],{"class":246},"sj4cs"," -y\n",[73,249],{},[177,251,253],{"id":252},"_2-download-and-verify-composer-installer","2. Download and Verify Composer Installer",[14,255,256],{},"Installing Composer is very simple because it provides an installation wizard written in PHP.",[14,258,259],{},"Switch to your home directory and download the Composer installer script:",[188,261,263],{"className":190,"code":262,"language":192,"meta":193,"style":193},"cd ~\ncurl -sS https:\u002F\u002Fgetcomposer.org\u002Finstaller -o composer-setup.php\n",[38,264,265,273],{"__ignoreMap":193},[197,266,267,270],{"class":199,"line":200},[197,268,269],{"class":246},"cd",[197,271,272],{"class":207}," ~\n",[197,274,276,278,281,284,287],{"class":199,"line":275},2,[197,277,40],{"class":203},[197,279,280],{"class":246}," -sS",[197,282,283],{"class":207}," https:\u002F\u002Fgetcomposer.org\u002Finstaller",[197,285,286],{"class":246}," -o",[197,288,289],{"class":207}," composer-setup.php\n",[76,291,293],{"id":292},"optional-but-recommended-verify-the-installer-security","(Optional but Recommended) Verify the Installer Security",[14,295,296],{},"To ensure that the installer was not corrupted or modified during download, you can verify its SHA-384 hash using the latest signature from the Composer website:",[188,298,300],{"className":190,"code":299,"language":192,"meta":193,"style":193},"HASH=\"$(wget -q -O - https:\u002F\u002Fcomposer.github.io\u002Finstaller.sig)\"\nphp -r \"if (hash_file('sha384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;\"\n",[38,301,302,327],{"__ignoreMap":193},[197,303,304,308,312,315,318,321,324],{"class":199,"line":200},[197,305,307],{"class":306},"sVt8B","HASH",[197,309,311],{"class":310},"szBVR","=",[197,313,314],{"class":207},"\"$(",[197,316,317],{"class":203},"wget",[197,319,320],{"class":246}," -q",[197,322,323],{"class":246}," -O",[197,325,326],{"class":207}," - https:\u002F\u002Fcomposer.github.io\u002Finstaller.sig)\"\n",[197,328,329,332,335,338,341],{"class":199,"line":275},[197,330,331],{"class":203},"php",[197,333,334],{"class":246}," -r",[197,336,337],{"class":207}," \"if (hash_file('sha384', 'composer-setup.php') === '",[197,339,340],{"class":306},"$HASH",[197,342,343],{"class":207},"') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;\"\n",[14,345,346,347,350],{},"If it outputs ",[38,348,349],{},"Installer verified",", you are safe to proceed.",[73,352],{},[177,354,356],{"id":355},"_3-install-composer-globally","3. Install Composer Globally",[14,358,359,360,363],{},"Start the installer using the command below to install Composer globally under ",[38,361,362],{},"\u002Fusr\u002Flocal\u002Fbin",":",[188,365,367],{"className":190,"code":366,"language":192,"meta":193,"style":193},"sudo php composer-setup.php --install-dir=\u002Fusr\u002Flocal\u002Fbin --filename=composer\n",[38,368,369],{"__ignoreMap":193},[197,370,371,373,376,379,382],{"class":199,"line":200},[197,372,204],{"class":203},[197,374,375],{"class":207}," php",[197,377,378],{"class":207}," composer-setup.php",[197,380,381],{"class":246}," --install-dir=\u002Fusr\u002Flocal\u002Fbin",[197,383,384],{"class":246}," --filename=composer\n",[14,386,387],{},"The installer will download and install Composer automatically. When you see a message like the one below, then you are done:",[188,389,394],{"className":390,"code":392,"language":393,"meta":193},[391],"language-text","All settings correct for using Composer\nDownloading...\n\nComposer (version 2.7.7) successfully installed to: \u002Fusr\u002Flocal\u002Fbin\u002Fcomposer\nUse it: php \u002Fusr\u002Flocal\u002Fbin\u002Fcomposer\n","text",[38,395,392],{"__ignoreMap":193},[14,397,398],{},"After the installation is complete, clean up the installer script:",[188,400,402],{"className":190,"code":401,"language":192,"meta":193,"style":193},"rm composer-setup.php\n",[38,403,404],{"__ignoreMap":193},[197,405,406,409],{"class":199,"line":200},[197,407,408],{"class":203},"rm",[197,410,289],{"class":207},[73,412],{},[177,414,416],{"id":415},"_4-verify-the-installation","4. Verify the Installation",[14,418,419],{},"You can confirm the installation and check the installed version with the following command:",[188,421,423],{"className":190,"code":422,"language":192,"meta":193,"style":193},"composer --version\n",[38,424,425],{"__ignoreMap":193},[197,426,427,429],{"class":199,"line":200},[197,428,67],{"class":203},[197,430,431],{"class":246}," --version\n",[14,433,434],{},"And if everything is OK, you will see output similar to this:",[188,436,439],{"className":437,"code":438,"language":393,"meta":193},[391],"Composer version 2.7.7 2024-06-10 22:11:12\n",[38,440,438],{"__ignoreMap":193},[14,442,443],{},"Congratulations and happy PHP coding!",[445,446,447],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}",{"title":193,"searchDepth":275,"depth":275,"links":449},[450,452,453,456,457],{"id":78,"depth":451,"text":79},3,{"id":179,"depth":275,"text":180},{"id":252,"depth":275,"text":253,"children":454},[455],{"id":292,"depth":451,"text":293},{"id":355,"depth":275,"text":356},{"id":415,"depth":275,"text":416},[459],"technical",null,"2022-05-13","A step-by-step guide to installing Composer globally on Ubuntu (20.04, 22.04, 24.04 LTS) and Debian-based systems, including dependency installation.",false,"md","\u002Fimages\u002Fhero\u002Fcomposer.avif","en",{},true,"\u002Finstall-composer-on-ubuntu",{"title":6,"description":462},"install-composer-on-ubuntu",[67,331,473],"ubuntu","2026-06-21","DOxt_t2ZZ6RTE2u1qv8fwkB9ujo_Po8z3nhu0gISr3o",{"path":477},"\u002Ftr\u002Fubuntu-20-04-composer-kurulumu",{"prev":479,"next":482,"others":485,"lucky":590,"readingTime":451},{"path":480,"title":481},"\u002Fall-about-headless-wordpress","All About Headless WordPress",{"path":483,"title":484},"\u002Fwhat-is-an-api-gateway","What is an API Gateway? Should You Use It?",[486,489,492,495,498,501,504,507,510,513,516,519,522,525,528,531,534,537,540,543,546,549,552,555,558,561,564,567,570,573,574,575,578,581,584,587],{"path":487,"title":488},"\u002Ffull-stack-project-development","Sample REST API Project",{"path":490,"title":491},"\u002Frest-api-authentication","How to Perform REST API Authentication?",{"path":493,"title":494},"\u002Frest-api-design","REST API Design: Principles and Output Format",{"path":496,"title":497},"\u002Frest-api-documentation-and-testing","How to Document and Test a REST API?",{"path":499,"title":500},"\u002Frest-api-error-handling","How to Perform REST API Error Handling?",{"path":502,"title":503},"\u002Frest-api-security","How to Secure a REST API?",{"path":505,"title":506},"\u002Frest-api-uri-structure","What Should the REST API URI Structure Be?",{"path":508,"title":509},"\u002Ftroubleshooting-cyberpanel-inaccessibility-after-ubuntu-release-upgrade","Troubleshooting CyberPanel Inaccessibility After Ubuntu Release Upgrade",{"path":511,"title":512},"\u002Freset-wordpress-admin-password-using-wp-cli","Reset WordPress Admin Password Using WP-CLI",{"path":514,"title":515},"\u002Fgraphql-vs-rest-api-which-is-the-best-choice-for-headless-wordpress","GraphQL vs REST API: Which is the Best Choice for Headless WordPress?",{"path":517,"title":518},"\u002Fgrow-your-business-in-turkey-with-expert-wordpress-plugin-and-theme-localization-and-support-services","Grow Your Business in Turkey with Expert WordPress Plugin and Theme Localization and Support Services",{"path":520,"title":521},"\u002Fgetting-started-with-devops-understanding-the-principles-and-adopting-the-tools","Getting Started with DevOps: Understanding the Principles and Adopting the Tools",{"path":523,"title":524},"\u002Fphp-graphql-development-advanced-techniques-for-optimizing-your-apis","PHP GraphQL Development: Advanced Techniques for Optimizing Your APIs",{"path":526,"title":527},"\u002Fadvanced-techniques-for-dependency-injection-in-php-tips-code-samples-and-faqs","Advanced Techniques for Dependency Injection in PHP: Tips, Code Samples, and FAQs",{"path":529,"title":530},"\u002Fmaximize-the-potential-of-headless-wordpress-with-graphql","Maximize the Potential of Headless WordPress with GraphQL",{"path":532,"title":533},"\u002Fwriting-clean-modular-and-reusable-code-in-php","Best Practices for Writing Clean, Modular, and Reusable Code in PHP",{"path":535,"title":536},"\u002Fheadless-cmss-an-overview-of-popular-alternatives-to-contentful-and-wordpress","Headless CMSs: An Overview of Popular Alternatives to Contentful and WordPress",{"path":538,"title":539},"\u002Fci-cd-for-php-a-comprehensive-guide","CI\u002FCD for PHP: A Comprehensive Guide",{"path":541,"title":542},"\u002Fintroduction-to-php-namespaces-a-beginners-guide-to-structuring-your-code","Introduction to PHP Namespaces: A Beginner's Guide to Structuring Your Code",{"path":544,"title":545},"\u002Fwhat-is-graylog-a-powerful-tool-for-collecting-indexing-and-analyzing-log-data","What is Graylog? A Powerful Tool for Collecting, Indexing, and Analyzing Log Data",{"path":547,"title":548},"\u002Felevate-your-turkish-audience-experience-with-professional-wordpress-plugin-and-theme-translation","Elevate Your Turkish Audience Experience with Professional WordPress Plugin and Theme Translation",{"path":550,"title":551},"\u002Fhow-to-set-up-a-self-hosted-api-gateway-a-comprehensive-guide","How to Set Up a Self-Hosted API Gateway: A Comprehensive Guide",{"path":553,"title":554},"\u002Fdifference-between-generators-and-iterators-in-php","The Key Differences Between PHP Generators and Iterators",{"path":556,"title":557},"\u002Fphp-and-machine-learning-a-winning-combination-with-php-ml","PHP and Machine Learning: A Winning Combination with PHP-ML",{"path":559,"title":560},"\u002Fphp-generators-a-beginners-guide-to-iteration","PHP Generators: A Beginner's Guide to Iteration",{"path":562,"title":563},"\u002Fmastering-closures-in-javascript-a-beginners-guide","Mastering Closures in JavaScript: A Beginner's Guide",{"path":565,"title":566},"\u002Fthe-top-php-certification-programs-for-developers","The Top PHP Certification Programs for Developers",{"path":568,"title":569},"\u002Fhow-to-revalidate-next-js-isr-cache-on-demand-cache-regeneration","How to Revalidate Next.js ISR Cache? On-Demand Cache Regeneration",{"path":571,"title":572},"\u002Ftips-for-translating-a-wordpress-plugin-wordpress-theme-to-turkish","Tips for Translating a WordPress Plugin \u002F WordPress Theme to Turkish",{"path":480,"title":481},{"path":483,"title":484},{"path":576,"title":577},"\u002Fis-jwt-safe-or-is-it-vulnerable","Is JWT Safe or Is It Vulnerable?",{"path":579,"title":580},"\u002Ftailwind-css-to-use-or-not-to-use-that-is-the-question","Tailwind CSS! To use? Or not to use? That is the question.",{"path":582,"title":583},"\u002Fwhat-is-hateoas","What is HATEOAS?",{"path":585,"title":586},"\u002Fhello-world","Hello World: A New Multilingual Journey",{"path":588,"title":589},"\u002Fwhat-is-ecmascript","What is ECMAScript? What is not?",{"path":550,"title":551},[592,594,596,598],{"path":487,"title":488,"date":593},"2026-06-20",{"path":508,"title":509,"date":595},"2023-10-14",{"path":523,"title":524,"date":597},"2023-01-19",{"path":532,"title":533,"date":599},"2023-01-17",[601,603,604],{"path":538,"title":539,"date":602},"2023-01-15",{"path":490,"title":491,"date":593},{"path":550,"title":551,"date":605},"2023-01-12",1782141982132]