wordpress-vhost-apache

Example:

# Apache wordpress vhost config.
- wordpress-vhost-apache:
    vhost_name: my_wordpress_site
    wp_title: My wordpress site
    use_https: true
    host: dev.frkl.io
    base_path: /var/www/wordpress

Description

Create Apache wordpress virtual host config.

Variables

Name Type Default Description

wp_title

string --

The name of the wordpress instance. Required

base_path

string /var/www

The wordpress project folders parent directory.

host

string localhost

The hostname of the server.

listen_ip

string _default_

The address to listen to, can be any of the following, optionally followed by a colon and a port number (or *): - The IP address of the virtual host; - A fully qualified domain name for the IP address of the virtual host (not recommended); - The character *, which acts as a wildcard and matches any IP address. - The string default, which is an alias for *

server_admin

string --

The email address to use in the vhost file and with letsencrypt, falls back to 'wp_admin_email.

use_https

boolean --

Request a lets-encrypt certificate and serve devpi via https (needs 'server_admin' or 'wp_admin_email' set).

Examples

Example 1

Apache wordpress vhost config.

Code
- wordpress-vhost-apache:
    vhost_name: my_wordpress_site
    wp_title: My wordpress site
    use_https: true
    host: dev.frkl.io
    base_path: /var/www/wordpress

Code

doc:
  short_help: Create Apache wordpress virtual host config.
  examples:
  - title: Apache wordpress vhost config.
    vars:
      vhost_name: my_wordpress_site
      wp_title: My wordpress site
      use_https: true
      host: dev.frkl.io
      base_path: /var/www/wordpress

