Git Product home page Git Product logo

hosting_wordpress's Introduction

Hosting WordPress

EXPERIMENTAL work in progress. Use at your own risk.

This module is not officially supported. No security announcement will be published if an issue is found. See 'support' for more information.

See: https://www.drupal.org/node/1044692

Requirements

  • Aegir 3 (7.x-3.x)
  • Web server: nginx (Apache might work, but not well tested)
  • Lets Encrypt with hosting_https

The provision_symbiotic module is recommended. It provides a few workarounds for the nginx vhost template.

The aegir_ansible module is recommended if using https. This module will automatically write a domains-wp.txt file to regenerate https certificates with letsencrypt. Currently a cron is not automatically setup. See the https section below.

This module assumes that Hosting Https is used, with Lets Encrypt. Previous attempts to supporting other kind of setups would cause odd bugs, and it is not something we need, so we removed it.

Installation

IMPORTANT: run all the following commands as the 'aegir' user ('sudo -i -u aegir' or 'su -c /bin/bash aegir').

Copy the hosting_wordpress module in your ~/hostmaster-7.x-3.x/sites/example.org/modules directory:

cd ~/hostmaster-7.x-3.x/sites/example.org/modules/
git clone https://github.com/mlutfy/hosting_wordpress.git

Enable the hosting_wpplatform and hosting_wpsite modules:

drush @hostmaster en hosting_wpsite

