Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 0 additions & 201 deletions LICENSE

This file was deleted.

62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
# php

## Ansible Role: Php
![php_logo_resized_150x150](https://github.com/user-attachments/assets/066df891-0d0e-4b4b-82b6-7bd37c43c799)


### Version History

|**Date**| **Version**| **Description**| **Changed By** |
|----------|---------|---------------|-----------------|
|**June '03'** | V.1 | Initial Draft | Mohit Saini |



## Table of Content
- [Introduction](#introduction)
- [Features](#features)
- [Supported OS](#supported-os)
- [Directory Structure of Php role](#directory-structure-of-php-role)
- [References](#references)


### Introduction

**Apache** HTTP Server is a free, open-source web server developed by the Apache Software Foundation, widely used in web hosting and part of the LAMP stack


### Features

- **Ease of Use & Familiar Syntax**: Simple, logical syntax similar to C makes PHP very easy to learn and use, even for beginners.
- **Flexible Integration**: Seamlessly embeds within HTML and integrates with many databases and technologies across multiple platforms.
- **Open Source with Huge Ecosystem**: Completely free with vast community support, numerous frameworks, and widely used CMS platforms like WordPress.
- **Fast Performance**: Optimized memory and execution speed, often faster than competing scripting languages.
- **Robust Database Abstraction (PDO)**: Provides a unified, secure way to access multiple databases with protection against SQL injection.

### Supported OS
------------
* Ubuntu 18.04 and above
* Debian 10 and above
* RHEL 7.0 and above

### Directory Structure of Php role

```
├── defaults
│   └── main.yml
├── handlers
│   └── main.yml
├── meta
│   └── main.yml
├── README.md
├── tasks
│   ├── debian.yml
│   ├── main.yml
│   └── redhat.yml
```



## References
----------
- **[Php Installation steps](https://phoenixnap.com/kb/install-php-on-ubuntu)**
19 changes: 19 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
php_version: "8.1"

php_packages_debian:
- "php{{ php_version }}"
- "php{{ php_version }}-cli"
- "php{{ php_version }}-fpm"
- "php{{ php_version }}-mysql"
- "php{{ php_version }}-curl"
- "php{{ php_version }}-xml"
- "php{{ php_version }}-mbstring"
- "libapache2-mod-php{{ php_version }}"

php_packages_redhat:
- php
- php-mysql

php_ini_path_debian: "/etc/php/{{ php_version }}/apache2/php.ini"
php_ini_path_redhat: "/etc/php.ini"
6 changes: 6 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Restart Apache
ansible.builtin.service:
name: "{{ 'apache2' if ansible_os_family == 'Debian' else 'httpd' }}"
state: restarted
become: yes
4 changes: 4 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- hosts: tag_Name__php
become: true
roles:
- role
32 changes: 32 additions & 0 deletions tasks/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
- name: Set package and ini path for Debian/Ubuntu
set_fact:
php_packages: "{{ php_packages_debian }}"
php_ini_path: "{{ php_ini_path_debian }}"

- name: Update apt cache
ansible.builtin.apt:
update_cache: yes
become: yes

- name: Install PHP and modules from Debian/Ubuntu
ansible.builtin.package:
name: "{{ php_packages }}"
state: present
become: yes

- name: Ensure PHP Apache config directory exists
file:
path: "/etc/php/{{ php_version }}/apache2"
state: directory
mode: '0755'
become: yes

- name: Deploy PHP configuration
ansible.builtin.template:
src: php.ini.j2
dest: "{{ php_ini_path }}"
owner: root
group: root
mode: '0644'
notify: Restart Apache
become: yes
3 changes: 3 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Include OS-specific tasks
include_tasks: "{{ ansible_facts['os_family'] | lower }}.yml"
21 changes: 21 additions & 0 deletions tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Set package and ini path for RedHat/CentOS
set_fact:
php_packages: "{{ php_packages_redhat }}"
php_ini_path: "{{ php_ini_path_redhat }}"

- name: Install PHP and modules
ansible.builtin.package:
name: "{{ php_packages }}"
state: present
become: yes

- name: Deploy PHP configuration
ansible.builtin.template:
src: php.ini.j2
dest: "{{ php_ini_path }}"
owner: root
group: root
mode: '0644'
notify: Restart Apache
become: yes
4 changes: 4 additions & 0 deletions templates/php.ini.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
memory_limit = 256M
upload_max_filesize = 50M
post_max_size = 50M
max_execution_time = 300