{"id":16012,"date":"2023-06-21T14:30:33","date_gmt":"2023-06-21T14:30:33","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=16012"},"modified":"2023-09-18T16:01:10","modified_gmt":"2023-09-18T16:01:10","slug":"how-to-install-wordpress-on-ubuntu-18-04-with-nginx","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/how-to-install-wordpress-on-ubuntu-18-04-with-nginx\/","title":{"rendered":"How to Install WordPress on Ubuntu 18.04 with Nginx"},"content":{"rendered":"<p><img decoding=\"async\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-1024x768.jpg\" alt=\"How to Install WordPress on Ubuntu 18.04 with Nginx\" width=\"1024\" height=\"768\" class=\"alignnone size-large wp-image-16013 lazyload\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-1024x768.jpg 1024w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-300x225.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-1536x1152.jpg 1536w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-2048x1536.jpg 2048w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-128x96.jpg 128w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-420x315.jpg 420w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-540x405.jpg 540w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-720x540.jpg 720w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-960x720.jpg 960w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-1140x855.jpg 1140w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-1320x990.jpg 1320w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2023\/06\/How-to-Install-WordPress-on-Ubuntu-18.04-with-Nginx-1440x1080.jpg 1440w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/768;\" \/><\/p>\n<p>WordPress is a popular content management system that allows you to create and manage your own website with ease. It&#8217;s a flexible and powerful tool that can be used for blogs, business websites, and even e-commerce. In this tutorial, we will guide you through the process of installing WordPress on Ubuntu 18.04 with Nginx .<\/p>\n<p><a href=\"https:\/\/webhostinggeeks.com\/blog\/nginx-server-explained\/\">Nginx<\/a> is a high-performance <a href=\"https:\/\/webhostinggeeks.com\/best\/web-server\/\">web server<\/a> and <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-reverse-proxy\/\">reverse proxy<\/a>. It&#8217;s known for its high performance, stability, rich feature set, simple configuration, and low resource consumption. <a href=\"https:\/\/webhostinggeeks.com\/blog\/what-is-ubuntu-beginners-guide-ubuntu-linux-distro\/\">Ubuntu<\/a> 18.04, also known as Bionic Beaver, is a long-term support release from Canonical. This combination provides a stable and secure platform for your WordPress site.<\/p>\n<p>Before we start, make sure you have a fully qualified domain name and a server with Ubuntu 18.04 installed. You should also have SSH access to your server and basic familiarity with command line. This tutorial assumes that you have already installed Nginx on your server. If you haven&#8217;t, please refer to our guide on <a href=\"https:\/\/webhostinggeeks.com\/howto\/how-to-install-and-configure-nginx-on-an-ubuntu-18-04\/\">installing Nginx server on Ubuntu 18.04<\/a>.<\/p>\n<h2>Step 1: Update Your System<\/h2>\n<p>First, log in to your server via SSH. Once you&#8217;re logged in, it&#8217;s a good practice to update your system packages to their latest versions. You can do this by running the following commands:<\/p>\n<pre>\r\nsudo apt update\r\nsudo apt upgrade\r\n<\/pre>\n<h2>Step 2: Install MySQL<\/h2>\n<p>WordPress uses MySQL to manage and store site and user information. Ubuntu 18.04 includes MySQL in its default repositories, so it can be installed using the apt package manager. Run the following command to install MySQL:<\/p>\n<pre>\r\nsudo apt install mysql-server\r\n<\/pre>\n<p>During the installation, you will be asked to set a password for the MySQL root user. Make sure to choose a strong password.<\/p>\n<p>After the installation is complete, run the following command to secure your MySQL installation:<\/p>\n<pre>\r\nsudo mysql_secure_installation\r\n<\/pre>\n<p>You will be asked a series of questions. It&#8217;s recommended to answer &#8220;Y&#8221; (yes) to all of them.<\/p>\n<h2>Step 3: Create a MySQL Database and User for WordPress<\/h2>\n<p>Next, you need to create a MySQL database and user for your WordPress installation. First, log in to the MySQL shell:<\/p>\n<pre>\r\nsudo mysql -u root -p\r\n<\/pre>\n<p>Enter the root password you set during the MySQL installation. Once you&#8217;re in the MySQL shell, run the following commands to create a database and user:<\/p>\n<pre>\r\nCREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;\r\nGRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'password';\r\nFLUSH PRIVILEGES;\r\nEXIT;\r\n<\/pre>\n<p>Replace &#8220;wordpress&#8221; with the name you want to use for your database, &#8220;wordpressuser&#8221; with the username you want to use, and &#8220;password&#8221; with a strong password.<\/p>\n<h2>Step 4: Install PHP<\/h2>\n<p>WordPress is written in PHP, so you need to install PHP and some PHP extensions. Ubuntu 18.04 includes PHP in its default repositories, so it can be installed using the apt package manager. Run the following command to install PHP and necessary extensions:<\/p>\n<pre>\r\nsudo apt install php-fpm php-mysql php-curl php-gd php-intl php-mbstring php-soap php-xml php-xmlrpc php-zip\r\n<\/pre>\n<h2>Step 5: Configure Nginx to Serve WordPress<\/h2>\n<p>Next, you need to configure Nginx to serve your WordPress site. First, navigate to the Nginx sites-available directory:<\/p>\n<pre>\r\ncd \/etc\/nginx\/sites-available\/\r\n<\/pre>\n<p>Then, create a new configuration file for your WordPress site:<\/p>\n<pre>\r\nsudo nano wordpress\r\n<\/pre>\n<p>In the file, paste the following configuration:<\/p>\n<pre>\r\nserver {\r\n    listen 80;\r\n    server_name your_domain;\r\n    root \/var\/www\/html\/wordpress;\r\n    index index.php index.html index.htm;\r\n\r\n    location \/ {\r\n        try_files $uri $uri\/ \/index.php?$args;\r\n    }\r\n\r\n    location ~ \\.php$ {\r\n        include snippets\/fastcgi-php.conf;\r\n        fastcgi_pass unix:\/var\/run\/php\/php7.2-fpm.sock;\r\n    }\r\n\r\n    location ~ \/\\.ht {\r\n        deny all;\r\n    }\r\n}\r\n<\/pre>\n<p>Replace &#8220;your_domain&#8221; with your domain name. Save and close the file.<\/p>\n<p>Next, create a symbolic link to this file in the sites-enabled directory:<\/p>\n<pre>\r\nsudo ln -s \/etc\/nginx\/sites-available\/wordpress \/etc\/nginx\/sites-enabled\/\r\n<\/pre>\n<p>Then, test the Nginx configuration to make sure there are no syntax errors:<\/p>\n<pre>\r\nsudo nginx -t\r\n<\/pre>\n<p>If the test is successful, restart Nginx to apply the changes:<\/p>\n<pre>\r\nsudo systemctl restart nginx\r\n<\/pre>\n<h2>Step 6: Download and Install WordPress<\/h2>\n<p>Now, you&#8217;re ready to download and install WordPress. First, navigate to the \/tmp directory and download the latest WordPress package:<\/p>\n<pre>\r\ncd \/tmp\r\ncurl -LO https:\/\/wordpress.org\/latest.tar.gz\r\n<\/pre>\n<p>Then, extract the package and move the WordPress files to your web root directory:<\/p>\n<pre>\r\ntar xzvf latest.tar.gz\r\nsudo cp -a \/tmp\/wordpress\/. \/var\/www\/html\/wordpress\r\n<\/pre>\n<p>Next, set the correct permissions for the WordPress directory:<\/p>\n<pre>\r\nsudo chown -R www-data:www-data \/var\/www\/html\/wordpress\r\nsudo chmod -R 755 \/var\/www\/html\/wordpress\r\n<\/pre>\n<h2>Step 7: Complete the WordPress Installation Through the Web Interface<\/h2>\n<p>Finally, you can complete the WordPress installation through the web interface. Open your web browser and navigate to your domain:<\/p>\n<pre>\r\nhttp:\/\/your_domain\r\n<\/pre>\n<p>You will be greeted by the WordPress installation wizard. Follow the prompts, enter the database information you created earlier, and complete the installation.<\/p>\n<p>Congratulations! You have successfully installed WordPress on Ubuntu 18.04 with Nginx!<\/p>\n<h2>Commands Mentioned:<\/h2>\n<ul>\n<li><span class=\"fw-bold\">sudo apt update<\/span> \u2013 Updates the list of available packages and their versions.<\/li>\n<li><span class=\"fw-bold\">sudo apt upgrade<\/span> \u2013 Installs newer versions of the packages you have.<\/li>\n<li><span class=\"fw-bold\">sudo apt install<\/span> \u2013 Installs a package.<\/li>\n<li><span class=\"fw-bold\">sudo mysql_secure_installation<\/span> \u2013 Improves the security of your MySQL installation.<\/li>\n<li><span class=\"fw-bold\">CREATE DATABASE<\/span> \u2013 Creates a new MySQL database.<\/li>\n<li><span class=\"fw-bold\">GRANT ALL<\/span> \u2013 Gives a MySQL user full permissions on a database.<\/li>\n<li><span class=\"fw-bold\">FLUSH PRIVILEGES<\/span> \u2013 Reloads the grant tables in the MySQL database, enabling changes to take effect.<\/li>\n<li><span class=\"fw-bold\">EXIT<\/span> \u2013 Exits the MySQL shell.<\/li>\n<li><span class=\"fw-bold\">sudonano<\/span> \u2013 Opens a file in the nano text editor.<\/li>\n<li><span class=\"fw-bold\">sudo ln -s<\/span> \u2013 Creates a symbolic link to a file.<\/li>\n<li><span class=\"fw-bold\">sudo nginx -t<\/span> \u2013 Tests the Nginx configuration for syntax errors.<\/li>\n<li><span class=\"fw-bold\">sudo systemctl restart nginx<\/span> \u2013 Restarts the Nginx service.<\/li>\n<li><span class=\"fw-bold\">curl -LO<\/span> \u2013 Downloads a file from a URL.<\/li>\n<li><span class=\"fw-bold\">tar xzvf<\/span> \u2013 Extracts a tar.gz file.<\/li>\n<li><span class=\"fw-bold\">sudo cp -a<\/span> \u2013 Copies files and directories.<\/li>\n<li><span class=\"fw-bold\">sudo chown -R<\/span> \u2013 Changes the owner of a file or directory.<\/li>\n<li><span class=\"fw-bold\">sudo chmod -R<\/span> \u2013 Changes the permissions of a file or directory.<\/li>\n<\/ul>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Why do I need to use Nginx with WordPress?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Nginx is known for its high performance, stability, and low resource consumption. It can handle a large number of concurrent connections, making it a good choice for high-traffic WordPress sites.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the role of MySQL in a WordPress installation?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">MySQL is a database management system. WordPress uses MySQL to store all its data, including your website content, user profiles, and customizations.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Why do I need to update my system packages before installing WordPress?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Updating your system packages ensures that you have the latest security patches and bug fixes. This can help protect your server from vulnerabilities and improve its performance.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the purpose of the sudo command?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The sudo command allows you to run commands with the security privileges of another user, by default the superuser. It&#8217;s used when performing operations that require higher privileges, such as installing software or changing system configurations.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What is the role of PHP in a WordPress installation?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">WordPress is written in PHP, a popular scripting language for web development. PHP is used to generate dynamic page content, work with databases, handle cookies, and manage sessions, among other tasks. Without PHP, WordPress would not be able to function.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p>Installing WordPress on Ubuntu 18.04 involves several steps, but the process is straightforward when you follow them in order. This tutorial has guided you through updating your system, installing MySQL and PHP, creating a MySQL database and user for WordPress, configuring Nginx to serve your WordPress site, downloading and installing WordPress, and finally completing the WordPress installation through the web interface.<\/p>\n<p>By following these steps, you can set up a robust and high-performance WordPress site on your own server. This gives you full control over your site and allows you to customize it to your needs. Whether you&#8217;re setting up a personal blog, a business website, or an e-commerce store, WordPress is a versatile and powerful tool that can help you create the perfect site.<\/p>\n<p>Remember, maintaining a website involves more than just setting it up. You need to keep your server and WordPress installation updated, monitor your site&#8217;s performance, and ensure it&#8217;s secure.<\/p>\n<p>Hope this guide has been helpful in setting up your WordPress site.<\/p>\n<p>Happy web hosting!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress is a popular content management system that allows you to create and manage your own website with ease. It&#8217;s a flexible and powerful tool that can be used for&#8230;<\/p>\n","protected":false},"author":6,"featured_media":16013,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[1014,1073],"tags":[1605,1856,2074,1933],"class_list":["post-16012","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nginx","category-ubuntu","tag-nginx","tag-ubuntu","tag-ubuntu-18-04","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/16012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=16012"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/16012\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/16013"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=16012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=16012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=16012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}