{"id":775,"date":"2022-12-19T14:37:58","date_gmt":"2022-12-19T21:37:58","guid":{"rendered":"https:\/\/rewaant.com\/blog\/?p=775"},"modified":"2023-01-01T12:37:39","modified_gmt":"2023-01-01T19:37:39","slug":"hosting-wordpress-on-ubuntu-or-debian","status":"publish","type":"post","link":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/","title":{"rendered":"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023"},"content":{"rendered":"\n<h3 class=\"table-of-contents wp-block-heading\">Table of Contents<\/h3>\n\n\n\n<ol class=\"table-of-contents-list wp-block-list\">\n<li><a href=\"#overview\">Overview<\/a><\/li>\n\n\n\n<li><a href=\"#ubuntu-server\">Setting up your Ubuntu server<\/a><\/li>\n\n\n\n<li class=\"table-of-contents-list\"><a href=\"#lamp-stack\">Setting up the LAMP stack<\/a><\/li>\n\n\n\n<li><a href=\"#ssl-certs\">Setting up Let\u2019s Encrypt SSL Certificates<\/a><\/li>\n\n\n\n<li><a href=\"#installing-wordpress\">Installing WordPress<\/a><\/li>\n\n\n\n<li><a href=\"#configuring-phpmyadmin\">Configuring PHPMyAdmin (optional)<\/a><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"overview\">Overview<\/h2>\n\n\n\n<p>If you\u2019re looking to build a website or a blog it\u2019s highly likely you\u2019ve decided to use WordPress as your platform of choice which makes up around 43% of all websites on the web. WordPress, as you might know, comes in two flavors:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"http:\/\/WordPress.com\">WordPress.com<\/a> \u2192 CMS as a service provided by none other than <a href=\"https:\/\/automattic.com\/\">Automattic<\/a> a company that officially backs the platform and is headed by <a href=\"https:\/\/www.google.com\/search?q=Matt+Mullenweg&amp;stick=H4sIAAAAAAAAAOPgE-LUz9U3sExPz7NUAjNNU9IKirQUs5Ot9POL0hPzMqsSSzLz81A4Vsmp-YtY-XwTS0oUfEtzclLzylPTd7Ay7mJn4mAAAKqVd29UAAAA&amp;sa=X&amp;ved=2ahUKEwjKhYupsJr7AhWoIzQIHSD9C2UQmxMoAHoECC8QAg\">Matt Mullenweg<\/a> one of the original authors\/founders of WordPress. Now, this is an excellent offering if you plan to run a blog or a small business website that doesn\u2019t need extensive customization or the need to control plugins. It\u2019s also agreed in the community that once you get past a certain point in your journey as a site owner\/administrator, your options for control and customization start becoming limited.<\/li>\n\n\n\n<li><a style=\"pointer-events: none;\" href=\"http:\/\/WordPress.org\">WordPress.org<\/a> \u2192 An open-source offering of the same CMS by one of the largest communities with 100% control over its setup and customization and all for free. Keep in mind this does expose you to a bit of complexity that you might not want to deal with but when someone says WordPress, it\u2019s highly likely they\u2019re referring to this flavor.<\/li>\n<\/ol>\n\n\n\n<p>As you might know, self-hosting WordPress is a job in itself and there are many options out there like shared hosting (GoDaddy, NameCheap, Bluehost), quick installs, managed hosting offerings (WPEngine, Kinsta) and some of these companies also offer cloud hosting services that might be useful if you\u2019re on their shared plan and looking to upgrade but still prefer services from a hosting company.<\/p>\n\n\n\n<p>But, there\u2019s another way that is a little complicated but in our opinion one of the most controllable and customizable options for running your own self-hosted WordPress install. Cloud infrastructure services like AWS, Google Cloud Platform, DigitalOcean, Linode, and more allow you to run a virtual machine (VPS) which essentially acts as your own server with a public-facing IP address attached to it that can serve your WordPress installation. It exposes you to some complexity but is a great option for site and blog owners who are tech\/cloud savvy but want to run one or multiple sites or applications on their very own virtual server for as little as $5\/mo.<\/p>\n\n\n\n<p>What\u2019s more, you can even start hosting your site for free (up to 12 months) with offerings like the free tier from AWS and Google Cloud. AWS even offers the first 3 months free on its lesser-priced LightSail instances (one of its less complicated offerings) with similar options from other providers in form of credits. Oracle cloud even has a free forever plan.<\/p>\n\n\n\n<p>In this complete guide, we\u2019re going to explain in detail how to set up the LAMP stack on Ubuntu 22.04 and configure everything from the domain, and SSL certificates to setting up the WordPress installation and securing the server.<\/p>\n\n\n\n<p>We\u2019ll get it up and running on one of our subdomains: <a style=\"\" href=\"http:\/\/testwp.rewaant.com\">testwp.rewaant.com<\/a> and also go through some add-ons which make using the server for hosting additional PHP apps and WordPress websites easier in the long run. One of those applications is PHPMyAdmin which is highly useful but optional.<\/p>\n\n\n\n<p>Let\u2019s shoot!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ubuntu-server\">Setting up your Ubuntu server<\/h2>\n\n\n\n<p>We now need SSH access to the server running Ubuntu, we\u2019re using an AWS EC2 instance in this guide but for the most part, this guide should be good for almost any other service and the steps remain similar once you\u2019re authenticated to an Ubuntu 22.04 server using SSH.<\/p>\n\n\n\n<p>If you need help connecting to the server with SSH, consider reading our <a href=\"https:\/\/rewaant.com\/blog\/setup-ssh-keys-on-your-linux-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">Connecting with SSH<\/a> guide.<\/p>\n\n\n\n<p>Once you\u2019re authenticated, you\u2019ll see a screen similar to this one:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/ssh-connection-1024x545.png\" alt=\"\" class=\"wp-image-778\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/ssh-connection-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/ssh-connection-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p>Before working through the initial steps, I\u2019ll recommend updating the server packages and reboot with the following commands:<\/p>\n\n\n\n<p class=\"terminal\"><code>sudo apt update<\/code><\/p>\n\n\n\n<p class=\"terminal\"><code>sudo apt upgrade<\/code><\/p>\n\n\n\n<p class=\"terminal\"><code>sudo reboot<\/code><\/p>\n\n\n\n<p>Reconnect the server with the SSH command from the terminal. Once you\u2019re connected, our first order of business is to create an administrative user other than the root or default user, the reasons for which are well explained all over the internet. Long story short \u2192 root is a superuser and therefore has superuser privileges, executing commands unknowingly can completely break a system and may lead to a loss of hundreds of hours of effort in some cases in addition to financial loss. Hence, we\u2019ll be setting up a user with limited privileges and then add it to sudoers so occasionally when we\u2019re running commands that need attention, the sysadmin will first need to authenticate.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Setting up a new user<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>sudo adduser [username] <\/code>\u2192 Creates a new user. This will trigger the following screen:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/new-user-setup-1024x545.png\" alt=\"\" class=\"wp-image-779\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/new-user-setup-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/new-user-setup-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Fill in all the information as required.<\/li>\n\n\n\n<li>Once it\u2019s created, we\u2019ll add the user to the sudo group with the command <code>sudo usermod -aG sudo [username] <\/code>This will make sure the user can sudo commands which require superuser privileges.<\/li>\n\n\n\n<li>We now need to create a keypair so that we can SSH into the server with key-based authentication. We\u2019ve written a complete guide on securing SSH access to the server with key-based authentication, please read <a href=\"https:\/\/rewaant.com\/blog\/hardening-ssh-on-your-linux-server\/\">here<\/a> and follow the rest of the tutorial afterward. For the sake of brevity, we\u2019ll continue to set up the rest of the server with the default user.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Securing with Firewall<\/h3>\n\n\n\n<p>Setting up a firewall can help us filter internal traffic sources which add an additional layer of security. Many cloud services offer similar services which are built into the platform like AWS security groups but we\u2019ll be covering native firewall configuration with a program called UFW.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Check if the service is already active with <code>sudo ufw status<\/code><\/li>\n\n\n\n<li>Make sure that the OpenSSH service is allowed so you don\u2019t get locked out of the system. Use <code>sudo ufw allow OpenSSH<\/code> \u2192 This allows all connections over port 22 for both IPv4 and IPv6.<\/li>\n\n\n\n<li>As we\u2019ll be using this as a web server, we\u2019ll also need to allow port 80 for HTTP and port 443 for HTTPS. Use <code>sudo ufw allow 80<\/code> and <code>sudo ufw allow 443<\/code>. It\u2019s already enabled on our server so it\u2019s skipping adding existing rules.<\/li>\n\n\n\n<li>Enable firewall with <code>sudo ufw enable<\/code><\/li>\n\n\n\n<li>Check the status again with <code>sudo ufw status<\/code> You should now see a similar screen:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/firewall-status-1024x545.png\" alt=\"\" class=\"wp-image-780\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/firewall-status-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/firewall-status-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p>This should set up the firewall for good. Other than SSH, HTTP, and HTTPS, all connections to the server are rejected.<\/p>\n\n\n\n<p>Our initial server setup is complete, we\u2019ll now set up the LAMP stack which stands for Linux, Apache, MySQL, and PHP that enables us to run WordPress off an Ubuntu server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"lamp-stack\">Setting up the LAMP stack<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Installing the Apache web server<\/h3>\n\n\n\n<p>On the terminal window, type in the following commands:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>sudo apt install apache2<\/code> \u2192 Installs the Apache web server.<\/li>\n\n\n\n<li><code>sudo ufw status<\/code> \u2192 Make sure ports 80 and 443 are allowed.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-apache-ufw-status-1024x545.png\" alt=\"\" class=\"wp-image-782\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-apache-ufw-status-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-apache-ufw-status-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Access the server homepage to verify that apache\u2019s up and running. Type in the public IP address of your server in the following format: <code>http:\/\/[your_server_ip_address]<\/code> It should look something like this:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/apache-homepage-1024x545.png\" alt=\"\" class=\"wp-image-783\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/apache-homepage-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/apache-homepage-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Installing the MySQL database server<\/h3>\n\n\n\n<p>Once the web server is installed and we can access the Apache home page, we\u2019ll install MySQL as our choice of database server. Execute the following commands:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>sudo apt install mysql-server<\/code> \u2192 This will install MySQL along with all of its dependencies. Type in <code>Y<\/code> when prompted to continue.<\/li>\n\n\n\n<li><code>sudo mysql_secure_installation<\/code> \u2192 This will secure the database server as we\u2019re using it in a production environment. Make sure you keep the <code>VALIDATE PASSWORD<\/code> plugin disabled. Choose the root password of your choice and make sure to remember or write it down. If you get a failed error, we\u2019ll set the root password using the <code>ALTER USER<\/code> command: use <code>sudo mysql<\/code> then, once you\u2019re in at the repl interface, use <code>ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password by *'your_new_password'*;<\/code> . Re-run <code>sudo mysql_secure_installation<\/code> again.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-mysql-server-1024x545.png\" alt=\"\" class=\"wp-image-784\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-mysql-server-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-mysql-server-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Try entering the mysql server with <code>mysql -u root -p<\/code> command. It should now prompt for the root password and let you in.<\/li>\n<\/ol>\n\n\n\n<p>We\u2019ve finished the initial configuration of MySQL on our server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing and configuring PHP and its dependencies<\/h3>\n\n\n\n<p>Type in the following commands:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><code>sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip<\/code> \u2192 Installs PHP module for apache, mysql, and other extensions for WordPress.<\/li>\n\n\n\n<li>Test PHP installation with <code>php -v<\/code>. If you get a similar output, you\u2019re good to go.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-php-1024x545.png\" alt=\"\" class=\"wp-image-785\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-php-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/installing-php-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Creating an Apache virtual host<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>First of all, we\u2019ll create a directory where our website will be served from. Navigate to <code>\/var\/www<\/code> and execute <code>sudo mkdir \/var\/www\/domain_name<\/code>. In our case, it\u2019ll be <code>sudo mkdir \/var\/www\/testwp.rewaant.com<\/code>.<\/li>\n\n\n\n<li>Next, we\u2019ll assign the ownership of the directory to the apache user which is <code>www-data<\/code>. Type in <code>sudo chown -R www-data:www-data \/var\/www\/your_domain<\/code> this grants apache\u2019s user, the directory ownership. Make sure you also add your admin user to the <code>www-data<\/code> group so you can write files in the directory with FTP or if a need arises in the future.<\/li>\n\n\n\n<li>Navigate to <code>\/etc\/apache2\/sites-available\/<\/code> and type in <code>sudo vim your_domain.conf<\/code>. In our case, it\u2019ll be <code>sudo vim testwp.rewaant.com.conf<\/code>. You can also use the nano text editor if you prefer.<\/li>\n\n\n\n<li>Type in the following to configure the server:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;VirtualHost *:80&gt;\n    ServerName testwp.rewaant.com\n    ServerAlias www.testwp.rewaant.com\n    ServerAdmin rewaant@rewaant.com\n    DocumentRoot \/var\/www\/testwp.rewaant.com\n    ErrorLog ${APACHE_LOG_DIR}\/error.log\n    CustomLog ${APACHE_LOG_DIR}\/access.log combined\n\t\t&lt;Directory \/var\/www\/testwp.rewaant.com\/&gt;\n        AllowOverride All\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Make sure you replace the domain configuration with your own and save the file by pressing <code>Esc<\/code> typing <code>:wq!<\/code> and exit.<\/li>\n\n\n\n<li>Type in <code>sudo a2ensite your_domain<\/code> and <code>sudo a2dissite 000-default<\/code> \u2192 This enables vhost for your site and disables default access to the server.<\/li>\n\n\n\n<li>Test apache configuration with <code>sudo apache2ctl configtest<\/code> make sure it returns <code>Syntax OK<\/code>.<\/li>\n\n\n\n<li>Reload the configuration with <code>sudo systemctl reload apache2<\/code>.<\/li>\n\n\n\n<li>Remember, at this point, we haven\u2019t pointed the domain to our server\u2019s IP. We\u2019ll do that next.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Configuring the domain<\/h3>\n\n\n\n<p>We simply need to add two records to our DNS manager (in our case it\u2019s Cloudflare.) An A record should point to the IP address and a CNAME record for www should point to the apex domain. This should be configured just like in the screenshots:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"196\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/domain-configuration-a-record.png\" alt=\"\" class=\"wp-image-787\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/domain-configuration-a-record.png 1024w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/domain-configuration-a-record-980x188.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/domain-configuration-a-record-480x92.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1025\" height=\"195\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/domain-configuration-cname-record.png\" alt=\"\" class=\"wp-image-788\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/domain-configuration-cname-record.png 1025w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/domain-configuration-cname-record-980x186.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/domain-configuration-cname-record-480x91.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1025px, 100vw\" \/><\/figure>\n\n\n\n<p>We\u2019ll now go back to the terminal and create a file <code>index.html<\/code> with the following content:<\/p>\n\n\n\n<p><code>&lt;h1&gt;Our Site Works!&lt;\/h1&gt;<\/code> \u2192 This isn\u2019t the cleanest HTML site but gets the job done for us \ud83d\ude09<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Navigate: <code>cd \/var\/www\/site_directory<\/code><\/li>\n\n\n\n<li>Create a file with <code>sudo vim index.html<\/code> and paste the above HTML code. Save and exit with <code>Esc<\/code> + <code>:wq!<\/code> and test the link with the URL. In our case, <code>testwp.rewaant.com<\/code><\/li>\n\n\n\n<li>You should see something similar and this means that the site\u2019s configured with our domain name.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/testing-domain-1024x545.png\" alt=\"\" class=\"wp-image-789\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/testing-domain-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/testing-domain-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Configuring the DirecotryIndex on Apache<\/h3>\n\n\n\n<p>We need the server to make sure that <code>*.php<\/code> take precedence over other extensions like <code>*.html<\/code><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Type in <code>sudo vim \/etc\/apache2\/mods-enabled\/dir.conf<\/code><\/li>\n\n\n\n<li>Add index.php before index.html as shown below<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"946\" height=\"128\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/apache-DirectoryIndex.png\" alt=\"\" class=\"wp-image-790\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/apache-DirectoryIndex.png 946w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/apache-DirectoryIndex-480x65.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 946px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Reload apache configuration with <code>sudo systemctl reload apache2<\/code><\/li>\n\n\n\n<li>Create a new file <code>sudo vim \/var\/www\/site_directory\/info.php<\/code> and add the following content: <code>&lt;?php phpinfo();<\/code><\/li>\n\n\n\n<li>Test the link with the site URL and you should something similar:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpinfo-1024x545.png\" alt=\"\" class=\"wp-image-792\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpinfo-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpinfo-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\">\n<li>Make sure you remove the index.html and index.php files before proceeding as they are a security risk to be exposed to the public.<\/li>\n<\/ol>\n\n\n\n<p>We now have the LAMP stack up and running properly. Next up, we\u2019ll secure the domain on the server with Let\u2019s Encrypt certificates.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ssl-certs\">Setting up Let\u2019s Encrypt SSL Certificates<\/h2>\n\n\n\n<p>In order to setup free SSL certificates with Let\u2019s Encrypt, we need a command line program called certbot setup on our server.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Execute <code>sudo apt install certbot python3-certbot-apache<\/code> \u2192 This will install certbot and its apache supported plugin that\u2019ll automate the whole process.<\/li>\n\n\n\n<li>Type in <code>sudo certbot -d domain_name -d www.domain_name<\/code>. In our case, this becomes <code>sudo certbot -d testwp.rewaant.com -d www.testwp.rewaant.com<\/code><\/li>\n\n\n\n<li>It\u2019ll prompt you for an admin email and acceptance of TOS. After that, it\u2019ll validate and authenticate the domains.<\/li>\n\n\n\n<li>If it asks you to either set a redirect, select <code>2<\/code> so all requests are routed to HTTPS.<\/li>\n\n\n\n<li>Verify that certificate\u2019s auto-renewal service is active. Use <code>sudo systemctl status certbot.timer<\/code> and make sure it outputs as <code>\u201cactive (waiting)\u201d<\/code><\/li>\n\n\n\n<li>Also, test the renewal process with <code>sudo certbot renew --dry-run<\/code>. This will simulate a renewal and let you know if it\u2019s working properly.<\/li>\n<\/ol>\n\n\n\n<p>Your domain should now be secured and served automatically through HTTPS. Next up, we\u2019ll setup WordPress itself.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-wordpress\">Installing WordPress<\/h2>\n\n\n\n<p>Finally, let\u2019s set up WordPress:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>We need to create a database and a user for the WordPress installation. Enter mysql with <code>mysql -u root -p<\/code> provide the root password you selected earlier in the tutorial.<\/li>\n\n\n\n<li>Create a new database with <code>CREATE DATABASE wp_test DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;<\/code> Feel free to type in your preferred database name in place of wp_test. Make sure to replace in the following lines.<\/li>\n\n\n\n<li>Create a new user specific to this WordPress installation with <code>CREATE USER 'testuser'@'%' IDENTIFIED WITH mysql_native_password BY 'password';<\/code> Replace with appropriate credentials.<\/li>\n\n\n\n<li>Now we need to grant all privileges on the WordPress database to this newly created user. Use <code>GRANT ALL ON wp_test.* TO 'testuser'@'%';<\/code><\/li>\n\n\n\n<li>Let\u2019s make the credentials work by flushing privileges, type in <code>FLUSH PRIVILEGES;<\/code> . Type <code>EXIT;<\/code> to get out of mysql repl. We now have the database part all set.<\/li>\n\n\n\n<li>Download WordPress to the temporary directory. Use <code>cd \/tmp<\/code>. Download with the command: <code>curl -O <a href=\"https:\/\/wordpress.org\/latest.tar.gz\"><\/a>https:\/\/wordpress.org\/latest.tar.gz<\/code>. Extract into its directory structure with <code>tar xzvf latest.tar.gz<\/code><\/li>\n\n\n\n<li>Add a .htaccess file with <code>touch \/tmp\/wordpress\/.htaccess<\/code> and copy the configuration file for production with <code>cp \/tmp\/wordpress\/wp-config-sample.php \/tmp\/wordpress\/wp-config.php<\/code><\/li>\n\n\n\n<li>Lastly, create a <code>upgrade<\/code> directory so it can process updates automatically. Type in <code>mkdir \/tmp\/wordpress\/wp-content\/upgrade<\/code><\/li>\n\n\n\n<li>Now copy the WordPress directory files to the site\u2019s root directory. In our case, this command becomes: <code>sudo cp -a \/tmp\/wordpress\/. \/var\/www\/testwp.rewaant.com<\/code><\/li>\n\n\n\n<li>Now, we\u2019ll adjust the ownership and set the adequate file and directory permission values for WordPress. Use <code>sudo chown -R www-data:www-data \/var\/www\/site_dir<\/code> in our case it\u2019s <code>sudo chown -R www-data:www-data \/var\/www\/testwp.rewaant.com<\/code>. For setting directory permissions, use <code>sudo find \/var\/www\/site_dir\/ -type d -exec chmod 750 {} \\;<\/code> and for file permissions, use <code>sudo find \/var\/www\/site_dir\/ -type f -exec chmod 640 {} \\;<\/code><\/li>\n\n\n\n<li>Let\u2019s set up the WordPress configuration file now. Grab salt values with <code>curl -s https:\/\/api.wordpress.org\/secret-key\/1.1\/salt\/<\/code><\/li>\n\n\n\n<li>You\u2019ll see something similar:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wp-salt-1024x545.png\" alt=\"\" class=\"wp-image-793\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wp-salt-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wp-salt-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"13\">\n<li>Copy and replace the values in the wp-config.php file. Use vim wp-config.php and replace copied values in place of all the define(\u2026, &#8216;put your unique values here&#8217;) constants. It should look like this once values are replaced:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/salt-values-updated-1024x545.png\" alt=\"\" class=\"wp-image-794\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/salt-values-updated-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/salt-values-updated-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"14\">\n<li>We now need to update the database configuration as well. Make sure you have the database name and the user privileged to perform CRUD ops on that DB. Once you\u2019re ready, replace the constants with the database name, username and it\u2019s password. Use vim wp-config.php again and once it\u2019s updated should look something like this:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/updated-wp-config-php-1024x545.png\" alt=\"\" class=\"wp-image-796\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/updated-wp-config-php-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/updated-wp-config-php-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"15\">\n<li>Hit Esc and use: <code>wq!<\/code> to save changes and exit.<\/li>\n\n\n\n<li>If we\u2019ve set up the configuration file correctly and completed all these steps in sequence properly, we should now be ready to complete our installation through the web interface. Head over to the web address which in our case is <code>https:\/\/testwp.rewaant.com\/<\/code> Once we\u2019re there we should have the WordPress-guided installation available for use. From then on setting it up is a piece of cake. You now have a basic WordPress self-hosted installation up and running.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-new-installation-language-selection-1024x545.png\" alt=\"\" class=\"wp-image-797\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-new-installation-language-selection-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-new-installation-language-selection-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-welcome-page-site-setup-1024x545.png\" alt=\"\" class=\"wp-image-798\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-welcome-page-site-setup-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-welcome-page-site-setup-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-site-setup-successfully-1024x545.png\" alt=\"\" class=\"wp-image-799\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-site-setup-successfully-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpress-site-setup-successfully-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpres-admin-login-page-1024x545.png\" alt=\"\" class=\"wp-image-800\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpres-admin-login-page-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/wordpres-admin-login-page-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/default-site-homepage-1024x545.png\" alt=\"\" class=\"wp-image-801\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/default-site-homepage-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/default-site-homepage-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<p>So that\u2019s it, folks! We\u2019re now running a completely self-hosted copy of WordPress on an Ubuntu server we almost set up from scratch. A lot of the things we\u2019ve done could be further elaborated on or followed for specific requirements but there you have it for setting up a basic WordPress installation on a cloud server.<\/p>\n\n\n\n<p>In the next (optional) section, we\u2019ll be setting up PHPMyAdmin on the server which is a tool highly recommended if you regularly need maintenance work done or are planning to serve several websites from this server.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuring-phpmyadmin\">Configuring PHPMyAdmin (optional)<\/h2>\n\n\n\n<p>PHPMyAdmin is a great tool for site administrators who maintain PHP and MySQL websites. We\u2019ll cut to the chase and quickly show how you can get it up and running on your Ubuntu server.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>We\u2019ll start by updating all the packages: <code>sudo apt update<\/code><\/li>\n\n\n\n<li>We\u2019ll install all the required packages: <code>sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl<\/code><\/li>\n\n\n\n<li>Make sure you choose <code>apache2<\/code> in the following screen:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-web-server-1024x545.png\" alt=\"\" class=\"wp-image-802\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-web-server-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-web-server-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>Choose Yes to use dconfig-common in the following screen:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/dconfig-1024x545.png\" alt=\"\" class=\"wp-image-803\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/dconfig-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/dconfig-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Type in the MySQL application password when prompted:<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/mysql-password-1024x545.png\" alt=\"\" class=\"wp-image-804\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/mysql-password-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/mysql-password-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\">\n<li>Once done, enable the php mbstring module with <code>sudo phpenmod mbstring<\/code> and restart apache with <code>sudo systemctl restart apache2<\/code>.<\/li>\n\n\n\n<li>You should now be able to access PHPMyAdmin at <code>https:\/\/[your_domain]\/phpmyadmin<\/code>. Make sure you can log in with the root user.<\/li>\n\n\n\n<li>In the event that you\u2019re getting a 404 Not Found Error, open <code>\/etc\/apache2\/apache2.conf<\/code> and append <code>Include \/etc\/phpmyadmin\/apache.conf<\/code> to the end of the file. Restart the apache2 service with <code>sudo systemctl restart apache2<\/code>. It should now work well.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-login-page-1024x545.png\" alt=\"\" class=\"wp-image-805\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-login-page-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-login-page-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"545\" src=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-homepage-1024x545.png\" alt=\"\" class=\"wp-image-806\" srcset=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-homepage-980x522.png 980w, https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/phpmyadmin-homepage-480x256.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) and (max-width: 980px) 980px, (min-width: 981px) 1024px, 100vw\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"9\">\n<li>You may also need to increase the allowed upload limit for PHPMyAdmin from 2Mib to 128Mib or 256Mib to allow for importing larger database sizes. We\u2019ve written a quick blog post on how to do that <a href=\"#\">here<\/a>.<\/li>\n<\/ol>\n\n\n\n<p>There are a few more things that can be done to improve site\/server performance as well as the flexibility to allow larger file uploads and requirement-specific configuration for PHP, Apache, and MySQL but I believe this guide is already getting too long. Please check other guides on related topics as well as keep a check on upcoming content.<\/p>\n\n\n\n<p>If you face any issues following this guide, feel free to comment for help below or reach out directly to us at: <a href=\"mailto:hello@rewaant.com\">hello@rewaant.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve been looking for setting up a WordPress installation on a Ubuntu or Debian server, you&#8217;ve come to the right place.<\/p>\n<p>In this guide, we take you step by step to setting up your own server, securing and taking WordPress live on your domain.<\/p>\n","protected":false},"author":1,"featured_media":817,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false,"footnotes":""},"categories":[12,14,13,18,15],"tags":[],"class_list":["post-775","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud-hosting","category-cms","category-hosting","category-server-admin","category-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Complete guide to Hosting WordPress on Ubuntu or Debian in 2023 - Rewaant | Blog | Web &amp; Mobile Dev Tidbits<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023 - Rewaant | Blog | Web &amp; Mobile Dev Tidbits\" \/>\n<meta property=\"og:description\" content=\"If you&#039;ve been looking for setting up a WordPress installation on a Ubuntu or Debian server, you&#039;ve come to the right place. In this guide, we take you step by step to setting up your own server, securing and taking WordPress live on your domain.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/\" \/>\n<meta property=\"og:site_name\" content=\"Rewaant | Blog | Web &amp; Mobile Dev Tidbits\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-19T21:37:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-01T19:37:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/hosting_wp_on_ubuntu_debian.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"588\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rewaant Chhabra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rewaantllc\" \/>\n<meta name=\"twitter:site\" content=\"@rewaantllc\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rewaant Chhabra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/\"},\"author\":{\"name\":\"Rewaant Chhabra\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#\\\/schema\\\/person\\\/ba855e29fc3aef528547d8cc5d574754\"},\"headline\":\"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023\",\"datePublished\":\"2022-12-19T21:37:58+00:00\",\"dateModified\":\"2023-01-01T19:37:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/\"},\"wordCount\":2666,\"publisher\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/hosting_wp_on_ubuntu_debian.png\",\"articleSection\":[\"Cloud Hosting\",\"CMS\",\"Hosting\",\"Server Administration\",\"WordPress\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/\",\"url\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/\",\"name\":\"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023 - Rewaant | Blog | Web &amp; Mobile Dev Tidbits\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/hosting_wp_on_ubuntu_debian.png\",\"datePublished\":\"2022-12-19T21:37:58+00:00\",\"dateModified\":\"2023-01-01T19:37:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/#primaryimage\",\"url\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/hosting_wp_on_ubuntu_debian.png\",\"contentUrl\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/12\\\/hosting_wp_on_ubuntu_debian.png\",\"width\":1024,\"height\":588},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/hosting-wordpress-on-ubuntu-or-debian\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/\",\"name\":\"Rewaant | Blog | Web &amp; Mobile Dev Tidbits\",\"description\":\"Web &amp; Mobile Dev Tidbits\",\"publisher\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#organization\",\"name\":\"Rewaant | Blog | Web &amp; Mobile Dev Tidbits\",\"url\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/rewaant_logo.png\",\"contentUrl\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/09\\\/rewaant_logo.png\",\"width\":544,\"height\":544,\"caption\":\"Rewaant | Blog | Web &amp; Mobile Dev Tidbits\"},\"image\":{\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/rewaantllc\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/rewaantllc\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/#\\\/schema\\\/person\\\/ba855e29fc3aef528547d8cc5d574754\",\"name\":\"Rewaant Chhabra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a0645ed92498626e9f50d57143ac2213945fe137a73a9885e4f7e7199015b8bf?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a0645ed92498626e9f50d57143ac2213945fe137a73a9885e4f7e7199015b8bf?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a0645ed92498626e9f50d57143ac2213945fe137a73a9885e4f7e7199015b8bf?s=96&d=mm&r=g\",\"caption\":\"Rewaant Chhabra\"},\"sameAs\":[\"https:\\\/\\\/rewaant.com\\\/blog\"],\"url\":\"https:\\\/\\\/rewaant.com\\\/blog\\\/author\\\/rewaant\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023 - Rewaant | Blog | Web &amp; Mobile Dev Tidbits","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/","og_locale":"en_US","og_type":"article","og_title":"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023 - Rewaant | Blog | Web &amp; Mobile Dev Tidbits","og_description":"If you've been looking for setting up a WordPress installation on a Ubuntu or Debian server, you've come to the right place. In this guide, we take you step by step to setting up your own server, securing and taking WordPress live on your domain.","og_url":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/","og_site_name":"Rewaant | Blog | Web &amp; Mobile Dev Tidbits","article_published_time":"2022-12-19T21:37:58+00:00","article_modified_time":"2023-01-01T19:37:39+00:00","og_image":[{"width":1024,"height":588,"url":"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/hosting_wp_on_ubuntu_debian.png","type":"image\/png"}],"author":"Rewaant Chhabra","twitter_card":"summary_large_image","twitter_creator":"@rewaantllc","twitter_site":"@rewaantllc","twitter_misc":{"Written by":"Rewaant Chhabra","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/#article","isPartOf":{"@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/"},"author":{"name":"Rewaant Chhabra","@id":"https:\/\/rewaant.com\/blog\/#\/schema\/person\/ba855e29fc3aef528547d8cc5d574754"},"headline":"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023","datePublished":"2022-12-19T21:37:58+00:00","dateModified":"2023-01-01T19:37:39+00:00","mainEntityOfPage":{"@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/"},"wordCount":2666,"publisher":{"@id":"https:\/\/rewaant.com\/blog\/#organization"},"image":{"@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/#primaryimage"},"thumbnailUrl":"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/hosting_wp_on_ubuntu_debian.png","articleSection":["Cloud Hosting","CMS","Hosting","Server Administration","WordPress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/","url":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/","name":"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023 - Rewaant | Blog | Web &amp; Mobile Dev Tidbits","isPartOf":{"@id":"https:\/\/rewaant.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/#primaryimage"},"image":{"@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/#primaryimage"},"thumbnailUrl":"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/hosting_wp_on_ubuntu_debian.png","datePublished":"2022-12-19T21:37:58+00:00","dateModified":"2023-01-01T19:37:39+00:00","breadcrumb":{"@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/#primaryimage","url":"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/hosting_wp_on_ubuntu_debian.png","contentUrl":"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2022\/12\/hosting_wp_on_ubuntu_debian.png","width":1024,"height":588},{"@type":"BreadcrumbList","@id":"https:\/\/rewaant.com\/blog\/hosting-wordpress-on-ubuntu-or-debian\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rewaant.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Complete guide to Hosting WordPress on Ubuntu or Debian in 2023"}]},{"@type":"WebSite","@id":"https:\/\/rewaant.com\/blog\/#website","url":"https:\/\/rewaant.com\/blog\/","name":"Rewaant | Blog | Web &amp; Mobile Dev Tidbits","description":"Web &amp; Mobile Dev Tidbits","publisher":{"@id":"https:\/\/rewaant.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rewaant.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/rewaant.com\/blog\/#organization","name":"Rewaant | Blog | Web &amp; Mobile Dev Tidbits","url":"https:\/\/rewaant.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rewaant.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2021\/09\/rewaant_logo.png","contentUrl":"https:\/\/rewaant.com\/blog\/wp-content\/uploads\/2021\/09\/rewaant_logo.png","width":544,"height":544,"caption":"Rewaant | Blog | Web &amp; Mobile Dev Tidbits"},"image":{"@id":"https:\/\/rewaant.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/rewaantllc","https:\/\/www.linkedin.com\/company\/rewaantllc\/"]},{"@type":"Person","@id":"https:\/\/rewaant.com\/blog\/#\/schema\/person\/ba855e29fc3aef528547d8cc5d574754","name":"Rewaant Chhabra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a0645ed92498626e9f50d57143ac2213945fe137a73a9885e4f7e7199015b8bf?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a0645ed92498626e9f50d57143ac2213945fe137a73a9885e4f7e7199015b8bf?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a0645ed92498626e9f50d57143ac2213945fe137a73a9885e4f7e7199015b8bf?s=96&d=mm&r=g","caption":"Rewaant Chhabra"},"sameAs":["https:\/\/rewaant.com\/blog"],"url":"https:\/\/rewaant.com\/blog\/author\/rewaant\/"}]}},"_links":{"self":[{"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/posts\/775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/comments?post=775"}],"version-history":[{"count":15,"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/posts\/775\/revisions"}],"predecessor-version":[{"id":872,"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/posts\/775\/revisions\/872"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/media\/817"}],"wp:attachment":[{"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/media?parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/categories?post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rewaant.com\/blog\/wp-json\/wp\/v2\/tags?post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}