We recommend you follow this tutorial using a Cost-Optimized Instance.
Installing WordPress on a Scaleway Instance with Ubuntu 22.04 LTS (Jammy Jellyfish) and LEMP
- WordPress
- cms
- php
- LEMP
- nginx
- mysql
- mariadb
WordPress is a popular and freely accessible open-source tool that offers a seamless means to craft and manage content on your website. With its intuitive interface and user-friendly features, WordPress has garnered extensive adoption, making it an ideal solution for swiftly launching a website. The web front-end it provides ensures effortless administration, simplifying the process even for those lacking technical expertise.
If you are seeking to install WordPress on a newly established Ubuntu 22.04 LTS Instance, this tutorial is tailor-made for your needs. We will meticulously walk you through the installation steps, employing the LEMP stack (Linux + Nginx - pronounced “engine x” + MySQL + PHP). For the sake of this tutorial, we are choosing Nginx, a robust HTTP server that is efficient in resource usage, resulting in faster page delivery, especially for static content. By opting for a Cost-Optimized Instance configured with LEMP, you will gain access to a robust web server that elevates website performance, thus ensuring a seamless WordPress installation experience.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An SSH key
sudo
privileges or access to the root user- Installed LEMP
- An FQDN (Fully Qualified Domain Name) pointing to your Instance’s IP address
- Secured your LEMP stack with TLS/SSL
Installing WordPress
We assume that you have already installed LEMP stack. Let us proceed with the installation of WordPress on your Ubuntu Jammy Instance.
WordPress is equipped to serve dynamic content and manage user authentication and authorization with ease. However, to ensure a secure connection to your site, the implementation of Transport Layer Security/Secure Sockets Layer (TLS/SSL) technology is essential. By encrypting your traffic, TLS/SSL guarantees a secure connection to your site. To configure SSL with Let’s Encrypt and complete the last stage of the tutorial, follow the link: Configuring SSL with Let’s Encrypt.
Configuring Nginx
To prepare for the upcoming WordPress installation, it is essential to configure Nginx to handle traffic. In the LEMP tutorial, we previously set up a server block for example.com
, which served as the default Nginx page for our domain. Now, we will create a new server block called wordpress
that will serve our WordPress site from the subdomain blog.example.com
.
-
Create a new server block for Nginx:
nano /etc/nginx/sites-available/wordpress -
Paste the following configuration. Make sure to replace the configuration at the
server_name
line with your domain.server {listen 80;root /var/www/wordpress;index index.php index.html index.htm;server_name blog.example.com;location = /50x.html {root /usr/share/nginx/html;}location / {# try_files $uri $uri/ =404;try_files $uri $uri/ /index.php?q=$uri&$args;}location ~ \.php$ {try_files $uri =404;fastcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_pass unix:/run/php/php7.2-fpm.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}location = /favicon.ico {access_log off;log_not_found off;expires max;}location = /robots.txt {access_log off;log_not_found off;}# Cache Static Files For As Long As Possiblelocation ~*\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)${access_log off;log_not_found off;expires max;}# Security Settings For Better Privacy Deny Hidden Fileslocation ~ /\. {deny all;access_log off;log_not_found off;}# Return 403 Forbidden For readme.(txt|html) or license.(txt|html)if ($request_uri ~* "^.+(readme|license)\.(txt|html)$") {return 403;}# Disallow PHP In Upload Folderlocation /wp-content/uploads/ {location ~ \.php$ {deny all;}}} -
Test the configuration to ensure that it will function correctly:
nginx -tAn output similar to the following displays.
nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful -
Enable the server block by symlinking:
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress -
Delete the Nginx default server block:
rm /etc/nginx/sites-enabled/default -
Open the Nginx configuration file:
nano /etc/nginx/nginx.conf -
Edit the following elements:
- Update the number of worker processes to match the number of cores in your Instance to optimize your Nginx configuration.
user www-data;worker_processes 1;pid /run/nginx.pid;- Add
use epoll;
to the events block.
events {worker_connections 4096;multi_accept on;use epoll;}- Add the
client_max_body_size 100m;
andserver_tokens off;
directives, then setkeepalive_timeout
to 30 seconds as shown below.
# Basic Settingssendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 30;types_hash_max_size 2048;server_tokens off;client_max_body_size 100m;# server_names_hash_bucket_size 64;# server_name_in_redirect off;include /etc/nginx/mime.types;default_type application/octet-stream;- Make sure that the whole Gzip settings block is similar to the following.
# Gzip Settingsgzip on;gzip_disable "msie6";gzip_vary on;gzip_proxied any;gzip_comp_level 6;gzip_buffers 16 8k;gzip_http_version 1.1;gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; -
Restart the server:
service nginx restart
Configuring PHP
To enable the upload of files larger than 2 MB to your WordPress website, you must adjust the PHP upload size variables located in the php.ini file.
- Open the
php.ini
file:nano /etc/php/7.4/fpm/php.ini - Press
Ctrl+W
and search forupload_max_filesize
and set it to100M
. - Restart PHP:
sudo service php7.4-fpm restart
Setting up the MySQL database
In this section, we will create the database user and tables.
-
Log into the MySQL shell using your MySQL root password:
mysql -u root -p -
Create a WordPress database and name it as desired:
MariaDB [(none)]> CREATE DATABASE wordpress;The following output displays:
Query OK, 1 row affected (0.00 sec) -
Create a new user and name it as desired:
CREATE USER wordpressuser@localhost;The following output displays:
Query OK, 0 rows affected (0.00 sec) -
Set a password for the new user:
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");The following output displays:
Query OK, 0 rows affected (0.00 sec) -
Grant all privileges to the new user. Without this command, the WordPress installer will not be able to start up:
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';The following output displays:
Query OK, 0 rows affected (0.00 sec) -
Refresh MySQL:
FLUSH PRIVILEGES;The following output displays:
Query OK, 0 rows affected (0.00 sec) -
Exit the MySQL shell:
exit
Installing the WordPress Files
- Navigate to the site root directory:
cd /var/www/
- Download the latest version of WordPress:
wget http://wordpress.org/latest.tar.gz
- Extract it from the archive:
tar -xzvf latest.tar.gz
- Grant the
www-data
user permissions to/var/www/wordpress
to enable automatic updates of WordPress plugins and file editing with SFTP in the future.chown -R www-data:www-data wordpress/usermod -a -G www-data www-data
Completing the installation through the web interface
With the server configuration completed, you can now proceed to complete the installation via the web interface.
Open your preferred web browser and enter your Instances’s domain name or public IP address in the address bar:
http://instance_domain_or_IP/wordpress/
-
Select your language.
Before entering your database information, you need to return to the terminal to complete the following steps.
-
Open the WordPress configuration file from your terminal:
nano /var/www/wordpress/wp-config-sample.php -
Edit the information for your database under
MySQL settings
, to replace the default values with those you configured while setting it up. In our case, it looks like this:// ** MySQL settings - You can get this info from your web host ** ///** The name of the database for WordPress */define( 'DB_NAME', 'wordpress' );/** MySQL database username */define( 'DB_USER', 'wordpressuser' );/** MySQL database password */define( 'DB_PASSWORD', 'password' );/** MySQL hostname */define( 'DB_HOST', 'localhost' );/** Database charset to use in creating database tables. */define( 'DB_CHARSET', 'utf8' );/** The database collate type. Do not change this if in doubt. */define( 'DB_COLLATE', '' ); -
Save and exit the file, then return to your web browser.
-
Enter the database information for WordPress:
-
Complete the five-minute WordPress installation process.
-
Log in. Your dashboard displays.