WordPress website<\/a>. Run this command below to install PHP 8.1 and its required extensions.<\/p>\n# apt install php-{curl,fpm,imagick,mbstring,mysql,xml,zip}<\/pre>\nOnce completed, the PHP-FPM service will be running automatically. We are not going to edit the PHP-FPM configuration. We will use the default PHP-FPM www.conf file. To ensure PHP-FPM is running, you can verify it with this command:<\/p>\n
# systemctl status php8.1-fpm<\/pre>\n<\/span>Step 5: Install and Configure Web Server<\/span><\/h2>\nNginx is a fast and secure web server and one of the most popular and widely used web servers in the world. To install the Nginx web server on Ubuntu 22.04 run the following command:<\/p>\n
# apt install nginx<\/pre>\nNext, let’s create a new nginx server block for our WordPress website.<\/p>\n
# nano \/etc\/nginx\/conf.d\/wprdpress.conf<\/pre>\nPaste the following into the new file.<\/p>\n
upstream php-handler {\r\nserver unix:\/run\/php\/php8.1-fpm.sock;\r\n}\r\n\r\nserver {\r\nlisten 80;\r\nserver_name wordpress.example.com;\r\nreturn 301 https:\/\/$server_name$request_uri;\r\n}\r\n\r\nserver {\r\nlisten 443 ssl http2;\r\nserver_name wordpress.example.com;\r\n\r\n# Path to the root of your installation\r\nroot \/var\/www\/wordpress;\r\nindex index.php;\r\n\r\nssl_certificate \/etc\/letsencrypt\/live\/wordpress.example.com\/fullchain.pem;\r\nssl_certificate_key \/etc\/letsencrypt\/live\/wordpress.example.com\/privkey.pem;\r\n\r\n# Prevent nginx HTTP Server Detection\r\nserver_tokens off;\r\n\r\naccess_log \/var\/log\/nginx\/wordpress_access.log;\r\nerror_log \/var\/log\/nginx\/wordpress_error.log;\r\n\r\nclient_max_body_size 64M;\r\n\r\nlocation \/ {\r\ntry_files $uri $uri\/ \/index.php?$args;\r\n}\r\n\r\nlocation ~ \\.php$ {\r\ntry_files $uri =404;\r\ninclude \/etc\/nginx\/fastcgi_params;\r\nfastcgi_read_timeout 3600s;\r\nfastcgi_buffer_size 128k;\r\nfastcgi_buffers 4 128k;\r\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\nfastcgi_pass php-handler;\r\nfastcgi_index index.php;\r\n}\r\n\r\n}<\/pre>\nMake sure to replace wordpress.example.com with your actual domain or subdomain name. Save and close the file.<\/p>\n