{"id":4892,"date":"2022-07-05T09:05:19","date_gmt":"2022-07-05T03:35:19","guid":{"rendered":"https:\/\/www.hostnamaste.com\/blog\/?p=4892"},"modified":"2022-12-14T22:21:25","modified_gmt":"2022-12-14T16:51:25","slug":"how-to-install-wordpress-on-ubuntu-apache-server","status":"publish","type":"post","link":"https:\/\/www.hostnamaste.com\/blog\/how-to-install-wordpress-on-ubuntu-apache-server\/","title":{"rendered":"How To Install WordPress on Ubuntu Apache Server &#8211; HostNamaste.com"},"content":{"rendered":"<figure id=\"attachment_4894\" aria-describedby=\"caption-attachment-4894\" style=\"width: 829px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-4894\" src=\"https:\/\/www.hostnamaste.com\/blog\/wp-content\/uploads\/2022\/06\/How-To-Install-WordPress-on-Ubuntu-Apache-Server-HostNamaste.png\" alt=\"How To Install WordPress on Ubuntu Apache Server - HostNamaste\" width=\"829\" height=\"499\" \/><figcaption id=\"caption-attachment-4894\" class=\"wp-caption-text\"><span style=\"font-size: 14pt; font-family: Verdana, Geneva; color: #000000;\"><strong>How To Install WordPress on Ubuntu Apache Server &#8211; HostNamaste<\/strong><\/span><\/figcaption><\/figure>\n<p><span style=\"font-family: Verdana, Geneva;\"><span style=\"text-decoration: underline;\"><a href=\"https:\/\/www.hostnamaste.com\/blog\/top-10-free-blogging-platforms-to-start-a-blog\/\"><strong>WordPress is one of the best Content Management Systems available in the market<\/strong><\/a><\/span>. It allows users to easily set up flexible blogs and websites with MySQL as the backend and PHP processing the dynamic pages of the website. WordPress CMS has seen a good rate of adoption and is a great choice for getting your websites on the search engine and running them quickly.<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">There are many ways of installing WordPress including the one using LAMP or LEMP stack. This is one of the most highly used methods. Its impressive features and extensive plugin framework and theme systems allows site owners and developers to enjoy its simple and powerful publishing tools.\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">In this guide, you will learn how to install WordPress instances set up on <span style=\"text-decoration: underline;\"><a href=\"https:\/\/ubuntu.com\/\" target=\"_blank\" rel=\"noopener\"><strong>Ubuntu<\/strong><\/a><\/span>.<\/span><\/p>\n<h2><span style=\"font-family: Verdana, Geneva; font-size: 18pt;\"><strong>Prerequisites<\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">Before you start, you need to complete some important steps on the server.\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">You need to be a non-root user using your\u00a0<strong><em>sudo<\/em><\/strong>\u00a0privileges.\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Login to your server as root or as a user with root privilege (<em><strong>sudo<\/strong><\/em>)<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">To check your hostname, run the following code:<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">hostname<\/span><\/strong><\/pre>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">hostname -f<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">The first code will convey your short hostname and the second states your fully qualified domain name (FQDN).\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">You need to configure LAMP or LEMP Stack.<\/span><\/p>\n<h2><span style=\"font-size: 18pt; font-family: Verdana, Geneva;\"><strong>How To Install WordPress on Ubuntu Apache Server<\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">The following steps will help you to install WordPress on Ubuntu.<\/span><\/p>\n<h2><span style=\"font-family: Verdana, Geneva;\"><strong>Step 1): Install MySQL database<\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">WordPress is a relational database used to manage and store site and the user information. With MySQL installed, you can fulfil this functionality. You need to make a database and a user for WordPress to work with.<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Set up MySQL database for WordPress.<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Follow these steps:<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Log in to your MySQL command line as a root (administrative) user by using the command:<\/span><\/p>\n<pre><strong><span style=\"font-size: 14pt; font-family: Verdana, Geneva;\">mysql -u root -p<\/span><\/strong><\/pre>\n<p class=\"wp-block-preformatted\"><span style=\"font-family: Verdana, Geneva;\">You will be asked for the password you used to set your MySQL root account.<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Now, you need to create a separate database that WordPress can control. You can call it anything you want. Here, in this example, we use the name WordPress. Enter the command:<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">CREATE DATABASE wordpress;<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">All SQL statements must end in semi-colon. Next, you need to create a separate MySQL user account that will only be used to operate the database. Assign a user name to it and a password. You will have to replace the username and password when you create your own account. Use the command:<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">CREATE USER wpuser@localhost IDENTIFIED BY 'password';<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">You need to grant the user access to the database. Use the command:\u00a0<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">GRANT ALL PRIVILEGES ON wordpress.* TO wpuser@localhost;<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">Now, you need to remove the previous MySQL instances to force the new privilege changes made.\u00a0<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">FLUSH PRIVILEGES;<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">Exit MySQL database using command:<\/span><\/p>\n<pre><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">exit<\/span><\/strong><\/pre>\n<h2><span style=\"font-family: Verdana, Geneva;\"><strong><span style=\"font-size: 18pt;\">Step 2) Download WordPress<\/span><\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">You have to download WordPress software from the website. Follow these steps:\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">You need to create a directory called\u00a0<strong><span style=\"font-size: 14pt;\"><code>src<\/code><\/span><\/strong>\u00a0under your website\u2019s directory, to store the fresh WordPress files. Enter the command:<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo mkdir \/var\/www\/html\/example.com\/src\/<\/span><\/strong><\/pre>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">cd \/var\/www\/html\/example.com\/src\/<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">Here<strong><em>,\u00a0<\/em><span style=\"font-size: 14pt;\"><code>var\/www\/html\/example.com\/<\/code><\/span><\/strong>\u00a0is used as an example. You can create your own home directory.\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Set the user of your web server as the owner of your site\u2019s home directory.\u00a0<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo chown -R www-data:www-data \/var\/www\/html\/example.com\/<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">Now, install the latest version of WordPress and extract it using command,<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo wget http:\/\/wordpress.org\/latest.tar.gz<\/span><\/strong><\/pre>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo -u www-data tar -xvf latest.tar.gz<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">Now, rename\u00a0<span style=\"font-size: 14pt;\"><strong><code>latest.tar.gz<\/code><\/strong><\/span>\u00a0as\u00a0<strong><em>WordPress<\/em><\/strong>\u00a0followed by the date, to store a backup of the original files in case you ever install new version in the future.\u00a0<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo mv latest.tar.gz wordpress-`date \"+%Y-%m-%d\"`.tar.gz<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">Next, create a public directory to be the root directory for WordPress. This means that everyone will be able to access your WordPress site. Use command\u00a0<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo mkdir \/var\/www\/html\/example.com\/public_html\/<\/span><\/strong><\/pre>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo mv wordpress\/* ..\/public_html\/<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">Now, change the web server ownership to the public folder.<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo chown -R www-data:www-data \/var\/www\/html\/example.com\/public_html<\/span><\/strong><\/pre>\n<h2><span style=\"font-family: Verdana, Geneva;\"><strong><span style=\"font-size: 18pt;\">Step 3) Configure WordPress<\/span><\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">This configuration will be done on the command line of WordPress. Follow these steps:\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Navigate your domain in the web browser. Fill in your details like the preferred language and click on the Let\u2019s go button. Use the database credentials that were set when you installed MYSQL:<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Once WordPress confirms the credentials, prompt to\u00a0<strong>Run to Install<\/strong>.\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Fill in all the administrator or root information. And click on install WordPress.<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Now, enter your details and click on Log In.<\/span><\/p>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Verdana, Geneva;\">WordPress will prompt you for FTP credentials when you install any new theme or plugins. To bypass it, modify the WordPress configuration <span style=\"font-size: 14pt;\"><strong>(<code>wp-config.php<\/code>)<\/strong><\/span> by adding the following lines:<\/span><\/div>\n<div>\u00a0<\/div>\n<div>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">\/** Bypass FTP *\/\ndefine('FS_METHOD', 'direct');<\/span><\/strong><\/pre>\n<\/div>\n<div>\u00a0<\/div>\n<div><span style=\"font-family: Verdana, Geneva;\">In case you are using Apache or LAMP stack, run the following command to ensure that\u00a0<span style=\"font-size: 14pt;\"><strong><code>mod_rewrite<\/code><\/strong><\/span>\u00a0is enabled. Restart Apache to apply the changes.<\/span><\/div>\n<div>\n<p><span style=\"font-family: Verdana, Geneva;\">If you want to make any further changes, access the WordPress dashboard from the web interface by adding code,<strong><span style=\"font-size: 14pt;\"><code>\/wp-admin<\/code><\/span><\/strong>\u00a0to your website address.\u00a0<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Now, you have successfully installed WordPress.<\/span><\/p>\n<h2><span style=\"font-family: Verdana, Geneva;\"><strong><span style=\"font-size: 18pt;\">Step 4) Create WordPress Permalinks<\/span><\/strong><\/span><\/h2>\n<\/div>\n<p><span style=\"font-family: Verdana, Geneva;\">Permalinks or permanent links, are URLs that are automatically created for some posts or pages in WordPress. This helps in interlinking or backlinking of posts. By default, WordPress assigns post numbers as permalinks. This means that every specific post will have a\u00a0<strong><em>p=23<\/em><\/strong>\u00a0type of number associated with it. If you want permalinks to be more information, you need to make a few adjustments to Apache or Nginx, depending on the stack you used.<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Follow these steps to configure permalink settings.\u00a0<\/span><\/p>\n<ul>\n<li><span style=\"font-family: Verdana, Geneva;\">Login to your WordPress admin panel by adding\u00a0<span style=\"font-size: 14pt;\"><strong><code>\/wp-admin<\/code><\/strong><\/span>\u00a0to the URL.<\/span><\/li>\n<li><span style=\"font-family: Verdana, Geneva;\">Click on Settings and then navigate to Permalinks.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-family: Verdana, Geneva;\">You can select your preferred permalink style or customize your own, using\u00a0<em>Custom Structure<\/em>. Click on\u00a0<strong><em>Save Changes<\/em><\/strong>.<\/span><\/p>\n<h2><span style=\"font-family: Verdana, Geneva;\"><strong><span style=\"font-size: 18pt;\">Step 5) Configure WordPress to allow permalinks on Apache<\/span><\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">You need to modify Apache to allow rewrites on the\u00a0<span style=\"font-size: 14pt;\"><strong><code>.htaccess<\/code><em>\u00a0<\/em><\/strong><\/span>overrides. You can do so by editing the virtual host file in the\u00a0<em>Directory<\/em>\u00a0Section.<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">&lt;Directory \/var\/www\/html\/example.com\/public_html&gt;\n\u00a0\u00a0\u00a0\u00a0Options Indexes FollowSymLinks\n\u00a0\u00a0\u00a0\u00a0AllowOverride All\n\u00a0\u00a0\u00a0\u00a0Require all granted\n&lt;\/Directory&gt;<\/span><\/strong><\/pre>\n<p><span style=\"font-family: Verdana, Geneva;\">Restart Apache to save the changes.<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva; font-size: 14pt;\">sudo systemctl restart apache2<\/span><\/strong><\/pre>\n<h2><span style=\"font-family: Verdana, Geneva;\"><strong><span style=\"font-size: 18pt;\">Step 6) Configure WordPress to allow permalinks on Nginx<\/span><\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">By default, Nginx assumes that each permalink doesn\u2019t refer to an existing page. It, therefore, returns a server-side 404 error. You need to update the command lines in the<strong><em>\u00a0<\/em><span style=\"font-size: 14pt;\"><code>location \/ {<\/code><\/span><\/strong>\u00a0block of the virtual host file configuration. Use the code:<\/span><\/p>\n<div class=\"entry-content\">\n<h2><span style=\"font-family: Verdana, Geneva;\"><strong><span style=\"font-size: 18pt;\">Step 7) Modify maximum file size upload setting to allow larger files<\/span><\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">By default, PHP allows only web uploads under 2 megabytes. If you want to upload larger files through the web interface, configure the\u00a0<span style=\"font-size: 14pt;\"><strong><code>upload_max_filesize<\/code><\/strong><\/span>\u00a0setting in the\u00a0<span style=\"font-size: 14pt;\"><strong><code>php.ini<\/code><\/strong><\/span>.<\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">For Apache:\u00a0<span style=\"font-size: 18pt;\"><strong><code>\/etc\/php\/7.0\/apache2\/php.ini<\/code><\/strong><\/span><\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">For Nginx:\u00a0<strong><span style=\"font-size: 14pt;\"><code>\/etc\/php\/7.0\/fpm\/php.ini<\/code><\/span><\/strong><\/span><\/p>\n<p><span style=\"font-family: Verdana, Geneva;\">Look for the command line:<\/span><\/p>\n<pre class=\"wp-block-preformatted\"><strong><span style=\"font-family: Verdana, Geneva;\"><span style=\"font-size: 14pt;\">; Maximum allowed size for uploaded files.<\/span>\n<span style=\"font-size: 14pt;\">; http:\/\/php.net\/upload-max-filesize<\/span>\n<span style=\"font-size: 14pt;\">upload_max_filesize = 2M<\/span><\/span><\/strong><\/pre>\n<\/div>\n<h2><span style=\"font-family: Verdana, Geneva;\"><strong><span style=\"font-size: 18pt;\">Conclusion<\/span><\/strong><\/span><\/h2>\n<p><span style=\"font-family: Verdana, Geneva;\">I hope this blog post will help you to install WordPress on ubuntu easily.\u00a0 Let me know in the comments if you have any questions or suggestions for the post.<\/span><\/p>\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"How To Install WordPress on Ubuntu Apache Server \u2013 HostNamaste.com\" width=\"758\" height=\"426\" src=\"https:\/\/www.youtube.com\/embed\/lvbGV3tGILo?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\"><a href=\"https:\/\/www.youtube.com\/watch?v=lvbGV3tGILo\" target=\"_blank\" rel=\"noopener\"><strong>How To Install WordPress on Ubuntu Apache Server \u2013 HostNamaste.com<\/strong><\/a><\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>WordPress is one of the best Content Management Systems available in the market. It allows users to easily set up flexible blogs and websites with&hellip;<\/p>\n","protected":false},"author":2,"featured_media":4894,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3207,3098,3206],"tags":[2354,3211,3210,3209,3208,2661,432],"class_list":["post-4892","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-how-to-install","category-how-to-install-wordpress","tag-apache-server","tag-how-to","tag-how-to-install","tag-how-to-install-wordpress-on-ubuntu","tag-nstall-wordpress","tag-ubuntu","tag-wordpress"],"acf":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/posts\/4892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/comments?post=4892"}],"version-history":[{"count":29,"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/posts\/4892\/revisions"}],"predecessor-version":[{"id":5341,"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/posts\/4892\/revisions\/5341"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/media\/4894"}],"wp:attachment":[{"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/media?parent=4892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/categories?post=4892"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostnamaste.com\/blog\/wp-json\/wp\/v2\/tags?post=4892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}