Logo

dev-resources.site

for different kinds of informations.

Installing Wordpress with Nginx in Ubuntu

Published at
12/25/2024
Categories
wordpress
ubuntu
linux
nginx
Author
partha7278
Categories
4 categories in total
wordpress
open
ubuntu
open
linux
open
nginx
open
Author
10 person written this
partha7278
open
Installing Wordpress with Nginx in Ubuntu

To install WordPress with Nginx on Ubuntu, follow these steps:
1. Update your system

sudo apt update
Enter fullscreen mode Exit fullscreen mode

2. Install required module

sudo apt install php-fpm php-mysql mysql-server nginx unzip php-xml
Enter fullscreen mode Exit fullscreen mode

3. Setup mySql (Optional)
You can skip this if already done

4. Configuring Nginx to work with PHP

Goto nginx directory

cd /etc/nginx/sites-available
Enter fullscreen mode Exit fullscreen mode

Delete default (Optional)

sudo rm default
Enter fullscreen mode Exit fullscreen mode

Create Server Blocks for this Domain

sudo nano /etc/nginx/sites-available/domain1.com
Enter fullscreen mode Exit fullscreen mode

Identify php sock version by following command

ls /var/run/php
Enter fullscreen mode Exit fullscreen mode

Add the following content (adjust paths and domain names as needed and php sock version from above):

server {
    listen 80;
    server_name domain1.com www.domain1.com;

    root /var/www/html/domain1.com;
    index index.php index.html index.htm;

    ssl_certificate  /etc/ssl/domain1.com.pem;
    ssl_certificate_key  /etc/ssl/domain1.com.key;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;  # Adjust PHP version if necessary
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}
Enter fullscreen mode Exit fullscreen mode

Create symbolic links in the site-enabled directory

sudo ln -s /etc/nginx/sites-available/domain1.com /etc/nginx/sites-enabled/
Enter fullscreen mode Exit fullscreen mode

Test Nginx Configuration. Make sure the Nginx configuration is correct:

sudo nginx -t
Enter fullscreen mode Exit fullscreen mode

Restart Nginx

sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

5. Configuring Wordpress
Downloading Wordpress to the Ubuntu server

cd /var/www/html/domain1.com
sudo wget https://wordpress.org/latest.zip
Enter fullscreen mode Exit fullscreen mode

Extract the file to domain1.com

sudo unzip latest.zip
sudo mv wordpress/* .
Enter fullscreen mode Exit fullscreen mode

Remove unwanted files and folders

sudo rm latest.zip
sudo rm -R wordpress
Enter fullscreen mode Exit fullscreen mode

Changing the owner of the Wordpress files

sudo chown -R www-data:www-data *
Enter fullscreen mode Exit fullscreen mode

6. Databse details configure
Open domain1.com and fill all the details.
From next page copy it's contains and create new file with this in /var/www/html/domain1.com folder

sudo nano wp-config.php
Enter fullscreen mode Exit fullscreen mode

Now complete remaining setup vi domain1.com url

nginx Article's
30 articles in total
Favicon
nginx-mod-http-geoip
Favicon
How to run a Nginx-web server
Favicon
ngx whitelist/blacklist module
Favicon
Nginx Simplified: Technical Insights with Real-World Analogies
Favicon
Nginx Configuration Tips for Secure Communication: Enabling mTLS and checking client fingerprint
Favicon
Building a Scalable Reverse Proxy Server like Nginx with Node.js and TypeScript
Favicon
Deploy NestJS and NextJS application in same server using pm2 and Nginx
Favicon
Setting Up an NGINX Reverse Proxy with a Node.js Cluster Using Docker
Favicon
การทำ HTTPS ด้วย Certbot และ Nginx บน Ubuntu Server
Favicon
How to configure Free SSL Certificate on Nginx using Certbot
Favicon
Docker Hands-on: Learn Docker Volume and Bind Mounts with Sample Projects using NGINX
Favicon
自建的git远程仓库,在push时413 Request Entity Too Large
Favicon
Optimize SvelteKit performance with brotli compression
Favicon
I’m running a Spring Boot application inside a Docker container on my VM. The application works fine over HTTP, and I can access all endpoints via http://127.0.0.1:8080. I’ve set up NGINX as a reverse proxy to serve HTTPS requests. No errors for http reqs.
Favicon
Deploying a MERN App on Azure: The Smart Way
Favicon
My First Full-Stack Deployment with Docker and NGINX as Load Balancer
Favicon
Streamlined Release Process for a Web Application: Trunk-Based Development with Feature Flags
Favicon
How to Install NGINX on Ubuntu 22.04
Favicon
Secure Nginx with Let's Encrypt on Ubuntu
Favicon
Kubernetes Ingress Controllers and NGINX Ingress: A Complete Guide
Favicon
What is HTTP 499 Status Code and How to Fix it?
Favicon
Docker Compose Demo: Running Multiple Services with Two Domains on Localhost
Favicon
Building a Production Stack: Docker, Meilisearch, NGINX & NestJS
Favicon
Step-by-Step Guide: Assigning a Namecheap Domain to DigitalOcean Hosting with Nginx
Favicon
Streamlining React CI/CD Pipelines with GitHub Actions
Favicon
Connecting to an EC2 Instance with Ubuntu and Installing NGINX on AWS
Favicon
Installing Nginx Web Server on Linux: A Step-by-Step Guide
Favicon
Hosting multiple Websites on a single Nginx Server
Favicon
Unleashing the Power of NGINX as an API Gateway
Favicon
Installing Wordpress with Nginx in Ubuntu

Featured ones: