# Setup WordPress on Ubuntu Server
Login to web server as user root using SSH (putty/terminal). Then install following software.
#### install Nginx
apt-get -y install nginx
#### install PHP
add-apt-repository ppa:ondrej/php
apt update
apt -y upgrade
apt -y install php7.4-cli php7.4-curl php7.4-gd php7.4-mysql php7.4-imagick php7.4-imap php7.4-json
apt -y install php7.4-xml php7.4-mbstring php7.4-zip php7.4-xmlrpc php7.4-soap php7.4-intl php7.4-bcmath
apt install -y php7.4-fpm
systemctl enable php7.4-fpm
systemctl restart php7.4-fpm
#### install MySQL
apt-get -y install mariadb-client mariadb-server
#### Create MySQL database
Login to MySQL command promt with
mysql
run following command in MySQL promt to create a DB/USER/PASSWORD.
create database DB_NAME;
grant all on DB_NAME.* to 'USERNAME'@'localhost' identified by 'MYSQL_PASSWORD';
You will need these DB_NAME, USERNAME and MYSQL_PASSWORD during wordpress install.
#### Setup Nginx
Create file
`/etc/nginx/sites-enabled/YOUR_DOMAIN.conf`
with following content
```
server {
listen 80;
server_name YOUR_DOMAIN www.YOUR_DOMAIN;
root /var/www/html/;
index index.php index.html index.htm;
location ~ \.(mp4|mp3)$ {
valid_referers YOUR_DOMAIN www.YOUR_DOMAIN;
if ($invalid_referer) {
return 403;
}
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_intercept_errors on;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}
```
In above code, replace YOUR_DOMAIN with your actual domain name.
Restart nginx
`systemctl restart nginx`
#### Point domain to server
You need to edit DNS record for your domain, point domain to server IP.
#### Install WordPress
Download WordPress from
https://wordpress.org/download/
Exact it and upload it to /var/www/html folder in web server.
You can upload files using FileZilla or another SFTP software.
Once files are uploaded, login to server using SSH and set proper permission for files with
`chown -R www-data:www-data /var/www/html`
Now you can visit the web site and finish the installation. Install wizzard will ask for MySQL login details (you created it in previous step) and select a admin user and password.