Skip to content

fatihgvn/apachep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apachep

Apachep automatically installs the following packages on your Linux system. It allows you to develop more than one project at the same time by dividing your web projects into virtual hosts on localhost. With the help of PHP-FPM, you can develop different projects concurrently using different PHP versions.


Packages Used

apache2
php
php-mbstring
gettext
mysql-client
mysql-common
mysql-server
zip
unzip
net-tools
postgresql
postgresql-contrib
phppgadmin

Tested

Linux Version(s) Result
Ubuntu 20.04, 22.04 Success
Debian - -
Centos - -

Run Install

Pre-Installation Requirements (Ubuntu)

Before installing Apachep on Ubuntu, please ensure that the following packages are already installed on your system:

  • git
  • wget
  • software-properties-common

These packages are required for fetching the installation script and adding external repositories. You can install them using:

sudo apt-get update
sudo apt-get install -y git wget software-properties-common

Installation Arguments

Parameter Description
--domain (Optional) Sets the default domain extension. The value is stored in .domain (default: dev).
--dnsmasq (Optional) If specified, the dnsmasq installation script will be run. Warning: If Apachep is not being installed inside an LXC container, using --dnsmasq may cause issues. Verify your environment before using this parameter.

Ubuntu Installation

wget https://raw.githubusercontent.com/fatihgvn/apachep/main/install/install-ubuntu.sh
bash install-ubuntu.sh --domain dev --dnsmasq

Note:
If you do not specify the --domain parameter, the default extension dev will be used.
Important: The --dnsmasq parameter is intended for installations inside LXC containers. If you are installing Apachep on a standard host environment (i.e., not in LXC), using this parameter may lead to unexpected behavior.


Commands

General usage:

sudo apachep [method] [args...]

Method List


add-host

Create a new virtual host. This command automatically combines the base domain (provided as argument) with the stored domain extension (from the INSTALL_DIR/.domain file) and uses the stored system IP (from INSTALL_DIR/.ip) for host entries. It then runs the create-conf command (with additional parameters) to generate the Apache configuration and creates the necessary document root directories.

Arguments

Argument Detail Default
domain_base Base part of the domain to be created. The final domain is composed as [domain_base].[domain_extension] (e.g., test becomes test.dev).
phpversion PHP version to be used for the virtual host. default

Example

Using PHP 7.4

sudo apachep add-host test 7.4

Using default PHP

sudo apachep add-host test default

create-conf

Create the Apache configuration file for a domain.
Note: In this updated version, the template parameter is mandatory. You must supply the template name (without the .template extension) to be used. The configuration file is generated by replacing placeholders with the appropriate values.

Arguments

Argument Detail Example
domain Domain address to be created (the full domain must be provided as created by add-host, e.g., test.dev). test.dev
phpversion PHP version to be used (e.g., default or 7.4). default or 7.4
template Mandatory. Template name (without extension) to be used. The file /usr/local/apachep/system/templates/conf/<template>.template must exist. default or default.fpm

Example

Use default PHP with the default template

sudo apachep create-conf test.dev default default

Use PHP 7.4 with the FPM template

sudo apachep create-conf test.dev 7.4 default.fpm

create-ssl

Create SSL for a domain by generating a key, CSR, and a self-signed certificate.

Arguments

Argument Detail Default
domain Domain address for which SSL is created.
password Password for SSL (if not provided, a default dummy password is used). dummypassword

Example

Use your own password

sudo apachep create-ssl test.dev mypassword

Use default password

sudo apachep create-ssl test.dev

install-php

Install a new PHP-FPM version.

Arguments

Argument Detail Default
phpversion PHP version to install

Example

sudo apachep install-php 7.4

remove-host

Remove an existing host along with its configuration files and document root (optionally).

Arguments

Argument Detail Default
domain Domain address to be removed.
with-conf Whether the configuration file should also be removed (true or false). true

Example

Remove host with configuration

sudo apachep remove-host test.dev

Remove host without configuration

sudo apachep remove-host test.dev false

remove-conf

Remove an existing host configuration file.

Arguments

Argument Detail Default
domain Domain address for which the configuration should be removed.

Example

sudo apachep remove-conf test.dev

Additional Information

  • Domain Extension & System IP Storage:
    During installation, the domain extension is stored in INSTALL_DIR/.domain and the detected system IP in INSTALL_DIR/.ip. These values are used by commands like add-host to construct full domain names and update /etc/hosts automatically.

  • Apachep Wrapper:
    The command wrapper installed at /usr/bin/apachep allows you to run Apachep commands easily. Use sudo apachep [method] [args...] for all operations.

  • LXC Considerations:
    The --dnsmasq parameter is designed for installations within LXC containers. If Apachep is not installed in an LXC container, using --dnsmasq might cause issues. Make sure your environment is compatible with dnsmasq usage before enabling this option.


Sample LXC Configuration & Network Setup

When installing Apachep within an LXC container, it is important to configure the container’s network correctly. Below is an example LXC configuration file:

# Common configuration
lxc.include = /usr/share/lxc/config/ubuntu.common.conf

# Container specific configuration
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.rootfs.path = dir:/var/lib/lxc/apachep/rootfs
lxc.uts.name = apachep
lxc.arch = amd64

# Network configuration
lxc.net.0.type = veth
lxc.net.0.hwaddr = 00:16:3e:b2:e0:2a
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.ipv4.address = 10.0.3.58

Important Points:

  • Bridge Interface:
    Ensure that the lxc.net.0.link parameter points to the correct bridge (for example, lxcbr0 or a different one if needed). If you wish to change it (e.g., to lxcbr1), verify that the new bridge exists and is correctly configured.

  • NAT & Static IP:
    Make sure that NAT configurations and static IP assignments are correct. The container’s static IP (here, 10.0.3.58) should match the DNS settings used for split DNS.

  • DNS Setup with resolvectl:
    After configuring the container network, run the following commands on the host to ensure DNS queries for your domain are directed correctly:

    sudo resolvectl dns lxcbr0 10.0.3.58
    sudo resolvectl domain lxcbr0 '~dev'

    If you are using a different domain extension (for example, .devop), adjust the resolvectl domain parameter accordingly:

    sudo resolvectl domain lxcbr0 '~devop'
  • Static IP Consistency:
    Ensure that the static IP assigned to the container remains consistent with the system’s detected IP (stored in INSTALL_DIR/.ip). The container’s network configuration should be set so that its IP does not change on reboot.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published