Sign In
Sign In

How to Install WordPress with Nginx and Let’s Encrypt SSL on Ubuntu

How to Install WordPress with Nginx and Let’s Encrypt SSL on Ubuntu
Hostman Team
Technical writer
Wordpress Ubuntu
13.11.2024
Reading time: 13 min

WordPress is a simple, popular, open-source, and free CMS (content management system) for creating modern websites. Today, WordPress powers nearly half of the websites worldwide. Hostman offers Wordpress cloud hosting with quick load times, robust security, and simplified management. 

However, having just a content management system is not enough. Modern websites require an SSL certificate, which provides encryption and allows using a secure HTTPS connection.

This short guide will show how to install WordPress on a cloud server, perform initial CMS configuration, and add an SSL certificate to the completed site, enabling users to access the website via HTTPS.

The Nginx web server will receive user requests and then proxied to WordPress for processing and generating response content.

A few additional components are also needed: a MySQL database, which serves as the primary data storage in WordPress, and PHP, which WordPress is written in.

This technology stack is known as LEMP: Linux, Nginx, MySQL, PHP.

Step 1. Creating the Server

First, you will need a cloud server with Ubuntu 22.04 installed.

  1. Go to the Hostman control panel.
  2. Select the Cloud servers tab on the left side of the control panel.
  3. Click the Create button.

You’ll need to configure a range of parameters that ultimately determine the server rental cost. The most important of these parameters are:

  • The operating system distribution and its version (in our case, Ubuntu 22.04).
  • Data center location.
  • Physical configuration.
  • Server information.

Once all the data is filled in, click the Order button.

Upon completion of the server setup, you can view the IP address of the cloud server in the Dashboard tab, and also copy the command for connecting to the server via SSH along with the root password:

883aecb6 Cc5e 4826 93be Afa062fae5c8

Next, open a terminal in your local operating system and connect via SSH with password authentication:

ssh root@server_ip

Replace server_ip with the IP address of your cloud server. You will then be prompted to enter the password, which you can either type manually or paste from the clipboard.

After connecting, the terminal will display information about the operating system. Now you can create a user with sudo priviliges or keep using root.

Step 2. Updating the System

Before beginning the WordPress installation, it’s important to update the list of repositories available through the APT package manager:

sudo apt update -y

It’s also a good idea to upgrade already installed packages to their latest versions:

sudo apt upgrade -y

Now, we can move on to downloading and installing the technology stack components required for running WordPress.

Step 3. Installing PHP

Let's download and install the PHP interpreter.

First, add a specialized repository that provides up-to-date versions of PHP:

sudo add-apt-repository ppa:ondrej/php

In this guide, we are using PHP version 8.3 in FPM mode (FastCGI Process Manager), along with an additional module to enable PHP’s interaction with MySQL:

sudo apt install php8.3-fpm php-mysql -y

The -y flag automatically answers “yes” to any prompts during the installation process.

To verify that PHP is now installed on the system, you can check its version:

php -v

The console output should look like this:

PHP 8.3.13 (cli) (built: Oct 30 2024 11:27:41) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.13, Copyright (c) Zend Technologies
   with Zend OPcache v8.3.13, Copyright (c), by Zend Technologies

You can also check the status of the FPM service:

sudo systemctl status php8.3-fpm

In the console output, you should see a green status indicator:

Active: active (running)

Step 4. Installing MySQL

The MySQL database is an essential component of WordPress, as it stores all site and user information for the CMS.

Installation

We’ll install the MySQL server package:

sudo apt install mysql-server -y

To verify the installation, check the database version:

mysql --version

If successful, the console output will look something like this:

mysql  Ver 8.0.39-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

Also, ensure that the MySQL server is currently running by checking the database service status:

sudo systemctl status mysql

The console output should display a green status indicator:

Active: active (running)

MySQL Security

This step is optional in this guide, but it’s worth mentioning. After installing MySQL, you can configure the database’s security settings:

mysql_secure_installation

This command will prompt a series of questions in the terminal to help you configure the appropriate level of MySQL security.

Creating a Database

Next, prepare a dedicated database specifically for WordPress.

First, log in to MySQL:

mysql

Then, execute the following SQL command to create a database:

CREATE DATABASE wordpress_database;

You’ll also need a dedicated user for accessing this database:

CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'wordpress_password';

Grant this user the necessary access permissions:

GRANT ALL PRIVILEGES ON wordpress_database.* TO 'wordpress_user'@'localhost';

Finally, exit MySQL:

quit

Step 5. Downloading and Configuring Nginx

The Nginx web server will handle incoming HTTP requests from users and proxy them to PHP via the FastCGI interface.

Download and Installation

We’ll download and install the Nginx web server using APT:

sudo apt install nginx -y

Next, verify that Nginx is indeed running as a service:

systemctl status nginx

In the console output, you should see a green status indicator:

Active: active (running)

You can also check if the web server is functioning correctly by making an HTTP request through a browser. Enter the IP address of the remote server in the address bar, where you are installing Nginx. For example:

http://166.1.227.189

If everything is set up correctly, Nginx will display its default welcome page.

For good measure, let’s add Nginx to the system’s startup list (though this is typically done automatically during installation):

sudo systemctl enable nginx

Now, you can proceed to make adjustments to the web server configuration.

Configuration

In this example, we’ll slightly modify the default Nginx configuration. For this, we need a text editor. We will use nano.

sudo apt install nano

Now open the configuration file:

sudo nano /etc/nginx/sites-enabled/default

If you remove all the comments, the basic configuration will look like this:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }
}

To this configuration, we’ll add the ability to proxy requests to PHP through FastCGI:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # added index.php to index files
    index index.html index.htm index.nginx-debian.html index.php;

    # specify the domain name to obtain an SSL certificate later
    server_name mydomain.com www.mydomain.com;

    location / {
        # try_files $uri $uri/ =404;

        # direct root requests to /index.php
        try_files $uri $uri/ /index.php?$args;
    }

    # forward all .php requests to PHP via FastCGI
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }
}

Note that the server_name parameter should contain the domain name, with DNS settings including an A record that directs to the configured server with Nginx.

Now, let’s check the configuration syntax for errors:

sudo nginx -t

If everything is correct, you’ll see a confirmation message in the console:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Then, reload the Nginx service to apply the new configuration:

sudo systemctl reload nginx

Step 6. Installing an SSL Certificate

To obtain an SSL certificate from Let’s Encrypt, we’ll use a special utility called Certbot. In this guide, Certbot will automate several tasks:

  • Request the SSL certificate.
  • Create an additional Nginx configuration file.
  • Edit the existing Nginx configuration file (which currently describes the HTTP server setup).
  • Restart Nginx to apply the changes.

Obtaining the Certificate

Like other packages, install Certbot via APT:

sudo apt install certbot
sudo apt install python3-certbot-nginx

The first command installs Certbot, and the second adds a Python module for Certbot’s integration with Nginx. Alternatively, you can install python3-certbot-nginx directly, which will automatically include Certbot as a dependency:

sudo apt install python3-certbot-nginx -y

Now, let’s initiate the process to obtain and install the SSL certificate:

sudo certbot --nginx

First, Certbot will prompt you to register with Let’s Encrypt. You’ll need to provide an email address, agree to the Terms of Service, and optionally opt-in for email updates (you may decline this if desired).

Then, enter the list of domain names, separated by commas or spaces, for which the certificate should be issued. Specify the exact domain names that are listed in the Nginx configuration file under the server_name directive:

  • mydomain.com
  • www.mydomain.com

After the certificate is issued, Certbot will automatically configure it by adding the necessary SSL settings to the Nginx configuration file:

listen 443 ssl; # managed by Certbot

# RSA certificate
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot

include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

# Redirect non-https traffic to https
if ($scheme != "https") {
	return 301 https://$host$request_uri;
} # managed by Certbot

So, the complete Nginx configuration file will look as follows:

