WordPress Multisites

From Anarchaserver
Revision as of 21:48, 6 May 2019 by B01 (talk | contribs)

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

       <Directory />
                Options FollowSymLinks
                AllowOverride all
       </Directory>

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

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

#RewriteEngine on
# Some rewrite rules in this file were disabled on your HTTPS site,
# because they have the potential to create redirection loops.
# RewriteCond %{SERVER_NAME} =zoiahorn.anarchaserver.org
# RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
#Include /etc/letsencrypt/options-ssl-apache.conf
</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.

Error creating thumbnail: Unable to save thumbnail to destination

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
Error creating thumbnail: Unable to save thumbnail to destination

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 ?