Deploying of WordPress sites

I am about to migrate 100 WordPress Domains to a Hestia Machine and I have been doing some testing.

For now, I have a script that:

  • creates user
  • assigns domain
  • creates database
  • uses wp-cli to install wordpress
  • retrieves wp-content.zip via SCP
  • unzips
  • changes permissions
  • retrieves database.zip via SCP
  • uses wp-cli to import database

I do not have a valid SSL yet since it is a test and I have not published the website yet.

Problem: I can correctly see the homepage but I can’t see any other page or even /wp-admin
I cannot reflush permalinks and when I did via wp-cli it had no effect.

This is how my server is configured:

there is a wordpress template located at:

/usr/local/hestia/data/templates/web/nginx/php-fpm

can you give this a try?

Thank you Dennis.

I have read the documentation:
https://docs.hestiacp.com/admin_docs/server_management.html#how-do-web-templates-work

And well. I can see the templates that I want:

  • /usr/local/hestia/data/templates/web/nginx/php-fpm/wordpress.tpl
  • /usr/local/hestia/data/templates/web/nginx/php-fpm/wordpress.stpl

So reading the instructions I come to the conclusion that I have to create a copy of the template with the PHP version:

  • /usr/local/hestia/data/templates/web/nginx/php-fpm/wordpress-PHP-8_0.tpl
  • /usr/local/hestia/data/templates/web/nginx/php-fpm/wordpress-PHP-8_0.stpl

I don’t know if I have to move the templates elsewhere. It is not explained in the documentation.

I have rebuilt the user but the options remain the same in the panel.

It should work out of the box as you use Apache2

Did the script copied .htaccess file?

You will just move them up one folder into nginx.

/usr/local/hestia/data/templates/web/nginx/wordpress.tpl

/usr/local/hestia/data/templates/web/nginx/wordpress.stpl

Afterwards you can select them inside hestiacp web panel.

Apache2 uses .htaccess and the wordpress template directs everything to fpm directly…

That’s true. I moved them one folder up, then chmod +x to have the same permissions as the rest of them and then I activated the template in nginx.

But sadly same result.

When I try to visit a mydomain.com/subpage I get this 404 result:
image

If I try to visit mydomain.com/wp-admin -> ERR_TOO_MANY_REDIRECTS

And this is the result
while(1) {

I had to edit one page/post in wp-admin to get the rewrite redone and working again. Not sure why wp-admin is not loading for you.

Disable force redirect
Update wordpress so it uses https and you are done
Enable force redirect.

Don’t use wordpress templates for Nginx+PHP-FPM for Nginx+Apache2 servers!

Thank you @eris . Understood.

I had trouble with that. I deleted the user and started all over again.

  • Created hestia user
  • Created hestia web domain
  • Created hestia database
  • WP CLI download WP
  • WP CLI installed WP

I tested the website and runs perfectly in http.

Went to wp-options and changed http:// to https://

Everything went south.

Can’t enable ssl in panel > Can’t force ssl redirect

$HESTIA/bin/v-add-web-domain-ssl-force myuser mydomain.com
Error: SSL is not enabled

I tried but I couldn’t get it to work.

  • I pointed DNS to the server, then I activated Lets Encrypt Support and then I forced the redirection.
  • WP-CLI wp search-replace http:// https:// --allow-root
  • logged in in wp-admin and flushed permalinks

Everything working BUT I had to publish the website. (EDIT: By publish I mean go live by updating the DNS A record)

How can I test if a website is okay without publishing it?

For now, I have reverted the DNS publication and I am using Let’s Encrypt’s certificate but this is not an elegant solution.

It is because your SITEURL is setup for httpS but as you don’t have SSL installed on your HestiaCP, it creates a forced loop. You have 2 options:

Get and Change your SITEURL using WP-CLI to http (non-ssl)
or
Issue an SSL, Lets Encrypt or Self-assigned so that your https URL loads

To test without publishing DNS, you can use hosts file entry in your computer.
Once you feel satisfied, change A records, go live with your site from Hestia Server and then issue fresh LE SSL certificate.

1 Like

The thing is that the self-assigned was not working.

Thank you anyway.

Why so? Care to define what was ‘not working’?

Might be unrelated, but I recently had a string of problems migrating sites between servers with the “Too many redirects” error. Turns out it was a plugin called SimpleSSL. I had to disable it using wp-cli before I could access anything. Maybe something similar is happening with you? Perhaps try disabling plugins before you migrate?

Okay I am redefining now. What has been happening.

If I uncheck the SSL option, then I can’t see the website. If I check it, I can’t unless I publish the website.

I did this to fix the issue:

cat ssl-fix.sh
#!/bin/bash
#Define custom functions to use across scripts
source ./functions.sh
get_user_domain $1 $2
#Create Self-Signed certificates
path="/home/$username/web/$domain/ssl-cert"
mkdir $path
crt="$domain.crt"
key="$domain.key"
arg="/countryName=ES/localityName=Madrid/organizationalUnitName=$domain/commonName=$username/[email protected]$domain"
msg “Creo los certificados”
openssl req -newkey rsa:2048 -x509 -sha256 -days 3650 -nodes -out $path/$crt -keyout $path/$key -subj $arg
ls $path
#Create Self Signed Certificates
msg “Aplico los certificados AUTOFIRMADOS a $domain”
$HESTIA/bin/v-add-web-domain-ssl $username $domain $path
#Force SSL
msg “Fuerzo redirección a https://$domain
$HESTIA/bin/v-add-web-domain-ssl-force $username $domain
#Try to install Let’s Encrypt as a bonus.
msg “Intento instalar Let’s Encrypt (fallará si el dominio no está publicado)”
$HESTIA/bin/v-add-letsencrypt-domain $username $domain www.$domain

Now I have everything in SSL with a 10-year self signed certificate so I can check if it works and the system tries to install a Let’s Encrypt certificate. If it suceeds, everything is normal if it doesn’t it will be likely because the website is not published yet and I will have to repeat this later.

Not my case but for sure it can interfere.

SSL plugins can cause force redirect loops, so yes, you have to disable them if testing.

Your ‘terminology’ is still not understandable, what do you mean by ‘publish’ the website, you mean publishing the DNS A records to go live ?

Issuing a selfe signed SSL has nothing to do with DNS at all. And then you can test the site with hosts file entry. The only thing is it will nag you to load site from unknown certificate… but Firefox would let you go in. Safari / Chrome may need additional clicking of a few things and configuring their settings to allow self signed certs… But thats a browser problem and not server side thing.

I do it all the time on daily basis.

Yes! That’s what I mean.

I use hosts file but hestia doesn’t work out of the box unlike Plesk.
With Plesk I could provision a server and then connect to it just pointing my hosts file to the server.

With Hestia I have to create my self-signed certificate, and then I can point my hosts or propagate DNS A record and use let’s encrypt.

I thought that I could just install wordpress and point the hosts file and it should be fine.

That is not accurate :frowning: I use hosts file (and fiddler) all the time with domains in Hestia and I don’t have issues. If a domain (that I want to test/move to Hestia) already has a certificate, I copy the certificate keys (private, public, chain) from the original hosting server into the 3 boxes in Hestia web domain. That way I don’t get any certificate errors while doing my tests on Hestia. After checking that everything is all right, I update the NS records to point to the Hestia server. After about 48h, I use LE on the Hestia server to get a new certificate (so that it will auto-renew).

2 Likes

Good Idea

Okay. I have successfully migrated domains and subdomains from Plesk flawlessly. (Subdomains are in a different folder structure)

If anyone wants my scripts I can share them. They can be adapted to any panel.