Run a 'verify' task on the Hostmaster so that Aegir does the magic include in ~/.drush/drushrc.php (c.f. do#2300537):

drush @hostmaster provision-verify

Make sure your Aegir user has a ~/.profile file, so that the .bashrc is read when using sudo -i -u aegir:

cp -i /etc/skel/.profile ~/

Composer adds its 'bin' directory to the $PATH, which makes it possible to use the 'wp' command easily.

Install wp-cli using composer (this should create a sylink in ~/.composer/vendor/bin/wp)

cd ~/
composer global require wp-cli/wp-cli

Alternatively, if wp is not found, add the composer path manually to your .bashrc:

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc

Warning

Because of limitations in the integration with provision_customhtaccess (which lets developers inject custom rules in their nginx configuration), this module assumes that you trust the developers who have access to the site-specific directory of their site.

If a file called sites/example.org/nginx-custom.conf exists, it will be included by the nginx configuration.

An incorrect nginx configuration can cause problems with restarting nginx, potentially provide a path towards privilege escalation, etc.

How to test

  • Create a new platform on your filesystem, ex: mkdir /var/aegir/platforms/wordpress-4.5/; cd /var/aegir/platforms/wordpress-4.5/; wp core download
  • Create a new WP Platform (node/add/wpplatform)
  • Create a new WP Site from there.
  • Access the URL of your new site.
  • You can also use wp-cli in a site context, using, for example: "drush @mysite.example.org wp user list"

Known issues

See: https://github.com/mlutfy/hosting_wordpress/issues

How it works

  • provision_wordpress and hosting_wordpress implement new entities for the 'wpplatform' and 'wpsite' (highly inspired from 'platform' and 'site').

  • while it would be great to re-use the platform/site from Aegir, they make too many assumptions related to Drupal.

  • wpplatform verify creates a platform/example/wp-config.php file based on wp-config-sample.php, but uses the vhost variables so that we can install multiple sites in the same platform.

Https

This module works a bit differently from hosting_https. It still assumes that the module has been enabled and is used on the main Aegir frontend, but works more closely to how dehydrated works.

As an admin, to enable https on a site:

  • Make sure that "hosting https" is enabled on the Aegir frontend (i.e. you can access your aegir instance with https, ex: https://aegir.example.org).
  • Create a new WordPress site.
  • Run 'Verify' on the new site (eventually this will run automatically).

Technically:

  • When sites are verified, it checks if an https certificate is already available. If so, it assumes that the vhost supports and redirects to https.
  • If the 'aegir ansible' module is installed, it fetches a list of sites (and aliases) from the inventory and writes a 'domains-wp.txt' file in /var/aegir/config/letsencrypt/.
  • If 'hosting_https' seems to be enabled (well, if the above directory exists), it will assume that sites must be https, and will generate a certificate for it.

You can then configure a cron to run daily:

/var/aegir/config/letsencrypt/script -c -f /var/aegir/config/letsencrypt/config-wp

You can also run the above to debug if a certificate is not renewing correcly.

The config-wp file should be generated if empty. If not, you can create it manually:

WELLKNOWN="/var/aegir/config/letsencrypt.d/well-known/acme-challenge"
DOMAINS_TXT="/var/aegir/config/letsencrypt/domains-wp.txt"
PARAM_CERTDIR="/var/aegir/config/letsencrypt.d/"

This module will also attempt to run dehydrated when a new site is created, using the above command.

CiviCRM

See: https://drupal.org/project/hosting_civicrm

Support

Feel free to send patches using the issue queue on Github.

Commercial support is available through Coop SymbioTIC:
https://www.symbiotic.coop

Copyright and license

Provision Wordpress
(C) 2015-2022 Mathieu Lutfy [email protected]

Distributed under the terms of the GNU Affero General public license v3 (AGPL).
http://www.gnu.org/licenses/agpl.html

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

hosting_wordpress's People

Contributors

helmo avatar jacobembree avatar mlutfy avatar mmyriam avatar shaneonabike avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hosting_wordpress's Issues

Set the CIVICRM_SETTINGS vhost env variable

The civimail open/click-through scripts cannot find the civicrm.settings.php file. The simplest workaround I could find is to set the CIVICRM_SETTINGS env variable in the vhost.

Ex:

SetEnv CIVICRM_SETTINGS /srv/aegir/platforms/wordpress-4.4/sites/example.org/wp-content/plugins/civicrm/civicrm.settings.php

This should be added systematically.

Send patches to Aegir core

Currently, to use hosting_wordpress, we need to patch Aegir core in 2 places.

Need to propose a better solution upstream.

Provision_Context_wpplatform not found

Drush command terminated abnormally due to an unrecoverable error.Error: Uncaught Error: Class 'Provision_Context_wpplatform' not found in /usr/share/drush/commands/provision/provision.context.inc:132
Stack trace:
#0 /usr/share/drush/commands/provision/provision.context.inc(68): provision_context_factory('@wpplatform_Wor...', true)
 # 1 /usr/share/drush/commands/provision/provision.drush.inc(363): d('@wpplatform_Wor...')
 # 2 phar:///usr/local/bin/drush/includes/command.inc(422): drush_provision_save('@wpplatform_Wor...')
 # 3 phar:///usr/local/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
 # 4 phar:///usr/local/bin/drush/includes/command.inc(199): drush_command('@wpplatform_Wor...')
 # 5 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
 # 6 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
 # 7 phar:///usr/local/bin/drush/includes/startup.inc(462): drush_main()
 # 8 phar:///usr/local/bin/drush/includes/startup.inc(369): drush_run_main(false, '/', 'Phar detected. ...')
 # 9 phar:///usr/loc in /usr/share/drush/commands/provision/provision.context.inc, line 132

Provision_Context_wpplatform is in hosting_wpplatform/drush/Provision/Context/wpplatform.php. I don't know how Drush autoloads the classes, though. Mentioning the file in hosting_wpplatform/hosting_wpplatform.info did not help.

wp cli doesnt seem to work as well as drush

  1. wp cli doesnt seem to work as well as drush

aegir@arix:~/platforms/wordpress-core/sites$ wp
PHP Notice: Undefined index: db_name in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 18
PHP Notice: Undefined index: db_user in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 21
PHP Notice: Undefined index: db_passwd in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 24
PHP Notice: Undefined index: db_host in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 27
PHP Notice: Undefined index: wp_content_dir in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 30
Error:

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at . This could mean your host's database server is down.

  • Are you sure you have the correct username and password?
  • Are you sure that you have typed the correct hostname?
  • Are you sure that the database server is running?

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

plugin permissions etc?

how do change permissions on plugins to allow wordpress web ui installation of plugins etc?

also tried using drush wp

whats your workflow for this?

symlink for composer install of wp-cli was wrong on trusty

as usual, doing R&D passed bed time, I followed the instructions but may have messed up

made manual symlinks and got a fair way into this, i.e. working wordpress sites, but not sure whats next

I should test this again on a vm and not my main dev server

Got this working !

hi

finally got around to hacking my way to Aegir Wordpress victory

bunch of issues, which I will need to circle back to record properly

this is a meta issue

  1. had to comment out error log in apache config for wordpress site and restart apache, for some reason it didnt work

PROVISION_LOGS

==============

Set error log to site-specific file.

ErrorLog /var/log/aegir/wp2.arizmendix.devekko.net.error.log

==============

  1. wpsite form complained about languages

Notice: Undefined variable: selected_profile in hosting_wpsite_form() (line 300 of /var/aegir/hostmaster-7.x-3.1/sites/all/modules/hosting_wordpress/hosting_wpsite/hosting_wpsite.form.inc).

  1. wp cli doesnt seem to work as well as drush

aegir@arix:~/platforms/wordpress-core/sites$ wp
PHP Notice: Undefined index: db_name in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 18
PHP Notice: Undefined index: db_user in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 21
PHP Notice: Undefined index: db_passwd in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 24
PHP Notice: Undefined index: db_host in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 27
PHP Notice: Undefined index: wp_content_dir in /var/aegir/.composer/vendor/wp-cli/wp-cli/php/wp-cli.php(23) : eval()'d code on line 30
Error:

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can't contact the database server at . This could mean your host's database server is down.

  • Are you sure you have the correct username and password?
  • Are you sure that you have typed the correct hostname?
  • Are you sure that the database server is running?

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

  1. need to update or create views and menu items to be non specific to Drupal or maybe create a Wordpress section
  2. Site and Site in Content Types (need to make that Drupal Site and Wordpress Site) update, couldnt see how to make Views display Wpplatform and wpsite... I guess that needs to be done in code and then in the View
  3. symlink for composer install of wp-cli was wrong on trusty

anyways.. great

Restore from Drupal backup failed - Call to undefined function hosting_wpsite_get_backup() in drush_hosting_wpsite_pre_hosting_task()

Ran task to restore a Drupal site from a backup
It failed with the following error:

WD php: Error: Call to undefined function hosting_wpsite_get_backup() in drush_hosting_wpsite_pre_hosting_task() (line 85 of /var/aegir/hostmaster-7.x-3.x-2018-08-08-0255/sites/mysite/modules/hosting_wordpress/hosting_wpsite/hosting_wpsite.drush.inc). - error
Drush command terminated abnormally due to an unrecoverable error.

Find a better way to call wp-cli

Currently, the "provision-wordpress-install" and "provision-wordpress-cli" commands are calling wp-cli in a very unusual way: re-rewriting the $GLOBALS['argv'] variable, then doing an 'include' of wp-cli.php.

The main reason for doing this, instead of doing an 'exec', is to correctly include wp-config.php from the platform, while making sure that the $_SERVER variables are correctly set by the wpsite service.

However, there are alternatives that could work:

  • - update: no, because we prefer to "cloak" database credentials in the vhost, for more security.
    
  • finding out the correct way to call wp-cli.php so that it does not parse the $GLOBALS['argv'] variable.

While we're at it, it would be nice to have proper logging redirection (wp-cli does an fwrite to STDOUT).

wpsite creation form error line 300

just installed this again on my laptop, am probably doing wp for work and integrating with a well known cloud provider and using aegir 3/wp hosting for dev, stage etc

anyways...

get this error on the wpsite form

Notice: Undefined variable: selected_profile in hosting_wpsite_form() (line 300 of /var/aegir/hostmaster-7.x-3.1/sites/trustyinx.devekko.net/modules/hosting_wordpress/hosting_wpsite/hosting_wpsite.form.inc).

also, the form itself looks broken, but does work and creates a site

create site trustyinx devekko net - google chrome_082

wpsite form complained about languages

wpsite form complained about languages

Notice: Undefined variable: selected_profile in hosting_wpsite_form() (line 300 of /var/aegir/hostmaster-7.x-3.1/sites/all/modules/hosting_wordpress/hosting_wpsite/hosting_wpsite.form.inc).

had to comment out error log in apache config for wordpress

  1. had to comment out error log in apache config for wordpress site and restart apache, for some reason it didnt work
# 
PROVISION_LOGS
# ==============
# Set error log to site-specific file.
# ErrorLog /var/log/aegir/wp2.arizmendix.devekko.net.error.log
# ==============

Implement the "delete" task

After creating a wp site, it's not possible to delete it, because the provision-wordpress-delete task is not yet implemented.

Aegir / Drupal 7 Views cant see wpplatform or wpsite

4. need to update or create views and menu items to be non specific to Drupal or maybe create a Wordpress section

Site and Site in Content Types (need to make that Drupal Site and Wordpress Site) update, couldnt see how to make Views display Wpplatform and wpsite... I guess that needs to be done in code and then in the View

Avoid having to patch the wp-cli includes

Currently there are 3 conditional "includes" that need to be patched into hard includes in the wp-cli code (see README.md or patches directory).

Need to figure out why those files are not included, so that we do not need to patch wp-cli (is wp-cli misdetecting the wordpress version?).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.