Question

How to finish WordPress Installation without SSH?

I’m currently preparing to conduct a workshop for 20-30 non-technical people. One of the steps is to spin up a droplet with WordPress pre-installed, using the one click applications. I can’t ask them to use SSH; they will get scared as soon as they see the command line(web or terminal). I’m looking to run a script post installation from User Data which will finish up the WordPress installation.

I found the script which is run after login /opt/digitalocean/wp_setup.sh:

# Enable WordPress on firstlogin
mv /var/www/html /var/www/html.old
mv /var/www/wordpress /var/www/html
chown -Rf www-data:www-data /var/www/html
echo "This script will copy the WordPress instalation into"
echo "Your web root and move the existing one to /var/www/html.old"
echo "--------------------------------------------------"
echo "This setup requires a domain name.  If you do not have one yet, you may"
echo "cancel this setup, press Ctrl+C.  This script will run again on your next login"
echo "--------------------------------------------------"
echo "Enter the domain name for your new WordPress site."
echo "(ex. example.org or test.example.org) do not include www or http/s"
echo "--------------------------------------------------"
a=0
while [ $a -eq 0 ]
do
 read -p "Domain/Subdomain name: " dom
 if [ -z "$dom" ]
 then
  a=0
  echo "Please provide a valid domain or subdomain name to continue to press Ctrl+C to cancel"
 else
  a=1
fi
done
sed -i "s/\$domain/$dom/g"  /etc/apache2/sites-enabled/000-default.conf
a2enconf block-xmlrpc

service apache2 restart
cp /etc/skel/.bashrc /root
echo -en "\n\n\n"
echo "Next, you have the option of configuring LetsEncrypt to secure your new site.  Before doing this, be sure that you have pointed your domain or subdomain to this server's IP address.  You can also run LetsEncrypt certbot later with the command 'certbot --apache'"
echo -en "\n\n\n"
 read -p "Would you like to use LetsEncrypt (certbot) to configure SSL(https) for your new site? (y/n): " yn
    case $yn in
        [Yy]* ) certbot --apache; echo "WordPress has been enabled at https://$dom  Please open this URL in a browser to complete the setup of your site.";break;;
        [Nn]* ) echo "WordPress has been enabled at http://$dom  Please open this URL in a browser to complete the setup of your site.";exit;;
        * ) echo "Please answer y or n.";;
    esac

I tried running first 3 commands post install from User Data to move WordPress to it’s directory so that it is visible. But when accessing the IP address it would tell me I need to finish the installation through SSH. When I logged in using USSH, it did ask me to Enter the domain name for your new WordPress site. same as in the above script. I cancel that script with Ctrl+C and then accessing the IP address after that will show the first WordPress page fine.

Is there anything else happening behind the scenes that makes the website available? Or does anyone know how to install WordPress with actually one click?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

jarland
DigitalOcean Employee
DigitalOcean Employee badge
March 22, 2019
Accepted Answer

Greetings!

While that may be possible to do, there could be no guarantee that it wouldn’t be broken by an update. Instead, I would like to suggest that you consider installing Wordpress entirely from within the user-data. I have a sample script for you here:

https://github.com/digitalocean/do_user_scripts/blob/master/Ubuntu-16.04/cms/wordpress.sh

Jarland

@jarland your suggestion actually worked out pretty well, and the script is great. I’ve updated it a bit to install php7.2 else it wouldn’t work: https://github.com/lamazingco/digitalocean-wordpress-install-script/blob/master/wordpress.sh

For whoever is interested in using it properly add this to User Data:

#cloud-config

runcmd:
  - curl https://raw.githubusercontent.com/lamazingco/digitalocean-wordpress-install-script/master/wordpress.sh | sh

To take it further I used the DO API call needed to create a droplet with the given config. api-key-goes-here needs to be replaced with the one generated here: https://cloud.digitalocean.com/account/api/tokens then execute the curl:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer api-key-goes-here" -d '{"name":"wp-server","region":"nyc3","size":"s-1vcpu-1gb","image":"ubuntu-18-04-x64","ssh_keys":null,"backups":false,"ipv6":true,"user_data": "#cloud-config

runcmd:
  - curl https://raw.githubusercontent.com/lamazingco/digitalocean-wordpress-install-script/master/wordpress.sh | sh","private_networking":null,"volumes": null,"tags":["web"]}' "https://api.digitalocean.com/v2/droplets"

Checking the droplet IP it in ~5 min will display the WordPress install wizard. Tadam! Works like a charm! Thanks again @jarland for guidance!

Thanks @jarland that might actually work out pretty well. And the script looks pretty straightforward. Let me test out the script tonight and see if it does everything needed for WP to work. If so, I’d rather create an actual one Click install app. It would use the DigitalOcean API to create the droplet with everything pre-installed.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel