{"id":311,"date":"2024-03-20T01:37:00","date_gmt":"2024-03-20T01:37:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=311"},"modified":"2024-03-20T01:37:00","modified_gmt":"2024-03-20T01:37:00","slug":"wordpress-installation-guide","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=311","title":{"rendered":"WordPress Installation Guide: Install and Configure WordPress on Ubuntu"},"content":{"rendered":"<p>This WordPress installation guide helps you to install and configure the latest WordPress on an Ubuntu Linux box. It covers Apache, <a href=\"https:\/\/devopscube.com\/install-mariadb-on-ubuntu\/\" rel=\"noreferrer\">MariaDB<\/a>, PHP, and WordPress configurations.<\/p>\n<h2 id=\"wordpress-installation-on-ubuntu-server\">WordPress Installation On Ubuntu Server<\/h2>\n<p>This installation guide covers the following.<\/p>\n<ol>\n<li>Installation and configuration of <a href=\"https:\/\/httpd.apache.org\/?ref=devopscube.com\" rel=\"noopener\">Apache2<\/a><\/li>\n<li>Installation and configuration for <a href=\"https:\/\/mariadb.org\/?ref=devopscube.com\" rel=\"noopener\">MariaDB<\/a><\/li>\n<li>Installation and configuration of PHP and Apache modules.<\/li>\n<li>WordPress Apache configurations with a domain name.<\/li>\n<li>Accessing the <a href=\"https:\/\/wordpress.org\/?ref=devopscube.com\" rel=\"noopener\">WordPress<\/a> dashboard.<\/li>\n<\/ol>\n<h2 id=\"how-to-install-wordpress-on-ubuntu-server\">How to install WordPress on Ubuntu Server?<\/h2>\n<p>Follow the steps given below for the complete WordPress setup on Ubuntu 23.04<\/p>\n<h2 id=\"install-and-configure-apache-2\">Install and Configure Apache 2<\/h2>\n<p><strong>Step 1:<\/strong> Login to the server and <a href=\"https:\/\/askubuntu.com\/questions\/222348\/what-does-sudo-apt-get-update-do?ref=devopscube.com\" rel=\"noopener\">update the package repos<\/a>.<\/p>\n<pre><code>sudo apt-get update -y<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Install Apache2<strong>,<\/strong><\/p>\n<pre><code>sudo apt-get install apache2 -y<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Execute the following command to disable anonymous directory listing.<\/p>\n<pre><code>sudo sed -i \"s\/Options Indexes FollowSymLinks\/Options FollowSymLinks\/\" \/etc\/apache2\/apache2.conf<\/code><\/pre>\n<p><strong>Step 4:<\/strong> Start, enable, and check the status of Apache2<\/p>\n<pre><code>sudo systemctl stop apache2\nsudo systemctl enable apache2\nsudo systemctl start apache2<\/code><\/pre>\n<h2 id=\"install-and-configure-mariadb\">Install and Configure MariaDB<\/h2>\n<p><strong>Step 1:<\/strong> Install the Marais DB database server and client<\/p>\n<pre><code>sudo apt-get install mariadb-server mariadb-client -y<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Use the following commands to start, stop, enable, and check the status of the MariaDB service.<\/p>\n<pre><code>sudo systemctl stop mysql\nsudo systemctl start mysql\nsudo systemctl enable mysql\nsudo systemctl status mysql<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Setup the root admin password for the database using mysql_secure_installation command. It will prompt you to set up the new password.<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>Use the following options for the prompt.<\/p>\n<pre><code>Enter current password for root (enter for none): Just press the Enter\nSet root password? [Y\/n]: Y\nNew password: Enter password\nRe-enter new password: Repeat password\nRemove anonymous users? [Y\/n]: Y\nDisallow root login remotely? [Y\/n]: Y\nRemove test database and access to it? [Y\/n]:  Y\nReload privilege tables now? [Y\/n]:  Y<\/code><\/pre>\n<p><strong>Step 4:<\/strong> Restart the database server for the changes to take effect.<\/p>\n<pre><code>sudo systemctl restart mysql<\/code><\/pre>\n<h2 id=\"setup-and-configure-php\">Setup and Configure PHP<\/h2>\n<p><strong>Step 1:<\/strong> Install PHP 8 and its related modules.<\/p>\n<pre><code>sudo apt-get install php8.2 php8.2-mysql libapache2-mod-php8.2 php8.2-cli php8.2-cgi php8.2-gd<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Open  \/etc\/php\/8.2\/apache2\/php.ini file<\/p>\n<pre><code>sudo vi \/etc\/php\/8.2\/apache2\/php.ini<\/code><\/pre>\n<p>Add the following contents to the file.<\/p>\n<pre><code>file_uploads = On\nallow_url_fopen = On\nmemory_limit = 256M\nupload_max_filesize = 150M\nmax_execution_time = 350\ndate.timezone = America\/Chicago<\/code><\/pre>\n<h2 id=\"configure-database-for-wordpress\">Configure Database For WordPress<\/h2>\n<p><strong>Step 1:<\/strong> Login to the database using the password you set for root.<\/p>\n<pre><code>sudo mysql -u root -p<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Create a database named &#8220;wordpress-db&#8221;<\/p>\n<pre><code>CREATE DATABASE wordpress_db;<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Create a new database user named &#8220;wordpress-admin&#8221; and set a custom password. This user will be used in the WordPress configuration.<\/p>\n<pre><code>CREATE USER 'wordpress-admin'@'localhost' IDENTIFIED BY 'your_password_here';<\/code><\/pre>\n<p><strong>Step 4:<\/strong> Grant all privileged on wordpress-db for wordpress-admin user. Replace the password you set for wordpress-admin.<\/p>\n<pre><code>GRANT ALL ON wordpress_db.* TO 'wordpress-admin'@'localhost' IDENTIFIED BY 'your-password-here' WITH GRANT OPTION;<\/code><\/pre>\n<p><strong>Step 5:<\/strong> Flush all privileges and exit the db shell.<\/p>\n<pre><code>FLUSH PRIVILEGES; exit<\/code><\/pre>\n<h2 id=\"setup-and-configure-wordpress\">Setup and Configure WordPress<\/h2>\n<p><strong>Step 1:<\/strong> Download the latest WordPress<\/p>\n<pre><code>wget https:\/\/wordpress.org\/latest.tar.gz<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Untar the WordPress files<\/p>\n<pre><code>tar -xvf latest.tar.gz<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Move the WordPress folder to \/var\/www\/html folder.<\/p>\n<pre><code>sudo mv wordpress \/var\/www\/html\/wordpress<\/code><\/pre>\n<p><strong>Step 4:<\/strong> Change the ownership of the wordpress folder to www-data<\/p>\n<pre><code>sudo chown -R www-data:www-data \/var\/www\/html\/wordpress\/<\/code><\/pre>\n<p><strong>Step 5:<\/strong> Change the folder and file permissions using the following command. Folders should have 755 permission, and files should have 644 permission.<\/p>\n<pre><code>find \/var\/www\/html\/ -type d -print0 | xargs -0 chmod 0755\nfind \/var\/www\/html\/ -type f -print0 | xargs -0 chmod 0644<\/code><\/pre>\n<p>You can check if the permissions have been applied using the following command.<\/p>\n<pre><code>stat -c \"%a %n\"  \/var\/www\/html\/wordpress\/*<\/code><\/pre>\n<h2 id=\"configure-apache-for-wordpress\">Configure Apache For WordPress<\/h2>\n<p><strong>Step 1:<\/strong> Create a new Apache configuration named wp-site.conf for the WordPress site.<\/p>\n<pre><code>sudo vi \/etc\/apache2\/sites-available\/wp-site.conf<\/code><\/pre>\n<p>Add the following configuration to the file and save it. Replace <code>yourdomain<\/code> with your custom domain name.<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\n     ServerAdmin admin@yourdomain.com\n     DocumentRoot \/var\/www\/html\/wordpress\/\n     ServerName yourdomain.com\n     ServerAlias www.yourdomain.com\n\n     &lt;Directory \/var\/www\/html\/wordpress\/&gt;\n        Options +FollowSymlinks\n        AllowOverride All\n        Require all granted\n     &lt;\/Directory&gt;\n\n     ErrorLog ${APACHE_LOG_DIR}\/error.log\n     CustomLog ${APACHE_LOG_DIR}\/access.log combined\n\n&lt;\/VirtualHost&gt;<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Enable wp-site.conf<\/p>\n<pre><code>sudo a2ensite wp-site.conf<\/code><\/pre>\n<p><strong>Step 3:<\/strong> Enable the Apache rewrite module.<\/p>\n<pre><code>sudo a2enmod rewrite<\/code><\/pre>\n<p><strong>Step 4:<\/strong> Restart the Apache server.<\/p>\n<pre><code>sudo systemctl restart apache2<\/code><\/pre>\n<h2 id=\"configure-wordpress-application\">Configure WordPress Application<\/h2>\n<p><strong>Step 1:<\/strong> Rename the default <code>wp-config-sample.php<\/code> to <code>wp-config.php<\/code><\/p>\n<pre><code>sudo mv \/var\/www\/html\/wordpress\/wp-config-sample.php \/var\/www\/html\/wordpress\/wp-config.php<\/code><\/pre>\n<p><strong>Step 2:<\/strong> Open the wp-config.php file<\/p>\n<pre><code>sudo vi \/var\/www\/html\/wordpress\/wp-config.php<\/code><\/pre>\n<p>Replace the values highlighted in the image below with the database, user, and password generated in the previous steps.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-46-11.png\" class=\"kg-image\" alt=\"wp-config.php wordpress database details\" loading=\"lazy\" width=\"650\" height=\"399\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-46-11.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-46-11.png 650w\"><\/figure>\n<p><strong>Step 3:<\/strong> Now you have configured your site details on the wp-site.conf file, try to access WordPress by browsing the domain name you used on the wp-site.conf file.<\/p>\n<p>Make sure your server is mapped to the domain name you configured in the wp-site.conf file.<\/p>\n<pre><code>http:\/\/your-domain-name.com<\/code><\/pre>\n<p>If you haven&#8217;t configured a domain name, you can access the installed WordPress with<\/p>\n<pre><code>http:\/\/&lt;your-server-ip&gt;\/wordpress <\/code><\/pre>\n<p><strong>Step 4:<\/strong> Select the preferred language and fill up the details in the configuration wizard.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-44-13.png\" class=\"kg-image\" alt=\"wordpress configuration wizard.\" loading=\"lazy\" width=\"844\" height=\"468\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-44-13.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-44-13.png 844w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><strong>Step 5:<\/strong> Once WordPress is installed, you can access the dashboard using the username and password.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-45-11.png\" class=\"kg-image\" alt=\"wordpress dashboard\" loading=\"lazy\" width=\"981\" height=\"575\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-45-11.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-45-11.png 981w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>Setting up WordPress is not a complex setup if you have some Linux technical background. However, managing it long term is the complex part.<\/p>\n<p>If you are setting up WordPress for your organization, you can try managed wordpres cloud hosting like <a href=\"https:\/\/devopscube.com\/cloudways-review\/\" rel=\"noreferrer\">Cloudways<\/a>.<\/p>\n<p>If you are on a budget, you can get started with managed wordpress on Bluehost. It offer deep discounts up to 65% on its plans. Checkout the <a href=\"https:\/\/devopscube.com\/bluehost-coupon-code\/\" rel=\"noreferrer\">Bluehost Coupon<\/a> page to get the latest discounts.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/wordpress-installation-guide\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPress Installation Guide: Install and Configure WordPress on Ubuntu \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/wordpress-installation-guide\/<\/p>\n","protected":false},"author":1,"featured_media":312,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-311","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=311"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/311\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/312"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}