This guide walks you through the process of installing XenForo 2, a popular community forum software, on Ubuntu 22.04. Before proceeding, ensure you have a LEMP (Linux, Nginx, MySQL, PHP) stack installed. If you haven’t set up a LEMP stack yet, refer to my previous post on LEMP stack on Ubuntu 22.04.
Prerequisites #
- A server running Ubuntu 22.04
- A LEMP stack installed
- Access to a terminal or command-line interface
- Basic knowledge of Linux and MySQL
Step 1: Update Your System #
Start by updating your system to ensure all existing packages are up to date:
sudo apt update
sudo apt upgrade
Step 2: Install Required PHP Extensions #
XenForo 2 requires certain PHP extensions to function properly. Install the necessary extensions using the following commands:
sudo apt install php-mysqli php-gd php-json php-curl php-xml php-zip -y
This will install the MySQLi, GD (with JPEG support), cURL, and XML handling (DOM and SimpleXML) PHP extensions.
Note: The extensions PCRE
, SPL
, iconv
, and ctype
are usually included in the standard PHP installation.
Step 3: Download XenForo 2 #
- Purchase and download the latest version of XenForo 2 from the official XenForo website.
- Upload the downloaded ZIP file to your server.
- Unzip the XenForo files in your desired directory, for example,
/var/www/html/
Uploading the ZIP File to Your Server #
To upload the ZIP file, you can use an SFTP client like FileZilla, or the scp
command from the command line for Unix-based systems or Windows Subsystem for Linux (WSL).
Using FileZilla (Windows/Mac/Linux): #
- Download and install FileZilla from the official FileZilla website.
- Connect to your server using the server’s IP address, SSH username, and password (or SSH key).
- Navigate to the local directory where the XenForo ZIP file is located.
- Drag and drop the file into the desired directory on your server.
Using scp
(Unix-based/WSL): #
- Open a terminal on your local machine.
- Navigate to the directory where the XenForo ZIP file is located.
- Use the
scp
command to transfer the file to your server:
scp path/to/xenforo.zip username@your_server_ip:/path/to/server/directory
Replace path/to/xenforo.zip
with the path to your XenForo ZIP file, username
with your SSH username, your_server_ip
with your server’s IP address, and /path/to/server/directory
with the directory on your server where you want to upload the file.
Unzipping the XenForo Files #
After uploading the ZIP file to your server, you need to unzip it in your desired directory. Here’s how:
- SSH into your server:
ssh username@your_server_ip
- Navigate to the directory where you uploaded the XenForo ZIP file.
- Use the
unzip
command to extract the files. Ifunzip
is not installed, you can install it usingsudo apt install unzip
.
sudo apt install unzip
unzip xenforo.zip -d /var/www/html
Replace xenforo.zip
with the name of your ZIP file and /var/www/html
with your desired directory.
Setting Correct Permissions #
After unzipping, you should set the correct permissions for the XenForo directory:
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
This sets the owner to www-data (the default web server user on Ubuntu) and sets the appropriate permissions for the files and directories.
Step 4: Create a MySQL Database #
XenForo requires a database to store its data. Create a MySQL database and user for XenForo:
login to MySQL:
sudo mysql
Create a database and user:
CREATE DATABASE xenforo_db;
CREATE USER 'xenforo_user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON xenforo_db.* TO 'xenforo_user'@'localhost';
FLUSH PRIVILEGES;
exit
Remember to replace xenforo_db
, xenforo_user
, and password
with your preferred database name, username, and password.
Step 5: Configure DNS Records #
Before installing the SSL certificate, configure the DNS records with your domain registrar:
A Record: This points your domain to your server’s IP address.
- Name:
@
- Type:
A
- Value:
Your_Server_IP
- TTL:
3600
or as per your registrar’s default setting
- Name:
CNAME Record: This is for the 'www' version of your domain.
- Name:
www
- Type:
CNAME
- Value:
example.com
(Replace with your domain) - TTL:
3600
or as per your registrar’s default setting
- Name:
Replace Your_Server_IP
with the IP address of your server and example.com
with your actual domain name.
Wait for the DNS changes to propagate, which can take anywhere from a few minutes to 48 hours.
Step 6: Configure Nginx for XenForo #
Create a new Nginx server block or edit an existing one for your XenForo site:
sudo nano /etc/nginx/sites-available/xenforo
Add the following configuration:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com; # Replace with your domain name
root /var/www/html; # Replace with your XenForo directory
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$uri&$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Change to match your PHP version
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Remember to replace example.com and /var/www/html with your actual domain name and XenForo directory.
Adjust Maximum File Upload Size in Nginx #
To allow file uploads of up to 1 GB, you need to increase the client_max_body_size
in Nginx:
- Open your Nginx configuration file:
sudo nano /etc/nginx/nginx.conf
or your specific site configuration:
sudo nano /etc/nginx/sites-available/xenforo
- Add or modify the
client_max_body_size
directive:
http {
...
client_max_body_size 1024M;
...
}
- Save and close the file.
- Test the Nginx configuration for errors:
sudo nginx -t
This will allow your Nginx server to handle file uploads up to 1 GB.
Enable the Nginx Configuration #
Enable your Nginx configuration and restart Nginx:
sudo ln -s /etc/nginx/sites-available/xenforo /etc/nginx/sites-enabled/
sudo systemctl restart nginx
Step 7: Install Let’s Encrypt SSL Certificate #
Use Certbot to install a free SSL certificate from Let’s Encrypt:
- Install Certbot and its Nginx plugin:
sudo apt install certbot python3-certbot-nginx -y
- Obtain and install the SSL certificate:
sudo certbot --nginx -d example.com -d www.example.com
Replace example.com and www.example.com with your domain name.
- Certbot will modify your Nginx configuration to use the SSL certificate and set up automatic renewal.
Verify SSL Configuration #
After configuring SSL, it’s a good idea to test your SSL configuration:
- Visit your website using
https://example.com
and ensure that it loads correctly. - You can also use online tools like SSL Labs’ SSL Test to check your SSL certificate and configuration.
Step 8: Final Steps and Testing #
- Restart Nginx: Ensure all your configurations are correctly loaded:
sudo systemctl restart nginx
Test Your Site: Now, navigate to your website using your domain name. You should be able to access XenForo through a secure HTTPS connection.
XenForo Setup: Complete the XenForo installation by following the on-screen instructions when you first visit your forum’s URL.
sudo nano /var/www/html/src/config.php
and enter $config['enableAddOnArchiveInstaller'] = true;
there.
Conclusion #
You have now successfully set up XenForo 2 on Ubuntu 22.04 with a secure SSL certificate from Let’s Encrypt. Your forum is now accessible via HTTPS, and your SSL certificate will automatically renew.