server {
	listen 80 default_server;
	listen [::]:80 default_server;

	listen 443 ssl; # managed by Certbot

	# RSA certificate
	ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
	ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot

	include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

	root /var/www/html;

	index index.html index.htm index.nginx-debian.html index.php;

	server_name domain.com www.domain.com;

	# Redirect non-https traffic to https
	if ($scheme != "https") {
	return 301 https://$host$request_uri;
	} # managed by Certbot

	location / {
		# try_files $uri $uri/ =404;

		# direct root requests to /index.php
		try_files $uri $uri/ /index.php?$args;
	}

	# forward all .php requests to PHP via FastCGI
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php8.3-fpm.sock;
	}
}

Automatic Certificate Renewal

Let’s Encrypt certificates expire every 90 days, so they need to be renewed regularly. Instead of manually renewing them, you can set up an automated task.

For this purpose, we’ll use Crontab, a scheduling tool in Unix-based systems that uses a specific syntax to define when commands should run.

Install Crontab:

sudo apt install cron

And enable it:

sudo systemctl enable cron

Now open the Crontab file:

crontab -e

Add the following line to schedule the Certbot renewal command:

0 12 * * * /usr/bin/certbot renew --quiet

In this configuration:

  • The command runs at noon (12:00) every day.
  • Certbot will check the certificate’s expiration status and renew it if necessary.
  • The --quiet flag ensures that Certbot runs silently without generating output.

Step 7. Downloading WordPress

In this guide, we’ll use WordPress version 6.5.3, which can be downloaded from the official website:

wget https://wordpress.org/wordpress-6.5.3.tar.gz

Once downloaded, unpack the WordPress archive:

tar -xvf wordpress-*.tar.gz

After unpacking, you can delete the archive file:

rm wordpress-*.tar.gz

This will create a wordpress folder containing the WordPress files.

Most core files are organized in the wp-content, wp-includes, and wp-admin directories. The main entry point for WordPress is index.php.

Moving WordPress Files to the Web Server Directory

You need to copy all files from the wordpress folder to the web server’s root directory (/var/www/html/) so that Nginx can serve the PHP-generated content based on user HTTP requests.

Clear the existing web server directory (as it currently contains only the default Nginx welcome page, which we no longer need):

