DEV Community

Cover image for Automate PHP 7.3 Installation with Ansible
Athreya aka Maneshwar
Athreya aka Maneshwar

Posted on • Edited on

Automate PHP 7.3 Installation with Ansible

Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. Star Us to help devs discover the project. Do give it a try and share your feedback for improving the product.

Hi there! I’m building [LiveAPI], a first-of-its-kind tool that helps you automatically index API endpoints across all your repositories. LiveAPI makes it easier to discover, understand, and interact with APIs in large infrastructures.

Manually installing PHP across servers? Nah.

Let's make it boringly repeatable with Ansible.

This playbook snippet handles PHP 7.3 installation along with all the commonly used extensions.

No more apt install gymnastics on every new box.

Prerequisites

  • Ubuntu server (18.04 or later works well)
  • Ansible installed on your control machine
  • SSH access to target machine(s)

What This Playbook Does

  1. Adds the trusted Ondřej Surý PPA for PHP.
  2. Installs php7.3.
  3. Installs all commonly needed PHP 7.3 extensions.
  4. Verifies the installation with php -v.

The Playbook

---
- name: Install PHP 7.3 and Extensions
  hosts: all
  become: true

  tasks:
    - name: Add PHP PPA repository
      apt_repository:
        repo: "ppa:ondrej/php"
        state: present
        update_cache: yes

    - name: Install PHP 7.3
      apt:
        name: php7.3
        state: present
        update_cache: yes

    - name: Verify PHP installation
      command: php -v
      register: php_version
      changed_when: false

    - name: Display PHP version
      debug:
        msg: "{{ php_version.stdout }}"

    - name: Install PHP 7.3 extensions and dependencies
      apt:
        name:
          - php7.3-bcmath
          - php7.3-bz2
          - php7.3-curl
          - php7.3-gd
          - php7.3-gmp
          - php7.3-imap
          - php7.3-intl
          - php7.3-json
          - php7.3-ldap
          - php7.3-mbstring
          - php7.3-mysql
          - php7.3-opcache
          - php7.3-readline
          - php7.3-soap
          - php7.3-sqlite3
          - php7.3-tidy
          - php7.3-xml
          - php7.3-xmlrpc
          - php7.3-xsl
          - php7.3-zip
          - php7.3-cli
          - php7.3-common
        state: present
        update_cache: yes
Enter fullscreen mode Exit fullscreen mode

Running the Playbook

ansible-playbook -i hosts.ini php73.yml
Enter fullscreen mode Exit fullscreen mode

Make sure your inventory (hosts.ini) is properly set up and includes the correct ansible_user and SSH access.

Output You Should See

You’ll get output like:

TASK [Verify PHP installation]
ok: [myserver]

TASK [Display PHP version]
ok: [myserver] => {
    "msg": "PHP 7.3.33-9+ubuntu18.04.1+deb.sury.org+1 (cli) ..."
}
Enter fullscreen mode Exit fullscreen mode

Bonus: Reuse via Roles

Want to reuse this across projects? Move it into a role (e.g., roles/php73/) and include it like this:

roles:
  - php73
Enter fullscreen mode Exit fullscreen mode

Note

PHP 7.3 is EOL. Only use this if:

  • You’re dealing with legacy apps.
  • You’re explicitly required to stay on this version.

Otherwise, consider installing a more recent version like PHP 8.1 or 8.2.

🏁 That’s It

You now have a fully automated PHP 7.3 setup using Ansible. This keeps your infrastructure consistent, easy to update, and less prone to manual errors.

Let the YAML do the talking.

With you can generate interactive API docs that allow users to search and execute endpoints directly from the browser.

If you're tired of updating manually or syncing collections, give it a shot.

git-lrc
*AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.*

Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.

⭐ Star it on GitHub:

GitHub logo HexmosTech / git-lrc

Free, Unlimited AI Code Reviews That Run on Commit

git-lrc logo

git-lrc

Free, Unlimited AI Code Reviews That Run on Commit


git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.

See It In Action

See git-lrc catch serious security issues such as leaked credentials, expensive cloud operations, and sensitive material in log statements

git-lrc-intro-60s.mp4

Why

  • 🤖 AI agents silently break things. Code removed. Logic changed. Edge cases gone. You won't notice until production.
  • 🔍 Catch it before it ships. AI-powered inline comments show you exactly what changed and what looks wrong.
  • 🔁 Build a habit, ship better code. Regular review → fewer bugs → more robust code → better results in your team.
  • 🔗 Why git? Git is universal. Every editor, every IDE, every AI…




Top comments (1)

Collapse
 
alvaromontoro profile image
Alvaro Montoro

Are you republishing this article from somewhere else? PHP 7.3 reached its end-of-life almost 4 years ago. It should not be used.