WordPress Multisites

From Anarchaserver

How to use Wordpress (multi-site)

! There is users (and administrators) for the network administration of the farm and there is users (and admin) per blog wp !

If a user is created on the network level, than she/he has to be added as a user of a particular blog to be able to write in it

For now, a new template or plug-in should be added by hand (threw ssh access on the server, see below)

Configuration an tuning

Configure the upload limit for all the blogs in https://zoiahorn.anarchaserver.org/wp-admin/network/settings.php

Max upload file size 1000000 k 

Disable comments on new blog if not needed

Classic editor has been set up by default on all blogs (bug in the new one)

WordPress Multisites installation in a LXC container

vhost on the host

Create the vhost proxy in the apache2 of the hosts to redirect the traffic to the container in sites-available/

nano /etc/apache2/sites-available/zoiahorn.conf
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName zoiahorn.anarchaserver.org


        ErrorLog ${APACHE_LOG_DIR}/zoiahorn-error.log
        CustomLog ${APACHE_LOG_DIR}/zoiahorn-access.log combined


  ProxyPreserveHost       On
  ProxyRequests           Off

   ProxyPass / http://10.0.3.5/
   ProxyPassReverse http://10.0.3.5/ /

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

RewriteEngine on
RewriteCond %{SERVER_NAME} =zoiahorn.anarchaserver.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
nano /etc/apache2/sites-available/zoiahorn-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName zoiahorn.anarchaserver.org


        ErrorLog ${APACHE_LOG_DIR}/zoiahorn-error.log
        CustomLog ${APACHE_LOG_DIR}/zoiahorn-access.log combined


  ProxyPreserveHost       On
  ProxyRequests           Off

   ProxyPass / https://zoiahorn.anarchaserver.org/
   ProxyPassReverse / https://zoiahorn.anarchaserver.org/

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
SSLEngine on
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off

#RewriteEngine on
SSLCertificateFile /etc/letsencrypt/live/zoiahorn.anarchaserver.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/zoiahorn.anarchaserver.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>

Activate the virtual hosts :

a2ensite zoiahorn.conf
a2ensite zoiahorn-le-ssl.conf
sytemctl reload apache2

vhost in the container

Connect to the container as root

lxc-attach -n livingdata

Create a virtual host in apache2 container :

nano /etc/apache2/sites-available/zoiahorn.conf 
<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   ServerName zoiahorn.anarchaserver.org

	DocumentRoot /var/www/zoiahorn/


   ErrorLog ${APACHE_LOG_DIR}/zoiahorn-error.log
   CustomLog ${APACHE_LOG_DIR}/zoiahorn-access.log combined
</VirtualHost>
nano /etc/apache2/sites-available/zoiahorn-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
   ServerAdmin webmaster@localhost
   ServerName zoiahorn.anarchaserver.org

        DocumentRoot /var/www/zoiahorn/

        ErrorLog ${APACHE_LOG_DIR}/zoiahorn-error.log
        CustomLog ${APACHE_LOG_DIR}/zoiahorn-access.log combined
# This specific syntax (+FollowSymlinks, Require all granted) is important for permalink .htaccess
       <Directory /var/www/zoiahorn>
                   Options -Indexes +FollowSymLinks +MultiViews
                   Require all granted
                   AllowOverride All
       </Directory>

SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>

Wordpress normal installation

Install a normal wordpress in /var/www/zoiahorn

cd /var/www
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz 
mv wordpress/ zoiahorn/
cd zoiahorn/

Create the Database as adviced here https://codex.wordpress.org/Installing_WordPress#Using_the_MySQL_Client

mysql -u root -p

Go to https://zoiahorn.anarchaserver.org to finish the configuration, at the end of the config, a web page propose to copy paste the content of wp-config.php :

nano wp-config.php
touch .htaccess
chown www-data: .htaccess 

Install old editor as the new one is buggy

cd wp-content/plugins/
wget https://downloads.wordpress.org/plugin/classic-editor.1.4.zip
unzip classic-editor.1.4.zip 
rm classic-editor.1.4.zip

Prepare upload directory

cd ../../wp-content/
mkdir uploads
chown www-data: uploads/

Add some themes

cd wp-content/themes/
wget https://downloads.wordpress.org/theme/pixova-lite.2.0.4.zip
unzip pixova-lite.2.0.4.zip 
wget https://downloads.wordpress.org/theme/dulcet.0.0.7.zip
unzip dulcet.0.0.7.zip 
rm *.zip

Optimise database

mysqlcheck -u anarchawpdbuser -p newzoiahorn --optimize

Wordpress multisite installation

Activate Network feature

nano wp-config.php

Add the line :

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );

Desactivate WP Plug-ins

You can now head over to Tools » Network Setup page to configure your multisite network. Networksetup.png Choose the domain structure and click install, WordPress will now show you some code that you need to add to your wp-config.php and .htaccess file respectively.

nano wp-config.php
nano .htaccess

Networksetup2.png

After that you will need to re-login to your WordPress site to access the multisite network.

Wp-multi.png

Troubleshooting

Permalinks

Not possible to change the way Wordpress produce the permalinks: for each site https://zoiahorn.anarchaserver.org/wp-admin/options-permalink.php

Only "Plain" system work, else the articles give a 404 when linked, may come from .htaccess or FollowSymlink in apache ? > I think the problem was coming from the vhost syntax about followsymlink, it works now

Sending mail from wordpress

by default it is wordpress@anarchaserver.org the adress that send the mails from wordpress

Not usefull ? A trial to see if it improves things 25102019 : add a TXT record in gandi DNS record :

@	TXT	1800	"v=spf1 include:anarchaserver.org a mx ~all"

Or install sendmail !

apt install sendmail

To test if sending a mail work :

echo "Subject: sendmail test 5" | sendmail -v validemail@mail.org

If

050 504 5.5.2 <livingdata>: Helo command rejected: need fully-qualified hostname

There is the need to add the hostname in sendmail config :

nano /etc/mail/sendmail.mc

add line 40 :

define(`confDOMAIN_NAME', `zoiahorn.anarchaserver.org')dnl

then, to take the changes into account

sendmailconfig

the previous command should work (see in the spam folder)

To test via php :

php -a
mail ('you@example.com', "Test Postfix", "Test mail from postfix");
quit

A plug-in to test from Wordpress : https://wordpress.org/plugins/check-email/