This state automates installation of Apache2 and PHP7.0, creating new local VirtualHost, creating homepages for current and future users (/skel) and enabling PHP.
init.sls
# Made By Matias Richterich www.richterich.me
apache2:
pkg.installed:
- pkgs:
- apache2
- libapache2-mod-php7.0
/var/www/html/index.html:
file.managed:
- source: salt://apache/index.html
/etc/apache2/mods-enabled/userdir.conf:
file.symlink:
- target: ../mods-available/userdir.conf
/etc/apache2/mods-enabled/userdir.load:
file.symlink:
- target: ../mods-available/userdir.load
/etc/apache2/mods-available/php7.0.conf:
file.managed:
- source: salt://apache/phpconfig
/etc/apache2/sites-available/matias.example.com.conf:
file.managed:
- source: salt://apache/matias.example.com.conf
- target: ../sites-available/matias.example.com.conf
- target: ../sites-available
/etc/hosts:
file.managed:
- source: salt://apache/hosts
/etc/skel/public_html:
file.recurse:
- name: /etc/skel/public_html
- source: salt://apache/public_html
apache2service:
service.running:
- name: apache2
- watch:
- file: /etc/apache2/mods-enabled/userdir.conf
- file: /etc/apache2/mods-enabled/userdir.load
- file: /etc/apache2/mods-available/php7.0.conf
- file: /etc/apache2/sites-available/matias.example.com.conf
matias.example.com.conf
DocumentRoot /home/xubuntu/public_html/
Require all granted
hosts
127.0.0.1 localhost
127.0.1.1 xubuntu
127.0.0.1 matias.example.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
index.html
Hello World
phpconfig
SetHandler application/x-httpd-php
SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Require all denied
# Deny access to files without filename (e.g. '.php')
Require all denied
# Running PHP scripts in user directories is disabled by default
#
# To re-enable PHP in user directories comment the following lines
# (from
# prevents .htaccess files from disabling it.
#
#
# php_admin_flag engine Off
#
#
Folder named ~/public_html
In public_html folder index.html file which contains just a “Hello world”