args:
#  vhost_name:
#    doc:
#      short_help: "The name of the vhost file."
#    required: true
#    type: string
  base_path:
    doc:
      short_help: The wordpress project folders parent directory.
    type: string
    required: false
    default: /var/www
    cli:
      show_default: true
  host:
    type: string
    default: localhost
    required: true
    doc:
      short_help: The hostname of the server.
  server_admin:
    type: string
    doc:
      short_help: The email address to use in the vhost file and with letsencrypt,
        falls back to 'wp_admin_email.
    required: false
  use_https:
    type: boolean
    required: false
    doc:
      short_help: Request a lets-encrypt certificate and serve devpi via https (needs
        'server_admin' or 'wp_admin_email' set).
    cli:
      is_flag: true
  wp_title:
    doc:
      short_help: The name of the wordpress instance.
    type: string
    required: true
    cli:
      metavar: TITLE
  listen_ip:
    doc:
      short_help: The ip to listen to (necessary if using the Apache webserver.
      help: |
        The address to listen to, can be any of the following, optionally followed by a colon and a port number (or *):
          - The IP address of the virtual host;
          - A fully qualified domain name for the IP address of the virtual host (not recommended);
          - The character *, which acts as a wildcard and matches any IP address.
          - The string _default_, which is an alias for *
      references:
      - '[Apache VirtualHost documentation](https://httpd.apache.org/docs/current/mod/core.html#virtualhost)'
    type: string
    required: false
    default: _default_
frecklets:
- apache-vhost-file:
    path: '/etc/apache2/sites-enabled/{{:: wp_title | clean_string | lower ::}}.conf'
    owner: root
    become: true
    server_name: '{{:: host ::}}'
    use_https: '{{:: use_https ::}}'
    listen_ip: '{{:: listen_ip ::}}'
    document_root: '{{:: base_path ::}}/{{:: wp_title | clean_string | lower ::}}'
    server_admin: '{{:: server_admin ::}}'
    folder_directives:
    - directive_type: Directory
      path: '{{:: base_path ::}}/{{:: wp_title | clean_string | lower ::}}'
      Options: FollowSymLinks
      AllowOverride: Limit Options FileInfo
      DirectoryIndex: index.php
      Require: all granted
#        - directive_type: Directory
#          path: "{{:: base_path ::}}/{{:: wp_title | clean_string ::}}/wp-content"
#          Options: FollowSymLinks
#          Require: "all granted"
    - directive_type: FilesMatch
      path: \.php$
      SetHandler: proxy:fcgi://127.0.0.1:9000
frecklecute wordpress-vhost-apache --help

Usage: frecklecute wordpress-vhost-apache [OPTIONS]

  Create Apache wordpress virtual host config.

Options:
  --wp-title TITLE              The name of the wordpress instance.
                                [required]
  --base-path BASE_PATH         The wordpress project folders parent
                                directory.
  --host HOST                   The hostname of the server.
  --listen-ip LISTEN_IP         The ip to listen to (necessary if using the
                                Apache webserver.
  --server-admin SERVER_ADMIN   The email address to use in the vhost file and
                                with letsencrypt, falls back to
                                'wp_admin_email.
  --use-https / --no-use-https  Request a lets-encrypt certificate and serve
                                devpi via https (needs 'server_admin' or
                                'wp_admin_email' set).
  --help                        Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.wordpress_vhost_apache.WordpressVhostApache
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class WordpressVhostApache(AutoPycklet):
    """Create Apache wordpress virtual host config.

       Args:
         base_path: The wordpress project folders parent directory.
         host: The hostname of the server.
         listen_ip: The ip to listen to (necessary if using the Apache webserver.
         server_admin: The email address to use in the vhost file and with letsencrypt, falls back to 'wp_admin_email.
         use_https: Request a lets-encrypt certificate and serve devpi via https (needs 'server_admin' or 'wp_admin_email' set).
         wp_title: The name of the wordpress instance.

    """

    FRECKLET_ID = "wordpress-vhost-apache"

    base_path: str = None
    host: str = None
    listen_ip: str = None
    server_admin: str = None
    use_https: bool = None
    wp_title: str = None


    def __post_init__(self):
        super(WordpressVhostApache, self).__init__(var_names=["base_path", "host", "listen_ip", "server_admin", "use_https", "wp_title"])


frecklet_class = WordpressVhostApache
# -*- coding: utf-8 -*-


#
# module path: pycklets.wordpress_vhost_apache.WordpressVhostApache
#


from pyckles import AutoPycklet

class WordpressVhostApache(AutoPycklet):
    """Create Apache wordpress virtual host config.

       Args:
         base_path: The wordpress project folders parent directory.
         host: The hostname of the server.
         listen_ip: The ip to listen to (necessary if using the Apache webserver.
         server_admin: The email address to use in the vhost file and with letsencrypt, falls back to 'wp_admin_email.
         use_https: Request a lets-encrypt certificate and serve devpi via https (needs 'server_admin' or 'wp_admin_email' set).
         wp_title: The name of the wordpress instance.

    """

    FRECKLET_ID = "wordpress-vhost-apache"

    def __init__(self, base_path="/var/www", host="localhost", listen_ip="_default_", server_admin=None, use_https=None, wp_title=None):

        super(WordpressVhostApache, self).__init__(var_names=["base_path", "host", "listen_ip", "server_admin", "use_https", "wp_title"])
        self._base_path = base_path
        self._host = host
        self._listen_ip = listen_ip
        self._server_admin = server_admin
        self._use_https = use_https
        self._wp_title = wp_title

    @property
    def base_path(self):
        return self._base_path

    @base_path.setter
    def base_path(self, base_path):
        self._base_path = base_path

    @property
    def host(self):
        return self._host

    @host.setter
    def host(self, host):
        self._host = host

    @property
    def listen_ip(self):
        return self._listen_ip

    @listen_ip.setter
    def listen_ip(self, listen_ip):
        self._listen_ip = listen_ip

    @property
    def server_admin(self):
        return self._server_admin

    @server_admin.setter
    def server_admin(self, server_admin):
        self._server_admin = server_admin

    @property
    def use_https(self):
        return self._use_https

    @use_https.setter
    def use_https(self, use_https):
        self._use_https = use_https

    @property
    def wp_title(self):
        return self._wp_title

    @wp_title.setter
    def wp_title(self, wp_title):
        self._wp_title = wp_title



frecklet_class = WordpressVhostApache