The article will guide you how to install WordPress on Ubuntu server with LEMP Stack installed. This is the last step in the series Installing WordPress on your Server, with PHP 8.4 and Cloudflare SSL.
Prior to this, you have learned how to:
Now you’re ready to download and install WordPress on your own server.
Download & Install WordPress
Connect to your server via SSH.
From the terminal, enter these commands in turn:
cd /tmp
curl -LO https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
sudo cp -a /tmp/wordpress/. /var/www/taihoang/wordpress
sudo chown -R www-data:www-data /var/www/taihoang/wordpress
Code language: Backus–Naur Form (bnf)
What they do:
- Create a temporary directory on the server.
- Download the latest version of WordPress and decompress it into that directory.
- Prepare the config file.
- Copy all WordPress directories and files into the main folder (
/var/www/taihoang/wordpress/
). Note that this path must matches the path that you configured earlier in Nginx (/var/www/taihoang/
), see this article.
Next, let’s generate the secret keys (WordPress Salts) to secure your WordPress application. Enter this command:
curl -s https://api.wordpress.org/secret-key/1.1/salt/
Code language: Bash (bash)
It will output values like this:
define('AUTH_KEY', ')n+L.XImPN$^0jw0.TQv|l,-q#:c5ZGYW6X:`=Bk8*k3)@,NhL^i6+gE$C/+f;mT');
define('SECURE_AUTH_KEY', 'Eh+<FV~y9,J;fsAB}fK=Zk:EpL/7aEd5c{j)}rZ43dF1,Xg*S^TTV(U1+`5Y-)HL');
define('LOGGED_IN_KEY', 'R0+81!aq%Jri_O%W4YI$}>z9sY,F*20`6@rzG5q_LZoY0C+{Ci(*G=Q ;+uCoL|V');
define('NONCE_KEY', 'BD>s:6wWqdKJl2ET+CL`dsvn{pJ}0*)5G%{3tg3jIN%UkI=tG*gn]:42Rqj32t@-');
define('AUTH_SALT', '):p.v1*;8]/z%*V:h-)8-r5Ucwx%bC7v>]+$W+vj[c>Ep!Zive&k{*G|MDw63!pu');
define('SECURE_AUTH_SALT', 'bG!+j>0kzG0nJZ~^FT{e(tBiy`+^vbSdOV#2vK06btCWZnbAHr3lIH+H|PI_}*7J');
define('LOGGED_IN_SALT', '8W/-~k?}P|2gZ)l|w+qg^7PRCt6/^q1`F/o6r~(J5f5C<q}[Pzi;wP GvlFLi)o-');
define('NONCE_SALT', 'N&gdLD?oQ@g_[WiA^+n|3YI>AKB-1/ER+E$Hmzy32+Hk{9h?]*]z:cJ*;/oUv=?*');
Code language: JavaScript (javascript)
You need to copy & paste those values into the corresponding postions in wp-config.php
file.
Note that you must copy the values that are generated for you by the curl
command above. DO NOT COPY the values in this article.
Let’s do this by opening the wp-config.php
file:
sudo nano /var/www/taihoang/wordpress/wp-config.php
Code language: Bash (bash)
Look for this section:
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
Code language: PHP (php)
Then paste the generated values from the curl
command to these positions.
Also in this wp-config.php
file, look for another section that defines the credentials:
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );
/** Database username */
define( 'DB_USER', 'username_here' );
/** Database password */
define( 'DB_PASSWORD', 'password_here' );
Code language: PHP (php)
Enter the database credentials exactly as you defined them in the previous article. For example:
define( 'DB_NAME', 'wordpress_database' );
define( 'DB_USER', 'db_admin' );
define( 'DB_PASSWORD', 'db_password' );
Code language: PHP (php)
Also in this file, add a new row above the line that says That's all, stop editing! Happy publishing
, like this:
define( 'FS_METHOD', 'direct' );
/* That's all, stop editing! Happy publishing. */
Code language: PHP (php)
Set up WordPress
Before going to the browser to set up your WordPress site, let’s make sure everything in the LEMP stack is running properly. Enter these commands to restart (and refresh) the components in the stack:
sudo systemctl restart nginx
sudo systemctl restart php8.4-fpm
sudo systemctl restart mariadb
Code language: Bash (bash)
If you ever get stuck in the terminal, try pressing q
to exit, or Ctrl + C
to return to the command line.
Then check their status too:
sudo systemctl status nginx
sudo systemctl status php8.4-fpm
sudo systemctl status mariadb
Code language: Bash (bash)
They must show as active (running)
.
Now you can visit your domain via the browser to begin the set up.
Done.