rm /var/www/html/*

Copy WordPress files to the web server directory:

cp -R wordpress/* /var/www/html/

The -R flag enables recursive copying of files and folders.

Set ownership and permissions. Ensure that Nginx can access and modify these files by setting the www-data user and group ownership, as well as appropriate permissions, for the WordPress directory:

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

This allows Nginx to read, write, and modify WordPress files as needed, avoiding permission errors during the WordPress installation process.

Step 8. Configuring WordPress

WordPress configuration is managed through an intuitive web-based admin panel. No programming knowledge is necessary, though familiarity with languages like JavaScript, PHP, HTML, and CSS can be helpful for creating or customizing themes and plugins.

Accessing the Admin Panel

Open a web browser and go to the website using the domain specified in the Nginx configuration, such as:

https://mydomain.com

If all components were correctly set up, you should be redirected to WordPress’s initial configuration page:

https://mydomain.com/wp-admin/setup-config.php
  1. Select Language: Choose your preferred language and click Continue.

  2. Database Configuration: WordPress will prompt you to enter database details. Click Let’s go! and provide the following information:

    • Database Name: wordpress_database (from the previous setup)

    • Database Username: wordpress_user

    • Database Password: wordpress_password

    • Database Host: localhost

    • Table Prefix: wp_ (or leave as default)

C630b1b0 F6be 441f A1c0 7e213bd5f7ea

  1. Click Submit. If the credentials are correct, WordPress will confirm access to the database.

  2. Run Installation: Click Run the installation. WordPress will then guide you to enter site and admin details:

    • Site Title

    • Admin Username

    • Admin Password

    • Admin Email

    • Option to discourage search engine indexing (recommended for development/testing sites)

1f358d6d C03a 48ef A921 8a18a465714c

  1. Install WordPress: Click Install WordPress. After installation, you’ll be prompted to log in with the admin username and password you created.

Accessing the Dashboard

Once logged in, you'll see the WordPress Dashboard, which contains customizable widgets. The main menu on the left allows access to core WordPress functions, including:

  • Posts and Pages for content creation

  • Comments for moderating discussions

  • Media for managing images and files

  • Themes and Plugins for design and functionality

  • Users for managing site members and roles

Your WordPress site is now fully configured, and you can begin customizing and adding content as needed.

Image2

Conclusion

This guide showed how to install WordPress along with all its dependencies and how to connect a domain and add a SSL certificate from Let’s Encrypt to an already functioning website, enabling secure HTTPS connections with the remote server.

The key dependencies required for WordPress to function include:

  • PHP: The scripting language WordPress is written in.

  • MySQL: The database system used by WordPress to store content and user data.

  • Nginx (or Apache in other implementations): The web server that processes user requests initially.

For more detailed information on managing site content through the WordPress admin panel, as well as creating custom themes and plugins, refer to the official WordPress documentation.

Wordpress Ubuntu
13.11.2024
Reading time: 13 min

Similar

Wordpress

How to Install WordPress Using Docker

WordPress is an open-source product written in PHP and one of the many popular website content management systems (CMS). The CMS stores data in a relational database, MySQL. Hostman offers Wordpress vps hosting with quick load times, robust security, and simplified management.  The purpose of WordPress does not end with managing blogs, as is commonly believed. Thanks to a system of themes and plugins, the CMS's basic functionality can be expanded to the level of more complex projects, making WordPress the most popular CMS in the world. WordPress is based on a technological stack of server software, the most common of which is LAMP: Linux, Apache, MySQL, and PHP. Manually installing these components may not be very practical if you regularly deploy the application to server machines. A better choice would be running WordPress in a Docker container. This way, you can automate the installation and running of CMS, turning WordPress into a multi-container application. If you are developing a product using Docker, the application will definitely work anywhere after deployment. In this tutorial, we will look at deploying the WordPress with Docker and Docker Compose. However, the tech stack will not be entirely LAMP; the project in this guide is based on Nginx, PHP, MySQL, and, of course, WordPress. Please note that this guide is intended for UNIX-like operating systems, particularly Debian and Ubuntu. Install Docker components To set up Wordpress in Docker, we obviously need to install Docker and its components first. Step 1. First of all, update the list of existing packages on your server machine: sudo apt update Step 2. To ensure the installation process runs correctly, we will need a few key packages to ensure the HTTPS connection works: sudo apt install apt-transport-https ca-certificates curl software-properties-common Removing old versions of Docker Step 3. To prevent possible problems, it is worth checking if one of the older versions of Docker is installed on your system (docker-engine and docker.io, which are considered obsolete, unlike docker-ce and docker-ee). If they are present, remove them: sudo apt autoremove docker docker-engine docker.io docker-ce Installing the Docker engine Step 4. Now you can take the GPG key from the official Docker repository and add it to the system: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - And then include the repository itself in the list of packages: sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" Step 5. Let's once again update the list of packages: sudo apt update Now you can download Docker itself: sudo apt install docker-ce docker-ce-cli docker-compose-plugin To check if Docker is installed successfully, use this simple command that will display the version in the terminal: docker --version Installing Docker Compose Docker Compose is a tool for automating container management. It uses a special instruction file in YAML format. It's somewhat similar to Node's package.json, but it goes a little deeper: you define services, their dependencies, storage spaces, and environment variables. Docker Compose, following the descriptions, performs automatic deployment. In general, this ensures the portability of developed projects. Please note that a separate installation of Docker Compose is not required if you are using the latest versions of Docker. Instead of a separate Compose V1, the Docker CLI package ships Compose V2, written in Go. In this case, docker compose is used instead of the usual docker-compose command. If, for some reason, you need the old version of Compose V1, then the instructions below are for you. Step 6. From the official GitHub repository, download the executable file with the latest version of docker-compose: sudo curl -L "https://github.com/docker/compose/releases/download/2.19.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/ bin/docker-compose Step 7. Next, set the permissions to use this file: sudo chmod +x /usr/local/bin/docker-compose The installation can be considered virtually completed. Subsequently, the downloaded file will process the definition files and start or stop containers per our commands. Step 8: For added reliability, we recommend trying to run the file to get version information: docker-compose --version Deploy your apps with a Dockerfile easily Configure Nginx Before we begin describing the container structure in the Docker Compose file, we must prepare all the required directories and configuration files for the components used in the application. One of the main configuration files, which contains the settings and routing of the Nginx web server, is of particular importance. Creating directories Step 1. Let's create a separate directory for our application in the home directory and immediately go to it:   mkdir -p ~/wordpresscd ~/wordpress Here we will create additional subdirectories within which Nginx, MySQL and WordPress data will be located.    mkdir -p nginx/ mkdir -p logs/ mkdir -p logs/nginx mkdir -p data/ mkdir -p data/html mkdir -p data/mysql We have a directory designed specifically for storing Nginx, as well as a separate folder where server log files will be saved. The directory called data will contain the main CMS and database files. Creating an Nginx configuration file Step 2. Now, we will create a configuration file for Nginx in the previously created directory dedicated to it: nano ~/wordpress/nginx/nginx.conf Step 3. We will add a minimal description to the file for the purposes of this guide. Later on, you can expand the file's content as the complexity of your projects grows: server { listen 80 default_server; server_name_; root /var/www/html; index index.php; access_log /var/log/nginx/site-access.log; error_log /var/log/nginx/site-error.log; location/{ try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass wordpress:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; } } The listening port is standard 80. The default_server directive and the _ setting in server_name instruct Nginx to process any requests (with any host value in the HTTP headers) on port 80. The root directory with the files is located at /var/www/html. Index.php, a kind of entry point in WordPress, is among them. The next lines are the paths to the log files (the request log and the error log). The standard route directs the user to the entry point index.php, also passing all the arguments (query string) from the address. Accordingly, all requests for PHP files are sent directly to the PHP container via the FastCGI protocol. Describe the required images and containers Creating the docker-compose.yml file The normal functioning of WordPress involves the joint work of 3 main components from the previously described tech stack: the Nginx server, WordPress itself, and the MySQL database. At the same time, MySQL is a fundamental component of the application because all the data that WordPress handles is located there. Therefore, disk space will be required both for MySQL and for the theme files and plugins that are integral to the CMS. It is precisely because WordPress is a multi-component application that we need docker-compose to deploy its structure in a portable manner. Step 1. We will place a description of all dependencies in a special file docker-compose.yml: sudo nano docker-compose.yml Step 2. Fill the file with the following content: version: '3.3' services: nginx: image:nginx:latest volumes: - ./nginx:/etc/nginx/conf.d - ./data/html:/var/www/html ports: - 8080:80 links: - wordpress wordpress: depends_on: -db image: wordpress:latest volumes: - ./data/html:/var/www/html ports: - "80:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: *username from MySQL* WORDPRESS_DB_PASSWORD: *MySQL password* WORDPRESS_DB_NAME: wordpress db: image: mysql:5.7 volumes: - ./data/mysql:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: *MySQL root password* MYSQL_DATABASE: wordpress MYSQL_USER: *username from MySQL* MYSQL_PASSWORD: *MySQL password* The intricacies of writing YAML files are beyond the scope of this article; this is a separate extensive topic that you can read about in the official documentation. Let's just go through the main points. Specifically, here, we first define Nginx, WordPress, and MySQL as the application's main services (containers), not forgetting to specify their dependencies. For example, WordPress won't work without a database. For WordPress and Nginx, we use the latest versions of containers. By default, we link them by reserving port 80 for web traffic. When you enter a URL into a browser, Nginx and WordPress Docker containers work together to process requests sequentially and return generated web pages to the user as a response. The database service is a MySQL version 5.7 image. Accordingly, we do not forget to specify environment variables with the necessary credentials for containers to communicate with each other. Inside each service, the volumes parameter declares disk space, i.e. directories in which working Nginx, WordPress and MySQL files are stored. When using the CMS in a real project, it is important to make backup copies of these directories regularly. Optional component: phpMyAdmin It's worth mentioning that you can optionally include the phpMyAdmin image in the yml file: ... phpmyadmin: image: phpmyadmin/phpmyadmin restart: always links: - db:mysql ports: - 8081:80 environment: MYSQL_ROOT_PASSWORD: *MySQL password* ... PhpMyAdmin is a web interface for MySQL. It allows you to manage the database not through the terminal and SQL queries, but visually in the browser window. In our case, phpMyAdmin is not a required component, but in more complex projects such functionality may be useful. Loading images and running containers Step 3. Now you can run this file, and Docker Compose will create working containers from all the described images and configure them accordingly: docker compose up -d Running this command for the first time will take significant time because the files will be downloaded from Docker Hub. Step 4. Once the process is complete, you should make sure that the loaded containers are actually running:   docker compose ps If everything is correct, a list of running containers will appear in the terminal, the names of which will correspond to the descriptions in the docker-compose.yml file. Restarting containers Each container can be restarted if necessary. For example, if you update the Nginx configuration, you will need to restart the web server to apply the changes. docker compose restart nginx However, there is one more stage ahead. Immediately after loading and launching the containers, you will be able to open the WordPress web interface. This is where you will perform all further configuration of the CMS. Cloud Servers for your needs from $4/mo Complete the WordPress installation via the web interface Now that we launched Docker containers for WordPress using Docker Compose, you can proceed to finalizing the installation. Step 1. In the address bar of your web browser, you need to enter your server address, after which the WordPress installation screen will appear. First, select the language in which the CMS will work.  Step 2. Next, click Continue. A page with basic WordPress settings will open. You'll need to specify the site name, username, user password, and email address. There is also a special clause at the bottom that prohibits search engines from indexing your site. If your site is not a private portal, you should leave indexing so that users can access your site from search results. By the way, it is better not to use such common names as admin or root as a username, as they will make it easier for attackers to hack. In some cases, a screen may appear asking for information about the database previously created in phpMyAdmin. However, in our case, we won't see it because we already declared all the necessary environment variables in the docker-compose.yml file. Step 3. When all fields are filled out correctly, the Install WordPress button will take you to the login page. After logging in, you will find yourself in the admin panel. It has many different sections, but it cannot be called too complex. Further use of WordPress consists of operating many settings inside the admin panel. An exception is the case when PHP variables are manually entered into the page markup, thereby turning the raw HTML layout into a full-fledged WordPress theme that anyone can install. If you have installed phyMyAdmin, then its web interface will be available at the address of your server but on port 8081. Conclusion While there are many ways to deploy a local WordPress app development environment, Docker stands out in stark contrast with its component sharing, cross-platform, and portability features. With Docker, you can set up multiple environments side by side using different components. Each of them can be included or excluded from the stack used depending on needs and tasks. In this tutorial, we used Docker containers to deploy all the required components of a WordPress application and followed a number of key steps: Downloaded Docker and Docker Compose for managing containers. Prepared an Nginx configuration file to transmit the requests to the WordPress container via the FastCGI protocol. Downloaded phpMyAdmin for easy database management through the web interface. Created a file describing the services, after which docker-compose automatically downloaded the necessary images and launched the required containers. In this case, Nginx was used as a web server, and we used a MySQL database to store data. Completed the WordPress installation through the admin panel in the browser. This basic configuration can be expanded or modified in a variety of ways. The official WordPress website has complete documentation describing the nuances of working with the admin panel of this CMS. The same goes for Nginx: you can find various guides on configuring and using this web server on the official website.
27 March 2024 · 12 min to read
Wordpress

How to Host and Transfer WordPress on Hostman Server

Creating a website opens up a world of possibilities; however, finding the perfect home for your online presence is vital as it is the foundation of your website. In today's digital world, choosing the right hosting provider is similar to choosing the best location for your storefront: it has a direct impact on the performance, reliability, and, eventually, success of your website. Hostman offers affordable Wordpress hosting with quick load times, robust security, and simplified management. We provide the infrastructure and resources required to store, run and deliver your website’s content to users throughout the world.  Creating a New Server Instance in Hostman Login to Hostman or sign up to create an account with Hostman.  Login to control panel with the created credentials. Inside the control panel dashboard, click Create, then go to Cloud Server. Start creating a new server. Select the specifications for the server; Operating system, Region, Plan, Network, and there are additional features to choose from according to the user’s preference.  Once done, click Order with the amount specified depending on the selections made.  The newly built server will look like the image below. Install and Configure WordPress on the New Server Take note of the server details below which is found on the lower right side of the server page.   IPv4 SSH connection Root password Login to server via SSH using your terminal or the PuTTy App.   ssh root@server-ip Proceed with the installation of WordPress. 3.1. Update the package list and the system: sudo apt update && apt upgrade 3.2. Install the Apache web server. sudo apt install apache2 3.3. Install MySQL and secure the installation.  sudo apt install mysql-server sudo mysql_secure_installation Remove anonymous users: Remove test database and access to it: Then reload: Select password strength, it is recommended to choose Strong. Database installation completed.  3.4. Login to database and create a database for WordPress. CREATE DATABASE WordPress; 3.5. Create user for the WordPress Database named wordpress. CREATE USER ‘wordpress’@’%’ IDENTIFIED with mysql_native_password BY ‘Welcome@123’; Note: In this syntax, Welcome@123 is the password that will be created. Make sure to change it with the user’s preferred password. 3.6. Provide all required permissions for WordPress user. To take effect, privileges should be reloaded. GRANT ALL ON wordpress.* TO 'wordpress'@'%'; FLUSH PRIVILEGES; 3.7. Logout from Database. EXIT; 3.8. Install PHP and necessary extensions: sudo apt install php php-mysql libapache2-mod-php 3.9. Download the latest WordPress package from the official website and extract it: wget https://wordpress.org/latest.tar.gz; tar xzvf latest.tar.gz; sudo cp -r wordpress/* /var/www/html/ 3.10. Configure WordPress to connect to the database: sudo nano /var/www/html/wp-config.php Note: Make sure that details are matched with the details provided during the database installation. 3.11. Adjust the file and directory permissions sudo chown -R www-data:www-data /var/www/html/ 3.12 Restart the Apache web server to apply the changes. sudo systemctl restart apache2 3.13. Complete Installation. Open a web browser and navigate to your server’s domain name or IP address, and complete the WordPress installation through the web interface. In our case, the address is https://66.248.207.252/wp-admin. 3.14. Create WordPress admin username and password. WordPress installation is completed.   Transferring Existing WordPress Site to Hostman Server Back-up the website files on your existing website. To back up the files, download WordPress files to the local using WP plugins or FTP / WinSCP.  Using WINSCP: Using Plugins: After backup, proceed with migration. There are 2 ways to migrate; manual and by using WordPress plugins.  Manual migration: On the existing website, go to Tools > Export > Choose what to export > All content. Now, import WordPress to Hostman. Login to your new (Hostman) WordPress dashboard. Go to Tools > Import > Run Importer. Choose the WordPress files that was exported from the old website. Migration completed. Migration using plugin: Go to WPvivid, click Database + Files (Wordpress Files), then click Backup Now. Check progress, wait for the back-up to complete.  Download the backup files locally. Import Your WordPress file to Hostman. Login to new WordPress admin site. Upload the WordPress file from back-up. Files can be seen in the download folder of the local machine. Click Restore. Restoring in progress. It will take time depending on the size of the WordPress file. Wait for the 100% completion.  Update the Domain Name Servers (DNS) in Hostman. Add your domain name to the Hostman panel. In this example, the domain name is mywebsite.com These are the DNS details from Hostman. The website is now hosted in Hostman: Conclusion To summarize, migrating an existing WordPress site to a new host is a critical step in ensuring the continued success and growth of your online presence. By following a systematic approach, including backing up your website, selecting a reliable hosting provider, seamlessly transferring files and databases, and thoroughly testing the migrated site, you can mitigate the risks associated with the process and ensure a smooth transition.
19 March 2024 · 5 min to read

Do you have questions,
comments, or concerns?

Our professionals are available to assist you at any moment,
whether you need help or are just unsure of where to start.
Email us
Hostman's Support