{"id":1460,"date":"2024-11-09T17:34:25","date_gmt":"2024-11-09T17:34:25","guid":{"rendered":"https:\/\/kb.lagonet.vn\/?p=1460"},"modified":"2024-11-09T17:34:25","modified_gmt":"2024-11-09T17:34:25","slug":"how-to-install-wordpress-on-ubuntu-22-04-with-lemp","status":"publish","type":"post","link":"https:\/\/kb.lagonet.vn\/?p=1460","title":{"rendered":"How to install WordPress on Ubuntu 22.04 with LEMP"},"content":{"rendered":"\n<p>Here is the detailed manual on how to install&nbsp;<strong>WordPress<\/strong>&nbsp;on&nbsp;<strong>Ubuntu 22.04<\/strong>&nbsp;with&nbsp;<strong>LEMP<\/strong>:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-1-update-the-operating-system\">Step 1: Update the Operating System<\/h2>\n\n\n\n<p>Before you start installing WordPress, it is important to make sure that your Ubuntu 22.04 operating system is up to date. Open the terminal and run the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get update\nsudo apt-get upgrade\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-2-install-nginx\">Step 2: Install Nginx<\/h2>\n\n\n\n<p>Nginx is a web server that will be used to host the WordPress website. Run the following command to install Nginx:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install nginx\n<\/code><\/pre>\n\n\n\n<p>Once the installation is complete, start the Nginx service with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start nginx\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-3-install-mysql\">Step 3: Install MySQL<\/h2>\n\n\n\n<p>MySQL is a database management system that will be used to store the data for the WordPress website. Run the following command to install MySQL:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install mysql-server\n<\/code><\/pre>\n\n\n\n<p>During installation, you will be prompted to set a password for the MySQL&nbsp;<code>root<\/code>&nbsp;user.<\/p>\n\n\n\n<p>Once the installation is complete, start the MySQL service with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start mysql\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-4-install-php\">Step 4: Install PHP<\/h2>\n\n\n\n<p>PHP is a programming language used to execute code on the web server. Run the following command to install PHP and the necessary modules:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install php-fpm php-mysql\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-5-configure-nginx\">Step 5: Configure Nginx<\/h2>\n\n\n\n<p>Now that the necessary components have been installed, it is time to configure Nginx to host the WordPress website. Open the default Nginx configuration file with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/nginx\/sites-available\/default\n<\/code><\/pre>\n\n\n\n<p>Inside the file, find the section starting with&nbsp;<code>server {<\/code>&nbsp;and replace its contents with the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen 80;\n    listen &#91;::]:80;\n    root \/var\/www\/html;\n    index index.php index.html index.htm;\n    server_name example.com www.example.com;\n\n    location \/ {\n        try_files $uri $uri\/ \/index.php?$args;\n    }\n\n    location ~ \\.php$ {\n        include snippets\/fastcgi-php.conf;\n        fastcgi_pass unix:\/var\/run\/php\/php8.1-fpm.sock;\n    }\n\n    location ~ \/\\.ht {\n        deny all;\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>Remember to replace&nbsp;<code>example.com<\/code>&nbsp;and&nbsp;<code>www.example.com<\/code>&nbsp;with the domain name of your website.<\/p>\n\n\n\n<p>Save and close the configuration file.<\/p>\n\n\n\n<p>Check and reload the new nginx configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nginx -t\n\/etc\/init.d\/nginx reload\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-6-create-the-wordpress-database\">Step 6: Create the WordPress database<\/h2>\n\n\n\n<p>Create a MySQL database for WordPress with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql -u root -p\n<\/code><\/pre>\n\n\n\n<p>You will be prompted to enter the MySQL&nbsp;<code>root<\/code>&nbsp;user password. Once you are in the MySQL console, execute the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE DATABASE wordpress;\nCREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';\nGRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';\nFLUSH PRIVILEGES;\nexit;\n<\/code><\/pre>\n\n\n\n<p>Remember to replace&nbsp;<code>password<\/code>&nbsp;with a strong password.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-7-download-and-install-wordpress\">Step 7: Download and install WordPress<\/h2>\n\n\n\n<p>Download the latest version of WordPress with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/tmp\nwget https:\/\/wordpress.org\/latest.tar.gz\n<\/code><\/pre>\n\n\n\n<p>Unzip the downloaded file with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -zxvf latest.tar.gz\n<\/code><\/pre>\n\n\n\n<p>Copy the unzipped WordPress files to the root directory of the web server with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo cp -r \/tmp\/wordpress\/* \/var\/www\/html\n<\/code><\/pre>\n\n\n\n<p>Change the ownership of the root directory to the user&nbsp;<code>www-data<\/code>&nbsp;with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chown -R www-data:www-data \/var\/www\/html\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"step-8-configure-wordpress\">Step 8: Configure WordPress<\/h2>\n\n\n\n<p>Open your browser and access the website.<\/p>\n\n\n\n<p>Follow the WordPress installation, selecting first the language and, in the next tab, the data concerning the database. The database name, username, password and server.<\/p>\n\n\n\n<p>During the manual we have used the following data:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Database name: wordpress\nUser: wordpressuser\nPassword: password\n<\/code><\/pre>\n\n\n\n<p>As the server, you will need to enter &#8220;localhost&#8221;.<\/p>\n\n\n\n<p>Complete the WordPress configuration details and follow the instructions to set up your website.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>That&#8217;s it! You now have WordPress installed on Ubuntu 22.04 with LEMP.<\/p>\n<\/blockquote>\n\n\n\n<p>Source: <a href=\"https:\/\/www.swhosting.com\/en\/comunidad\/manual\/how-to-install-wordpress-on-ubuntu-2204-with-lemp\">https:\/\/www.swhosting.com\/en\/comunidad\/manual\/how-to-install-wordpress-on-ubuntu-2204-with-lemp<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here is the detailed manual on how to install&nbsp;WordPress&nbsp;on&nbsp;Ubuntu 22.04&nbsp;with&nbsp;LEMP: Step 1: Update the Operating System Before you start installing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1460","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/posts\/1460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1460"}],"version-history":[{"count":1,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/posts\/1460\/revisions"}],"predecessor-version":[{"id":1461,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=\/wp\/v2\/posts\/1460\/revisions\/1461"}],"wp:attachment":[{"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.lagonet.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}