Creating a WordPress site using Openstack-Flex
Here I wanted to show our customers and hopefully future customers on how easy it is to host your own Wordpress site using Openstack Flex.
Below is a video that you can follow along with that will take you through a step by step setup.
Getting Started:
First you will need to set up your clouds.yaml file to be able to complete the next steps. More information about that can be found here.
Deploying Our Openstack Server
In this section I will provide examples on how I was able to set up my Openstack Server these are just examples please feel free to set up your environment as you would like.
First we need to create our router. I am naming mine wordpress-router.
Second we create our network which I will name wordpress-network.
Third we need to set the external gateway on our wordpress-router.
Fourth we are going to set up our subnet, you can choose between ipv4 and ipv6. The ip range is also up to you. For the DNS name server you will need to ping cachens1.sjc3.rackspace.com and cachens2.sjc3.rackspace.com. I am naming my subnet wordpress-subnet.
ping cachens1.sjc3.rackspace.com -c2
ping cachens2.sjc3.rackspace.com -c2
openstack --os-cloud {cloud_name} subnet create --ip-version 4 --subnet-range 172.20.108.0/24 --dns-nameserver {ip address} --dns-nameserver {ip address} --network wordpress-network wordpress-subnet
Fifth we will add our subnet to our wordpress-router
Sixth we are going to add our security group and add our ports of ingress we will need to allow for HTTP, HTTPS and SSH traffic. I am naming my security group wordpress-sg.
openstack --os-cloud {cloud_name} security group rule create --ingress --remote-ip 0.0.0.0/0 --dst-port 80:80 --protocol tcp wordpress-sg
openstack --os-cloud {cloud_name} security group rule create --ingress --remote-ip 0.0.0.0/0 --dst-port 443:443 --protocol tcp wordpress-sg
openstack --os-cloud {cloud_name} security group rule create --ingress --remote-ip 0.0.0.0/0 --dst-port 22 --protocol tcp wordpress-sg
Seventh we need to create our floating ip.
Eighth we are going to create our Public and Private ssh keys so we can securely connect to our server. I am naming my key wordpress-key
This will prompt you store and name your private key. I did something like this /home/{username}/.ssh/wordpress-key.After that we will create our public key using the command below then we will assign it using the the openstack cli tools.
ssh-keygen -f ~/.ssh/wordpress-key -y > ~/,ssh/wordpress-key.pub
openstack —os-cloud {cloud_name} key-pair create --public-key ~/.ssh/wordpress-key.pub wordpress-key
openstack --os-cloud {cloud_name} server create --flavor m1.medium --image Ubuntu-22.04 --boot-from-volume 40 --network wordpress-network --key-name wordpress-key --security-group wordpress-sg wordpress-server
Lastly we will want to make sure to assign our floating ip. We can do this by adding it to our port for the server. If you get the fixed ip from our newly create server you can find the port ID by searching through the port list. Look for the fixed ip address of our server and grab the corresponding ID.
openstack --os-cloud {cloud_name} port list
openstack --os-cloud {cloud_name} floating ip set --port {port id}
SSH into your new server!
Deploying Our Wordpress site on our Openstack-Flex Server
Once we have created our Openstack-Flex Server we will want to make sure everything is up to date.
The next step is to install apache and mysql.
Then we will want to install php and restart apache.
Next we need to use mysql and create our wordpress database with our username and password. Please create your own personal username and password.
CREATE DATABASE wordpress;
CREATE USER 'openstack-flex'@'localhost' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON wordpress.* TO 'openstack-flex'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download Wordpress.
Update our config file, you can find the example in /tmp/wordpress/wp-config-sample.php. Take this example and copy it to make your own config.
Using any text editor you are comfortable with update the 'DB_NAME', 'DB_USER', and 'DB_PASSWORD' to the values you created in the database earlier.
Next, we will copy our wordpress files to the apache root directory and set the permissions for the them.
sudo rsync -avP /tmp/wordpress/ /var/www/html/
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
Don't forget to remove the apache index.html which can be found in /var/www/html.
At this point you should be able to take our floating ip and plug it into your web browser. Then we should be greeted by the WordPress Setup page.