Difference between revisions of "WordPress Multisites"

From Anarchaserver
(Created page with "= 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 us...")
 
 
(4 intermediate revisions by one other user not shown)
Line 6: Line 6:


For now, a new template or plug-in should be added by hand (threw ssh access on the server, see below)
For now, a new template or plug-in should be added by hand (threw ssh access on the server, see below)
For users of the WP farm here a [https://www.qurium.org/secure-hosting/website-security/ good page with security recommendations] for users of WP farms, need to be adapted to AS


= Configuration an tuning =
= Configuration an tuning =
Line 19: Line 21:
Create the vhost proxy in the apache2 of the hosts to redirect the traffic to the container in sites-available/
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
  nano /etc/apache2/sites-available/zoiahorn.conf
<syntaxhighlight lang=php>
<syntaxhighlight lang="PHP">
<VirtualHost *:80>
<VirtualHost *:80>
         ServerAdmin webmaster@localhost
         ServerAdmin webmaster@localhost
Line 47: Line 49:


  nano /etc/apache2/sites-available/zoiahorn-le-ssl.conf
  nano /etc/apache2/sites-available/zoiahorn-le-ssl.conf
<syntaxhighlight lang=php>
<syntaxhighlight lang="PHP">
<IfModule mod_ssl.c>
<IfModule mod_ssl.c>
<VirtualHost *:443>
<VirtualHost *:443>
Line 94: Line 96:
Create a virtual host in apache2 container :
Create a virtual host in apache2 container :
  nano /etc/apache2/sites-available/zoiahorn.conf  
  nano /etc/apache2/sites-available/zoiahorn.conf  
<syntaxhighlight lang=php>
<syntaxhighlight lang="PHP">
<VirtualHost *:80>
<VirtualHost *:80>
   ServerAdmin webmaster@localhost
   ServerAdmin webmaster@localhost
Line 108: Line 110:


  nano /etc/apache2/sites-available/zoiahorn-le-ssl.conf
  nano /etc/apache2/sites-available/zoiahorn-le-ssl.conf
<syntaxhighlight lang=php>
<syntaxhighlight lang="PHP">
<IfModule mod_ssl.c>
<IfModule mod_ssl.c>
<VirtualHost *:443>
<VirtualHost *:443>
Line 114: Line 116:
   ServerName zoiahorn.anarchaserver.org
   ServerName zoiahorn.anarchaserver.org


DocumentRoot /var/www/zoiahorn/
        DocumentRoot /var/www/zoiahorn/


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


SSLEngine on
SSLEngine on
Line 133: Line 131:
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
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>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>
</IfModule>
</syntaxhighlight>
</syntaxhighlight>


Line 193: Line 186:
'''After that you will need to re-login to your WordPress site to access the multisite network.'''
'''After that you will need to re-login to your WordPress site to access the multisite network.'''


[[File:Wp-multi.png]]
[[File:Wp-multi.png|700px]]


* https://www.wpbeginner.com/wp-tutorials/how-to-install-and-setup-wordpress-multisite-network
* https://www.wpbeginner.com/wp-tutorials/how-to-install-and-setup-wordpress-multisite-network
= 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/

Latest revision as of 15:34, 9 February 2021

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)

For users of the WP farm here a good page with security recommendations for users of WP farms, need to be adapted to AS

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/