Do you want to create a new blog using WordPress? If you new to WordPress and thinking about sharing your thoughts online with others, you are on the right way. According to W3techs, 59.6% of the websites in the world are made of WordPress. As a Content Management System(CMS), WordPress is a free Open-source software which is popular and very easy to use. Keep in mind that WordPress is a self-hosted blogging platform, that means you can install it on VPS , Web hosting or Dedicated server.
While you may heard of some other Website Builders&platforms before, such as Webflow, Shopify blog, SquareSpace, Blogger, Drupal, Joomla and more, we would strongly recommend WordPress because of its lower maintenance costs and easy setup, with WordPress One-Click Installer(Softaculous Apps Installer), you can get a site running on web hosting in minutes. In addition to start a blog, you can also use WordPress to build an eCommerce site with WooCommerce plugin to sell online, to create a forum to share ideas, to start a business website to make money, and what’s more, you can customize it however you want to.
Thanks to millions of web developers and designers all over the world, there are a ton of free professional WordPress plugins& themes we can choose from. You can either pick a premium WordPress theme from an independent developer or 3rd Party theme marketplace, and of course you can create and design a unique wp template for individual needs. All these features make WordPress more powerful, highly customizable, flexible and easy to scale to grow your businesses. It is the best blogging platform for whom to create websites to start their own online businesses!
In this complete tutorial, we’ll show you how to set up your WordPress blog step-by-step. You will find out all the thing you need to learn how to start a blog as a beginner. There are a variety of ways to build a website, personally, I think WordPress should be the best one for you and your online business. We’ll cover WordPress site installation on Ubuntu Cloud VPS(Virtual Private Server) and Web Hosting(aka Shared Hosting).
If you are setting up a WordPress blog all on your own, after reading this beginner’s guide from start to finish, you will get your site up and running! I Promise!
I. First of all, let’s talk about Shared hosting vs. VPS hosting vs. Dedicated server: which web hosting is best for you to launch a new website?
II. Secondly, we will learn about: how to Install WordPress manually on any Shared Web Hosting and how to install WordPress by using One-Click Installer on cPanel.
III. Lastly, we’d like to share with you the experience about: how to set up WordPress blog on Ubuntu with DigitalOcean Droplets or Vultr Cloud Compute (VPS).
- Chapter I. Shared hosting vs. VPS hosting vs. Dedicated server
- Chapter II. Install WordPress On Shared Hosting With cPanel
- 2.1 Prepare Some Things Before We Start installing WordPress On Shared Hosting
- 2.2 How To Install WordPress via One-Click Installer Shared Hosting(cPanel)
- 2.3 How To Install WordPress Manually On Shared Web Hosting(cPanel)
- Chapter III. How To Set Up WordPress blog on Ubuntu Linux Server(VPS)
- 3.1 How To Start A Blog Using DigitalOcean’s WordPress One-Click Application(VPS)
- How To Create SSH Keys With PuTTY On Windows Or OpenSSH On Unix-like system(macOS, Linux, FreeBSD)
- How To Add Your Public Key To Your Ubuntu Server?
- How To Set Up DNS Records(A records(IPv4) and AAAA Record (IPv6)) For Your Domain?
- How To Connect To Your Ubuntu Droplet Server With PuTTY On Windows?
- How To Connect To Your Ubuntu Droplet Server With OpenSSH On Unix-like Systems(macOS, Linux, FreeBSD)?
- 3.2 How To Install WordPress With LEMP(Linux, Nginx, MySQL, PHP) On A Droplet Ubuntu VPS
- Conclution
Chapter I. Shared hosting vs. VPS hosting vs. Dedicated server: Which web hosting is the right for you to build a website?
Shared hosting, VPS hosting and Dedicated server are three of the most popular web hostings on WordPress Website setup. You may not be sure whether to go with a VPS hosting, a Shared hosting or a Dedicated server to create a new blog? The three are very different, in this section, we will talk about their advantages and disadvantages, so you can choose the right hosting for your online business.
1.1 Shared Hosting:
Shared hosting is similar to living in a dormitory, you have to share a room with others. Many WordPress blogs start with shared hosting plan because of it is cheap and beginner-friendly, easy to handle maintenance, especially for whom doesn’t have a lot of technical experience in building their own WordPress website.
Pros of Shared Hosting:
✔ It’s typically cheap, some hosting plans are as low as $2.95/mo (like Fastcomet).
✔ Beginner-friendly, getting started is very simple with cPanel.
✔ Most of hosting plans offer a free domain and unlimited bandwidth.
✔ A lot of free tools, so you don’t have to configure the web server manually.
Cons of Shared Hosting:
✖ With a shared hosting, you have to share the resources with other people.
✖ There are so many other sites running on the same server, sometimes you blog can be slow.
✖ All websites on same server share the same IP address, if someone’s site is hacked, you may suffer.
✖ It’s difficult to scale your business due to the limited physical resources(CPU, Storage and Bandwidth).
1.2 VPS(Virtual Private Server) Hosting:
Virtual Private Server is much like living in an apartment, you have your own space. You have the benefit of being able to customize the room for individual needs, but it requires a bit more technical maintenance.
Pros of VPS hosting:
✔ It’s usually still inexpensive, $5~$100/mo.
✔ Many of the VPS providers offer different operating system templates.
✔ Your pages will load faster than shared hosting, because you are allocated more resources.
✔ Easy to scale, you can get ROOT access to your server, so you have more control over your website.
Cons of VPS hosting:
✖ Your website can be slow, due to some VPS providers oversell their server.
✖ A little more expensive than shared hosting, if you only have a small budget on it.
✖ You should have some technical experience in handling security, updates and maintenance, or you may need to hire a developer to do this.
1.3 Dedicated Hosting:
A dedicated server is exactly like living in a villa, you don’t need to share the space with anyone else. Your site’s data is stored on a physical server,
and you are in full control of your server. In a nutshell, you will be able to configure and customize your website as much as you might like.
Pros of Dedicated Hosting:
✔ You have full control of all the resources on the server.
✔ Your website is fast, you don’t have to worry about someone else competes with you for the resources.
✔ Dedicated server providers offer 24/7 priority technical support.
✔ Thanks to a professional team takes care of your server, the security risks are lowered.
Cons of Dedicated Hosting:
✖ It’s usually very expensive, $100~$1000/mo.
✖ You have to hire an expert or a team to handle security, updates and maintenance, this may break your budget.
✖ You should have a big budget plan for your business.
Summing Up
Whether you go with a Shared hosting, a VPS hosting or a Dedicated server will depend on what you need and what kind of website you want to build.
If you need to build a blog or small website with minimal traffic, and you don’t have the time or technical experience, the Shared hosting should be the best option.
If you plan to run a small online store(like a woocommerce store) or a small business site, and you have a minimal budget, a VPS hosting might be a good choice for you.
If you are starting a large business with high-traffic site requires excessive bandwidth and a high level of security, a Dedicated server will probably be sufficient for you.
Chapter II. Install WordPress manually on any Shared Web Hosting and how to install WordPress by using One-Click Installer on cPanel
Fastcomet, Dreamhost, Bluehost are three of the most popular shared web hostings, they have been around for years. The steps to building WordPress websites on shared hostings are quite similar. Personally, I’m pretty big fans of fastcomet – a fast web hosting provider, they offers a new free domain name and free SSL when you first sign up. So in this guide, we will use Fastcomet shared hosting to set up our first demo WordPress blog step-by-step.
In addition to these three web hosting, you can also do your research to pick the best WordPress hosting for your business. And what’s more, managed WordPress Hosting should be a right choice for you, especially when you don’t have any technical experience on how to use cPanel. The final tip:The most important thing is that you should choose a reliability hosting for your website. Are you ready? let’s get started.
2.1 Before we get started installing WordPress on shared web hosting, we need to prepare some things.
Step 1: Visit Fastcomet.com homepage and select menu All Services> Web Hosting, then click on the “GET STARTED” button to select your preferred shared hosting plan.
Step 2: On the first page, you can choose “Register a domain for free” or “I already Have a domain“, if you select the first one, you can get a free domain from Fastcomet.
And of course you can also choose the second one If you already registered a domain before.
Step 3: On the second page, you need fill in your personal details to create your account, If you’re new to Fastcomet, you should choose ‘I’m a New Customer‘.
On the same page, you can set your Master Password and select your Billing Cycle.
On the end of second page, you can choose the Datacenter Location and Payment Method(Credit Card or PayPal).
Once you are ready to complete your order, click on the “Create Account” button to Check Out. Then you will be redirected to the Admin Dashboard.
You will receive an email with your Hosting Account Control panel Username and Password send by Fastcomet.
Step 4: Using the login details emailed to you by Fastcomet, login to your Fastcomet hosting cPanel.
Step 5: Before we go next step, you could secure your WordPress website with Let’s Encrypt, sites without an SSL certificate will be treated as “Not secure” by major browsers. The green address bar tells us that the website is safe to do business with. Although an SSL certificate is not necessary, I still recommend you should install it to enable encrypted HTTPS on your web server, since Let’s Encrypt certificate is 100% free and easy to setup.
Head to your Fastcomet cPanel page, In the SECURITY section, click Lets Encrypt™ SSL.
You will be redirected to a new page with information about Let’s Encrypt™ certificate, in Issue a new certificate section, click +Issue:
On next page, check the domains you want to Install certificate, select http-01 as your SSL validation method and click on Issue button, wait a minute, the installation will be completed soon.
You can Remove, Reinstall and View the certificates you have installed under your cPanel > SECURITY > Lets Encrypt™ SSL.
2.2 How to install WordPress via cPanel Softaculous(One-Click Installer) on shared web hosting
Step 1: In the cPanel > Softaculous Apps Installer section, click the WordPress icon.
Step 2: You will be redirected to Softaculous WordPress Installer dashboard, click on Install Now buttton.
Step 3: On the next page, you need to configure few options of WordPress Installation.
On the first screen, you can choose:
✔ the WordPress version you want to install.
✔ domain with WWW or NO-WWW, HTTP or HTTPS protocol.
✔ the domain to install the WordPress.
✔ In Directory – if you want to install WordPress blog into a subdirectory on your server, your WordPress site url will be like https://your-domain.com/blog, you should set it to “blog”(by default is set to “wp”), or you need to leave this field blank and your WordPress site url will be like https://your-domain.com.
On the second screen, you can set Site Name, Site Description and Enable Multisite (WPMU), Admin Username and Password, Admin Email, then you can Select Language for your WordPress blog.
On the third screen, we need to configure the advanced Options, such as Database Name, Table Prefix, Backup and more, if you don’t know how to configure, just let them Default.
(Optional)On the last screen, you can select a free WordPress theme for your blog, If not selected, the default theme will be installed.
Step 4: Click the Install button to install WordPress.
Step 5: You will be redirected to a congratulations page when the installation is completed, visit the url: https://your-domain.com/wp-admin , login to your blog with the login details above ⤴︎.
Step 6: Customize and secure your WordPress blog with themes and plugins.
Congratulations! You have successfully installed the WordPress blog!
2.3 How to Install WordPress manually on shared web hosting
Step 1: Download WordPress installation package from WordPress.org, ensure all the necessary things have been prepared before you begin installing WordPress.
Step 2: Create MySQL Database and User, In the cPanel > DATABASES section, click the MySQL Database Wizard icon.
You will be redirected to the MySQL Database Wizard page:
MySQL Database Wizard Step 1: Create A Database, enter your database name, in this guide we create a database – todolibd_demo, and then click Next Step.
MySQL Database Wizard Step 2: Create Database Users, enter your user name and password, in this guide we create a user – todolibd_user, and then click Create User.
MySQL Database Wizard Step 3: Add User to the Database, select the All PRIVILEGES checkbox to make all the privileges checked, and then click Next Step to complete the task.
Step 3: Configure wp-config.php file, extract the downloaded package file( WordPress.zip) to a folder on your local hard drive.
In the WordPress folder, right click on the file and rename wp-config-sample.php to wp-config.php.
We need to edit wp-config.php file manually, right click on the file and open it in a text editor(Notepad++ or Sublime Text), in this tutorial, we use coda2(for Mac) to edit it.
When the file opens:
- replace ‘database_name_here‘ with your database name( e.g, todolibd_demo ) that you save above in Step 2: Create MySQL Database and User ⤴︎.
- replace ‘username_here‘ with your database username( e.g, todolibd_user ) that you save above in Step 2: Create MySQL Database and User ⤴︎.
- replace ‘password_here‘ with your database password( e.g, cyxbac-xygke7-rofank ) that you save above in Step 2: Create MySQL Database and User ⤴︎.
- Update WordPress secret keys, visit the WordPress secret key generator URL, copy the content on the page, and then delete the default placeholder, paste the new content there.
- (Optional) for security purposes, we recommend that you should replace $table_prefix default value ‘wp_‘ with a unique value (e.g, wp_todolibdemo_).
Step 4: Upload WordPress Files to Your Web Hosting server.
You can upload the files via File Manager with cPanel:
In the cPanel > FILES section, click File Manager icon, you will redirected to the File Manager page in a new browser tab.
Click public_html folder, and then click ⬆︎Upload, on File Upload page, Select files and upload all the contents in the WordPress directory(but not the WordPress directory itself).
In this guide, we will upload files via FTP clients, like FileZilla(Both free on Windows and Mac), WinSCP(free on Windows), Cyberduck(free on Mac), Transmit(paid only on Mac), etc. We will use Transmit5 to upload files for our demo blog.
Where can I find my FTP username and password in cPanel?
In the cPanel > FTP Accounts section, click FTP Accounts icon, you will redirected to the FTP Accounts page.
On this page you can create an FTP Account. We will use the default hosting FTP Account, in Special FTP Accounts field, choose your hosting account and click ⚙Configure FTP Client.
On the next screen, you can get your Ftp account details.
Open your FTP client, set the option of Protocol to FTP( Pro Tip: Use SFTP for a secured connection if your host supports it), Enter your ftp Address, Port, User Name and Password(Your cPanel Password), and then click Connect.
If the login is successful, you will see a listing of files and folders will appear, on the left column of the window, navigate to the WordPress directory on your local hard drive, on the right column of the window, navigate to public_html folder on your hosting server, use shortcut Ctrl+A( Mac: ⌘Command-A ) to select the WordPress files, and drag all files to public_html folder.
Once the uploading is completed, you can see all the WordPress files appear in public_html folder.
Step 5: Run the WordPress Installation.
Open your browser and visit your primary domain(e.g, your-domain.com), you will redirected to https://your-domain.com/wp-admin/install.php, choose the language and click Continue button.
On the next page, you need to enter your website title, your blog username and password, your email address, then click Install WordPress button.
Step 6: Complete the Installation.
When you successfully install the WordPress, you will see the following message: Success! WordPress has been installed. Thank you, and enjoy!
Login you site and it’s time to customize, design and secure your WordPress blog with themes and plugins.
Chapter III. How to set up WordPress blog on Ubuntu linux server with DigitalOcean Droplets and Vultr Cloud Compute (VPS)
When it comes to VPS hosting, some of us may feel a bit overwhelming with the cumbersome installation and configuration. In fact, benefit from the open source softwares and improvement of information technology, to set up a website with VPS hosting become more and more easily and inexpensive. You don’t even need to have a lot of technical experience in building a website on a VPS hosting.
There are so many awesome VPS hostings we can choose from, personally, we recommend two cloud VPS hosting providers – digitalocean and vultr. Both of them provide us with extensive documentation and helpful community, and their VPS Control Panels are beginner friendly and easy to use. Then they might be the best VPS and Cloud Hostings to create WordPress websites for small business! In this tutorial, we will start with digitalocean.
3.1 How to start a blog using DigitalOcean’s WordPress One-Click application on Ubuntu Droplets(VPS)
By using One-Click App you can skip the complex server installation and configuration, get straight to deploying your WordPress site in minutes. I will show you how to do that step-by-step below, enjoy!
Step 1: Create an Account for digitalocean, go to digitalocean.com, enter your email address and password, then click “Create your account” to create a new account, or you can also Sign up with your Google account.
Step 2: On the top of your Digitalocean Control Panel, click on “Create” button, select Droplets in the drop-down menu.
Step 3: Start your first Droplets vps server using the One-Click Apps.
On the first screen, click on One-click apps, and then choose “WordPress on 18.04″ app.
On the second screen, choose your plan for your website, in this guide, we select the Standard Droplet for the WordPress demo blog.
On the third screen, you can choose a datacenter region, select additional options(Private networking, IPv6, User data, Monitoring) and add SSH keys. ( Pro Tip: we recommend select IPv6 and Monitoring here. )
Step 4: How to Create SSH Keys with PuTTY on Windows or OpenSSH on Unix-like systems(macOS, Linux, FreeBSD).
Create SSH keys on Windows:
Visit the PuTTY website, download the putty-xxx-installer.msi Package files and install it on your computer.
Start the PuTTYgen program through your Windows Start Menu.
Click on the Generate button on the right-hand side to generate SSH keys.
generate some randomness by moving your mouse over the blank area to create keys in a secure fashion.
Once the SSH Key is generated, you will see the SSH public key in the text box, select the entire key and copy it into your clipboard, be sure to scroll down to the end of the text area so you copy the entire key, or you would probably get errors when you try to login your server with the private key.
Then click the Save private key button to keep the id_rsa.ppk file in a secure location on your hard drive.
Create SSH keys on Unix-like systems(macOS, Linux, FreeBSD):
Open the Terminal on your computer and enter:
ssh-keygen
then press ENTER to continue, you can select a location for the keys or use the default directory( ~/.ssh), next you need to set a passphrase or leave it empty by pressing ENTER.
When the SSH Key is generated, you will find id_rsa.pub file (Public key) and id_rsa file (Private key) are stored in the ~/.ssh (macOS: /username/.ssh, Linux&FreeBSD: /home/username/.ssh)
Open the id_rsa.pub file with text editor (like Sublime Text, Vim, Nano), Next, copy the Public key into your clipboard.
Step 5: How to Add your Public key to your DigitalOcean Ubuntu server?
In Add your SSH keys section, Click New SSH key button, Paste the contents that we got above ⤴︎ into the SSH key content field and then click Save SSH key button to save it.
step 6: Scroll to the end of the DigitalOcean Droplets setup page, Click the Create button to create your first WordPress Droplets.
Step 7: Before we go next, you should set up DNS records for your domain and point it to the public IP address of your server, there are two DNS records.
If you are using name servers, login to your Name.com account and head to MY DOMAINS > DNS Records on the left, then create two A records as following:
An A record from the domain (e.g, your-domain.com) to the server’s public IP address.
An A record from the domain prefaced with www (e.g, www.your-domain.com) to the server’s public IP address.
How to Add an AAAA Record (IPv6)?
(Optional)If you have already added IPv6 on Droplet creation page, you can Add two AAAA Records (IPv6):
An AAAA record from the domain (e.g, your-domain.com) to the server’s public IPv6 address.
An AAAA record from the domain prefaced with www (e.g, www.your-domain.com) to the server’s public IPv6 address.
Step 8: Once you have your WordPress One-Click Droplet available, you can login the Ubuntu server via SSH to finish the WordPress setup.
How to Connect to your Ubuntu Droplet server with PuTTY on Windows?
Start the PuTTY program through your Windows Start Menu, and then Configure your PuTTY: fill in your server’s public IP address(or Host Name), set the Port to 22(Pro Tip: if you are using other Port, change it. ), set the Connection type to SSH.
Next, click SSH in the left sidebar under Connection category, in the Auth subcategory, click the Browse button to pick your Private key file( id_rsa.ppk) for authentication, then click Open button to connection your server.
If this is the first time you connect to a server, PuTTY will ask you to confirm that you trust the server, Choose Yes and go next.
Next, PuTTY will ask you ‘login as:‘, type in root(Pro Tip: you can also login as a regular and non-root user account on your server with sudo privileges). Once you have successfully authenticated, you will be connected to your server.
How to Connect to your Ubuntu Droplet server with OpenSSH on Unix-like systems(macOS, Linux, FreeBSD)?
Open the Terminal on your system OS and type in command below ⤵︎:
ssh -i ~/.ssh/id_rsa root@yourServerIP
And then press ENTER to the continue.
Next, you will be asked if you are sure you want to continue connecting. Type yes and then press ENTER to connect to your server.
Step 9: Login to the your Droplet server via SSH to finish the WordPress setup.
When you’ve successfully logged in, your command prompt will display like root@WordPress-s-1vcpu-1gb-sfo2-01:~#.
Next, the WordPress One-Click setup interactive script that runs will first prompt you for your domain:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Enter the domain name for your new WordPress site.
(ex. example.org or test.example.org) do not include www or http/s
-------------------------------------------
Domain/Subdomain name: todolib-demo.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Type in your primary domain (e.g, your-domain.com) and press ENTER.
Next, you need to configure the LetsEncrypt SSL Certificate to secure your new WordPress blog.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you like to use LetsEncrypt (certbot) to configure SSL(https) for your new site? (y/n): y
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): admin@todolib-demo.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Type in your Email Address (e.g, email@your-domain.com) here and press ENTER, then answer A for agree, Y for yes, or anything else to continue.
To test automatic renewal for your certificates, you can do a dry run with certbot:
If you login as a regular and non-root user, please run the commands below⤵︎ start with ‘sudo‘.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
certbot renew --dry-run
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If the automatic renewal process ever fails, don’t worry, Let’s Encrypt will send a email to you when the certificates are about to expire. Next, you can renew your certificates by running this command:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
certbot renew
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
When the installation is complete, you’ll see a confirmation message:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WordPress has been enabled at https://todolib-demo.com Please open this URL in a browser to complete the setup of your site.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Visit URL https://your-domain.com/wp-admin/install.php to select language and click Continue button to next.
Next, you have to enter your WordPress blog title, your website username and password, your admin email address, then click Install WordPress button.
Congratulations! You have successfully installed your first WordPress blog on a VPS server, so go to design, customize and secure your WordPress blog with themes and plugins.
3.2 How to Install WordPress with LEMP(Linux, Nginx, MySQL, PHP) on a Droplet Ubuntu VPS Server Manually
Step 1: Log into DigitalOcean account, on the top of your Digitalocean Control Panel, click on “Create” button, select Droplets in the drop-down menu.
Step 2: Choose an image and a Droplet size, in this guide, we will select Ubuntu 18.04 x64 for our WordPress blog installation.
Step 3: On this screen, pick a datacenter region, select additional options(Private networking, IPv6, User data, Monitoring) and add your SSH keys. (We recommend select IPv6 and Monitoring here. )
Step 4: Once you have already added SSH Keys, then click the Create button to create a Droplet.
Step 5: Login to the your Ubuntu server via SSH to install LEMP and then finish WordPress setup.
Once you’ve successfully logged into you server, your command prompt will display as root@Ubuntu-s-1vcpu-1gb-sfo2-01:~#.
If you login as a regular and non-root user, please run the commands below ⤵︎ start with ‘sudo‘.
First update your server’s package index by running a command as the following:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt update
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Next, install the nginx server:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt install nginx
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If your nginx server is work correctly, go to URL http://Your_Server_Public_IP you can see Nginx’s default landing page:
Installing MySQL to Manage website Data:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt install mysql-server
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Next, configure MySQL with secure installation:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mysql_secure_installation
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please answer Y for yes, or anything else to continue.
Please set you password as following if you select the strongest level:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
passfor_todolib_Demo123@#
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Creating a MySQL Database and User for your WordPress Blog.
Run the command below to log into the MySQL root (administrative) account:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mysql -u root -p
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press ENTER and type in the password you set above to continue.
Pro Tip: Every MySQL command statement must end with a semi-colon (;), check this if you are running into any issues.
First, we need to create a separate MySQL User(e.g, todolib_demo_wp_user) and set its Password(e.g, passfor_todolib_Demo123@#) that WordPress can control:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CREATE USER todolib_demo_wp_user@localhost IDENTIFIED BY 'passfor_todolib_Demo123@#';
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Second, we will create a separate Database(e.g, todolib_demo_database) for WordPress blog:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CREATE DATABASE todolib_demo_database;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Third, let MySQL User(e.g, todolib_demo_wp_user) grant access to the Database(e.g, todolib_demo_database) we created:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
GRANT ALL PRIVILEGES ON todolib_demo_database.* TO todolib_demo_wp_user@localhost;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Fourth, we need to flush the privileges for current instance of MySQL:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FLUSH PRIVILEGES;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Finally, we will Exit out of MySQL by typing:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EXIT;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Installing PHP core files and additional PHP Extensions for WordPress site
First, we need to add Ubuntu’s universe repository:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add-apt-repository universe
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Then update Ubuntu package index:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt update
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Next, install the necessary PHP core files:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt install php-fpm php-mysql
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Finally, we need to install some of the most popular PHP extensions for WordPress:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt install php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip php-ctype
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Configuring Nginx
Next, we need to Configuring Nginx, usually you may have to edit the nginx.conf manually. But in we will use an open source NGINX configuration generator script by nginxconfig.io to generator the nginx.conf file.
If you like Short URL with NO-WWW https://your-domain.com as your primary domain, here is the Nginx configuration for our demo WordPress site in this guide.
If you like URL with WWW https://www.your-domain.com as your primary domain, you can use this Nginx configuration.
On the NGINX configuration generator page, you only need to change Domain and Document root fields to your own.
The whole web root directory should be like the following(on Ubuntu):
/var/www/todolib-demo/(the WordPress php files)
Next, on Tools tab and click Generated config (.zip) button, download the generated config nginxconfig.io-xxx.zip file and extract it to your local hard drive.
Upload NGINX config files and WordPress install files to server hosting via FTP clients
Pro Tip: in this tutorial, we will use WinSCP (free on Windows) to upload files, you can other FTP clients, such as FileZilla(Both free on Windows and Mac), Cyberduck(free on Mac), Transmit(paid only on Mac).
Install and Configure WinSCP
First, download WinSCP and install it on your local computer and start the WinSCP program on your Windows Start Menu.
and then Configure your WinSCP: set File protocol type to SFTP, fill in your server’s public IP address(or Host Name), set the Port to 22(Pro Tip: if you are using other Port, change it.) and set User name to root, because we will use SSH key authentication to log into the Ubuntu server, so leave Password blank.
Next, click Advanced button to Advanced Site Settings panel, in the left sidebar under SSH category, in the Authentication subcategory, click the Browse button (…) to pick your Private key file( id_rsa.ppk) for authentication, then click OK and save it.
Then click login to connection your server, before you connect to a server for the first time, WinSCP will ask you to confirm that you trust the server, choose Yes and continue.
If the login is successful, you will see a listing of files and folders will appear, If NOT, just click( ⤴︎.. )folder icon.
On the left column of the WinSCP window lists directory of your local computer, on the right column of the WinSCP window lists directory of your remote Ubuntu hosting server.
Upload WordPress install files to web root directory.
First, download WordPress package file from WordPress.org, then extract WordPress-xxx.zip to a folder on your local hard drive.
Next, Configure wp-config.php file before we uploading it to server.
In the local WordPress folder, right click on the file and rename wp-config-sample.php to wp-config.php.
We need to edit wp-config.php file manually, right click on the file and open it in a text editor(Notepad++ or Sublime Text), in this tutorial, we use coda2(for Mac) to edit it.
When the wp-config.php file opens:
- replace ‘database_name_here‘ with the Database you created above ⤴︎( e.g, todolib_demo_database ).
- replace ‘username_here‘ with MySQL User name you created above ⤴︎( e.g, todolib_demo_wp_user).
- replace ‘password_here‘ with your Database Password you set above ⤴︎( e.g, passfor_todolib_Demo123@#).
- (Optional) for security purposes, we recommend that you should replace $table_prefix default value ‘wp_‘ with a unique value (e.g, wp_todolibdemo_).
- Update WordPress secret keys, visit the WordPress secret key generator URL, copy the content on the page, and then delete the default placeholder, paste the new content there.
On the left column, navigate to the local WordPress directory, then use shortcut Ctrl+A( Mac: ⌘Command-A ) to select files and folders in WordPress directory, and drag all files to the right column – your web root directory(e.g, /var/www/todolib-demo).
Set the User and Owner of your web root directory(include sub-directory) to www-data after you have uploaded WordPress files as a root.
Pro Tip: It’s very IMPORTANT, please check this if you are running into any issues on using WordPress, e.g, you can’t upload a image or add a new theme.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
chown -R www-data:www-data /var/www/your_wordpress_files_folder/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
How To Secure Nginx with Let’s Encrypt on Ubuntu 18.04
First, add the repository, press ENTER to accept:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
add-apt-repository ppa:certbot/certbot
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Then update Ubuntu package index:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt update
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Install Certbot’s Nginx package with apt:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apt install python-certbot-nginx
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Obtain a free SSL Certificate through the Nginx plugin:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
certbot --nginx -d your-domain.com -d www.your-domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Next, press ENTER, then answer A for agree, Y for yes, or anything else to continue.
Pro Tip: Let’s Encrypt’s SSL certificates are only valid for 90 days, we use a script to renew the certificate automatically. To test automatic renewal for your certificates, you can do a dry run with certbot:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
certbot renew --dry-run
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If the automatic renewal process ever fails, don’t worry, Let’s Encrypt will send a email to you when the certificates are about to expire. Next, you can renew your certificates manually by running this command:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
certbot renew
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Upload NGINX config files to replace the default nginx.conf file
On the left column, navigate to the nginxconfig.io-xxx directory, then use shortcut Ctrl+A( Mac: ⌘Command-A ) to select files and folders in nginxconfig.io-xxx directory, and drag all files to /etc/nginx folder replace the default nginx.conf file.
Next, reload Php-fpm and Nginx service by typing the following command:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
systemctl restart php7.2-fpm
systemctl restart nginx
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If no errors were reported, Visit URL https://your-domain.com/wp-admin/install.php to select language and click Continue button to next.
Then you need to enter your WordPress site title, your website username and password, your admin email address, then click Install WordPress button.
Congratulations! You have successfully installed your first WordPress site on a VPS hosting.
Next step, learn a bit about how to add Google Analytics tracking code to WordPress site?
Conclusion
Using a VPS or a Shared hosting to start a blog is not a hard task with WordPress. Most web hosting hosting providers offer one-click setup options for WordPress, you can set up a website in a few minutes. In addition to this, you can also customize your VPS hosting by using the command line, but it’s not difficult, you just need to follow the guide and press ENTER again and again. So choose a right web hosting to build your first WordPress blog.
Need some help building your WordPress blog on a web hosting? It would be great if you comment below to help us improve this post.