Fast install wordpress in LNMP

Step 1:
create mysql database “sky” and mysql user “skyer” in Mysql, please modify the name of database & user and the password of the user

CREATE DATABASE sky ;
CREATE USER 'skyer'@'localhost' IDENTIFIED BY '1@2#3&5';
GRANT ALL PRIVILEGES ON sky.* TO 'skyer'@'localhost';
FLUSH PRIVILEGES;

Step 2:
Set up the root directory of your target website in server, such as “myland.com” (directory has more than 1 routine, as your will), then download wordpress.zip and

mkdir /home/wwwroot/myland.com;
cd /home/wwwroot/myland.com;
wget -O w.zip https://wordpress.org/latest.zip && unzip w.zip && cd wordpress/ && mv * ../ && cd .. && rm -rf wordpress && rm -rf w.zip && mv wp-config-sample.php wp-config.php;

Step 3.1:
create nginx.conf file for your website ( e.g.: myland.com.conf ) as below (e.g.: file path–/home/wwwroot/conf/nginx):

mkdir /home/wwwroot/conf/nginx;
cd /home/wwwroot/conf/nginx/;
vim myland.com.conf;

Step 3.2:
paste the following content to the myland.com.conf file then save and quit.
Note: please modify the “myload

server {
    listen 80;
    listen [::]:80;

    root /home/wwwroot/myland.com;
    index index.php index.html index.htm;
    server_name myland.com;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
        add_header X-Content-Type-Options "nosniff";
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
    }

    location ~* \.(css|js|jpg|jpeg|png|gif|ico)$ {
        expires 7d;
        add_header Cache-Control "public, max-age=604800";
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        log_not_found off;
        access_log off;
        allow all;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    }
}

Step 4.1:
modify the “wp_config” in /home/wwwroot/myland.com/ with the database, user, password which were created in step 1.

cd /home/wwwroot/myland.com ;
vim wp_config;

Step 4.2:
2 several optional steps as bellow
1). modify “utf8” to “utf8mb4”
2). if you have more than 1 domain running on the same LNMP server and want to utilize the “memcached” components (including those of Server & Php extension ), it strongly recommend modify the “wp_” to other vaule, such as “land_”, the purpose is to avoid conflicts between different domains.

Step 4.3:
open or refresh this website (https://api.wordpress.org/secret-key/1.1/salt/ ) to gain the following contents and paste into the file “wp-config” to replace the original blank ones, then save and exit this file.

define('AUTH_KEY',         'wf|AEecd~K.?x8KVbb#pc)P!xdQLk)@N<pH!8:}0`A]nRLr *O!s^Q(O?;tX9 ZW');
define('SECURE_AUTH_KEY',  'Z:|1Jt|S<x4)*@jo(Xt*65izr;~l }BcoP78}N)kNIjQtOQ<:%k@!Hi rFB#z77c');
define('LOGGED_IN_KEY',    'rNMnk]V&d9S@NWM6RLpduq6yuq DW{]<<WR{KN,S(`Pe|te:WX{z?h^Y8Y uyyT!');
define('NONCE_KEY',        ',=f]eEDmaDh2-1/5u5>J9.&vx)t2y>arMQBjE{M6--L-Ylkp.Q6hujItkiF<Tk@F');
define('AUTH_SALT',        '[Tj@J#L5S-(v!4s)xCwr.=u}?}fvCbcDctEUU&P>4` Tba1yyqBC4{CUJR-:UfA#');
define('SECURE_AUTH_SALT', '&d|OGc#,V032;MbQs:?Mwj6{)>Tyz[[`4QvBP&:+$-o!p}!1G2yg5,WJ!Ll)+7NQ');
define('LOGGED_IN_SALT',   'YWnK:]<az5Lc*GE:|%,A^_|0>[}|:QW*[zoX.g!s<- Xz~Lv?<+5vtDT4g9_nms,');
define('NONCE_SALT',       'cT/~r/;{VNa|-)/d JCVN}Gb[.|!/Md`Dosf$(O=lHI+{JaO`tXn%Av2Q<ag~Q3V');

Step 5:
create soft link to your .conf file and enable it as bellow:

sudo ln -s /etc/nginx/sites-available/myland.com.conf /etc/nginx/sites-enabled/

Step 6:
generate SSL certificate to your domain with Certbot or ACME.

certbot -d myland.com --nginx -v

SSL certificate information will be deployed to myland.com.conf automatically, such as bellow:

server {
    if ($host = myland.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    listen [::]:80;
    server_name enote.one;
    return 404; # managed by Certbot
}

server {
    root /home/wwwroot/myland.com;
    index index.php index.html index.htm;
    server_name myland.com;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
        add_header X-Content-Type-Options "nosniff";
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-XSS-Protection "1; mode=block";
    }

    location ~* \.(css|js|jpg|jpeg|png|gif|ico)$ {
        expires 30d;
        add_header Cache-Control "public, max-age=604800";
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        log_not_found off;
        access_log off;
        allow all;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/myland.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/myland.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/nginx/acme/ssl-dhparams.pem; # managed by Certbot

}

Step 7:
Grant “www” privileges to the domain directory and reload nginx service in LNMP as below:

chown -R www-data:www-data /home/wwwroot/myland.com ;
sudo systemctl restart nginx && systemctl status nginx ;

Step 8:
open https://myland.com in web browser to start the installation of WordPress.

Scroll to Top