$ curl -L -O http://wordpress.org/latest.tar.gz
$ tar xf latest.tar.gz
$ mv wordpress/* /var/www/html/domain
$ nano /etc/nginx/sites-available/domain.conf
server {
listen 80;
server_name domain.com;
root /var/www/html/domain;
index index.php index.html;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ =404;
}
location ~* \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
include snippets/fastcgi-php.conf;
}
}
$ ln -s /etc/nginx/sites-available/domain.conf /etc/nginx/sites-enabled/
$ sudo nginx -t
$ systemctl restart nginx
$ cp /var/www/html/domain/wp-config-sample.php /var/www/html/domain/wp-config.php
$ nano /var/www/html/domain/wp-config.php
Insert db name, passwd, localhost
$ chown -R www-data:www-data /var/www/html/domain
$ chmod -R 755 /var/www/html/domain
$ sudo rm /etc/nginx/sites-enabled/default
$ sudo rm /etc/nginx/sites-available/default
$ sudo nginx -t
http://domain1.com
=OR==
$ wget -O /tmp/wordpress.tar.gz https://wordpress.org/latest.tar.gz
$ tar -xzvf /tmp/wordpress.tar.gz -C /var/www/html
$ chown -R www-data:www-data /var/www/html/wordpress
$ chmod -R 755 /var/www/html/wordpress
Create a Virtual Host (Server Blocks) for WordPress website on the Nginx server.
$ nano /etc/nginx/conf.d/wordpress.conf
Add the content to file.
server {
listen 80;
listen [::]:80;
server_name website1.com;
root /var/www/html/wordpress;
index index.php index.html index.htm;
error_log /var/log/nginx/wordpress_error.log;
access_log /var/log/nginx/wordpres_access.log;
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
$ sudo nginx -t
$ systemctl restart nginx