sajad torkamani

Ensure server is properly configured and has required dependencies

Let’s assume you have a standard WordPress project that you want to deploy on an Ubuntu 20.04.3 server. Make sure you’ve configured your server and that it has any required dependencies. A typical set of dependencies might be as follows:

php^8.0.3Because WordPress is written in PHP.
php-fpmProvides FastCGI implementation (interface between Nginx and PHP)
PHP extensionscurl, dom, exif, fileinfo, hash, imagick, json, mbstring, mysql, openssl, pdo, pcre, xml, zip
ImageMagickRequired by imagick extension
GhostScriptEnables Imagick/ImageMagick to generate PDF thumbnails for the media library.
Nginx ^1.20To serve static files and process PHP files via php-fpm
MySQL^8.0.28WordPress website will use MySQL as database.
ComposerTo manage PHP dependencies.

Refer to the WordPress hosting handbook for more info on configuring the server environment.

For the purpose of this post, let’s assume you’ll be deploying the website on the domain

Document system requirements

Add a to your project root and list the dependencies mentioned above. It’s a good idea to specify PHP version and extensions in your composer.json file like so:

  "require": {
    "php": "^8.0.3",
    "ext-curl": "*",
    "ext-dom": "*",
    "ext-exif": "*",
    "ext-fileinfo": "*",
    "ext-hash": "*",
    "ext-imagick": "*",
    "ext-json": "*",
    "ext-mbstring": "*",
    "ext-pdo_mysql": "*",
    "ext-openssl": "*",
    "ext-pcre": "*",
    "ext-xml": "*",
    "ext-zip": "*"

Then, during local setup or on deployment, you can run the following command to ensure these requirements are met:

composer check-platform-reqs

Create Nginx config file

Create file:

touch etc/nginx/sites-available/

Set contents to:

server {
    listen 80;
    root /home/sajad/sites/sajadtorkamani;

    index index.php index.html;

    location / {
      try_files $uri $uri/ /index.php?$query_string;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock; # Change as needed
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

    location ~ /\.ht {
        deny all;

Notice the fastcgi_pass directive. It’s set to unix:var/run/php/php8.0-fpm.sock but you may need to change this depending on where your php-fpm socket is located.

Make sure the value you set for root is also valid and there is actually a project in that location.

Create symlink:

ln -s /etc/nginx/sites-available/  /etc/nginx/sites-enabled/

Test for syntax errors:

sudo nginx -t

Restart or reload Nginx:

sudo systemctl reload nginx

Configure DNS records

Make sure you’ve configured your DNS settings so that the domains and www.sajadtorkamani are pointing to your Ubuntu server’s IPv4 address. An A and CNAME record like the below should suffice:


You can use a service like to check whether your DNS records have propagated yet.

Clone local database on remote server

See this post.

Transfer media files to remote server

If you need to transfer media files to the remote server, see this post.

Tagged: WordPress