{"id":745,"date":"2025-02-07T10:14:36","date_gmt":"2025-02-07T10:14:36","guid":{"rendered":"https:\/\/forumweb.hosting\/blog\/?p=745"},"modified":"2025-02-07T10:14:44","modified_gmt":"2025-02-07T10:14:44","slug":"deploying-a-wordpress-site-on-an-ubuntu-vps-with-nginx-php-fpm-and-mariadb","status":"publish","type":"post","link":"https:\/\/forumweb.hosting\/blog\/deploying-a-wordpress-site-on-an-ubuntu-vps-with-nginx-php-fpm-and-mariadb\/","title":{"rendered":"Deploying a WordPress Site on an Ubuntu VPS with NGINX, PHP-FPM, and MariaDB"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>WordPress powers over 40% of websites worldwide, making it the most popular content management system (CMS). Deploying WordPress on an Ubuntu VPS using <strong>NGINX<\/strong>, <strong>PHP-FPM<\/strong>, and <strong>MariaDB<\/strong> ensures optimal performance, scalability, and security. This guide walks you through the entire process, from server preparation to WordPress installation, providing a robust stack for high-traffic websites.<\/p>\n<h3>Prerequisites<\/h3>\n<p>Before you begin, ensure you have:<\/p>\n<ul>\n<li>An Ubuntu 22.04 VPS<\/li>\n<li>Root or sudo privileges<\/li>\n<li>A registered domain name pointing to your VPS IP<\/li>\n<\/ul>\n<h3>Step 1: Update Your System<\/h3>\n<p>Start by updating your system packages to ensure the latest security patches are installed:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo apt update &amp;&amp; sudo apt upgrade -y<\/p><\/blockquote>\n<h3>Step 2: Install NGINX<\/h3>\n<p>Install NGINX as the web server to handle HTTP requests efficiently:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo apt install nginx -y<\/p><\/blockquote>\n<p>Start and enable NGINX to run at boot:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo systemctl start nginx<br \/>\nsudo systemctl enable nginx<\/p><\/blockquote>\n<p>Verify NGINX status:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo systemctl status nginx<\/p><\/blockquote>\n<h3>Step 3: Install MariaDB<\/h3>\n<p>MariaDB will serve as the database for your WordPress site:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo apt install mariadb-server mariadb-client -y<\/p><\/blockquote>\n<p>Secure the MariaDB installation:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo mysql_secure_installation<\/p><\/blockquote>\n<p>Follow the prompts to set a root password, remove anonymous users, and secure your database.<\/p>\n<h3>Step 4: Create a Database for WordPress<\/h3>\n<p>Log in to the MariaDB shell:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo mysql -u root -p<\/p><\/blockquote>\n<p>Create a database and user for WordPress:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>CREATE DATABASE wordpress;<br \/>\nCREATE USER &#8216;wpuser&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;strong_password&#8217;;<br \/>\nGRANT ALL PRIVILEGES ON wordpress.* TO &#8216;wpuser&#8217;@&#8217;localhost&#8217;;<br \/>\nFLUSH PRIVILEGES;<br \/>\nEXIT;<\/p><\/blockquote>\n<h3>Step 5: Install PHP and PHP-FPM<\/h3>\n<p>Install PHP-FPM and necessary PHP modules for WordPress:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo apt install php-fpm php-mysql php-cli php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y<\/p><\/blockquote>\n<p>Verify PHP installation:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>php -v<\/p><\/blockquote>\n<h3>Step 6: Configure NGINX for WordPress<\/h3>\n<p>Create a new server block configuration:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo nano \/etc\/nginx\/sites-available\/wordpress<\/p><\/blockquote>\n<p>Add the following configuration:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>server {<br \/>\nlisten 80;<br \/>\nserver_name yourdomain.com www.yourdomain.com;<br \/>\nroot \/var\/www\/wordpress;<br \/>\nindex index.php index.html index.htm;<\/p>\n<p>location \/ {<br \/>\ntry_files $uri $uri\/ \/index.php?$args;<br \/>\n}<\/p>\n<p>location ~ \\.php$ {<br \/>\ninclude snippets\/fastcgi-php.conf;<br \/>\nfastcgi_pass unix:\/run\/php\/php8.1-fpm.sock;<br \/>\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;<br \/>\ninclude fastcgi_params;<br \/>\n}<\/p>\n<p>location ~ \/\\.ht {<br \/>\ndeny all;<br \/>\n}<br \/>\n}<\/p><\/blockquote>\n<p>Enable the configuration:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo ln -s \/etc\/nginx\/sites-available\/wordpress \/etc\/nginx\/sites-enabled\/<\/p><\/blockquote>\n<p>Test NGINX configuration for syntax errors:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo nginx -t<\/p><\/blockquote>\n<p>Reload NGINX to apply changes:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo systemctl reload nginx<\/p><\/blockquote>\n<h3>Step 7: Download and Install WordPress<\/h3>\n<p>Navigate to the web root directory:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>cd \/var\/www\/<\/p><\/blockquote>\n<p>Download WordPress:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo wget https:\/\/wordpress.org\/latest.tar.gz<\/p><\/blockquote>\n<p>Extract the archive:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo tar -xvzf latest.tar.gz<\/p><\/blockquote>\n<p>Set proper permissions:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo chown -R www-data:www-data \/var\/www\/wordpress<br \/>\nsudo chmod -R 755 \/var\/www\/wordpress<\/p><\/blockquote>\n<h3>Step 8: Configure WordPress<\/h3>\n<p>Copy the sample configuration file:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo cp \/var\/www\/wordpress\/wp-config-sample.php \/var\/www\/wordpress\/wp-config.php<\/p><\/blockquote>\n<p>Edit the configuration file:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo nano \/var\/www\/wordpress\/wp-config.php<\/p><\/blockquote>\n<p>Update the database settings:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>define(&#8216;DB_NAME&#8217;, &#8216;wordpress&#8217;);<br \/>\ndefine(&#8216;DB_USER&#8217;, &#8216;wpuser&#8217;);<br \/>\ndefine(&#8216;DB_PASSWORD&#8217;, &#8216;strong_password&#8217;);<br \/>\ndefine(&#8216;DB_HOST&#8217;, &#8216;localhost&#8217;);<\/p><\/blockquote>\n<h3>Step 9: Secure Your WordPress Site with SSL (Optional)<\/h3>\n<p>Install Certbot for SSL:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo apt install certbot python3-certbot-nginx -y<\/p><\/blockquote>\n<p>Obtain and configure SSL:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>sudo certbot &#8211;nginx -d yourdomain.com -d www.yourdomain.com<\/p><\/blockquote>\n<h3>Step 10: Finalize WordPress Installation<\/h3>\n<p>Open your browser and navigate to:<\/p>\n<blockquote class=\"td_quote_box td_box_left\"><p>http:\/\/yourdomain.com<\/p><\/blockquote>\n<p>Complete the installation process by following the on-screen instructions:<\/p>\n<ul>\n<li>Set the site title<\/li>\n<li>Create an admin username and password<\/li>\n<li>Choose your preferred language<\/li>\n<\/ul>\n<h3>Conclusion<\/h3>\n<p>Congratulations! You\u2019ve successfully deployed a WordPress site on your Ubuntu VPS using NGINX, PHP-FPM, and MariaDB. This stack provides excellent performance, scalability, and security for your website. Don\u2019t forget to keep your server and WordPress installation updated regularly to maintain security and performance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction WordPress powers over 40% of websites worldwide, making it the most popular content management system (CMS). Deploying WordPress on an Ubuntu VPS using NGINX, PHP-FPM, and MariaDB ensures optimal performance, scalability, and security. This guide walks you through the entire process, from server preparation to WordPress installation, providing a robust stack for high-traffic websites. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":746,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[127,137,62,94,17],"_links":{"self":[{"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/posts\/745"}],"collection":[{"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/comments?post=745"}],"version-history":[{"count":1,"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/posts\/745\/revisions"}],"predecessor-version":[{"id":747,"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/posts\/745\/revisions\/747"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/media\/746"}],"wp:attachment":[{"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/media?parent=745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/categories?post=745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/forumweb.hosting\/blog\/wp-json\/wp\/v2\/tags?post=745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}