How to Install Joomla with Nginx Support on Ubuntu

upgrading virtualbox host

This brief tutorial shows students and new users how to easily install Joomla content management system on Ubuntu server with Nginx support. This setup is going to require Ubuntu Linux, Nginx webserver, MySQL and PHP aka LEMP stack.

LEMP is an acronym for Linux, Engine-X (Nginx), MySQL and PHP. Other configurations use the LAMP stack, but we’re replacing the A in the LAMP stack with Nginx webserver.

For those who don’t know what Joomla is, it’s a popular CMS similar to WordPress. It’s based on the LAMP or LEMP stack. One can use Joomla to run and manage professional websites and blogs.

To install Joomla, follow the guide below:

Step 1: Install the LEMP Stack on Ubuntu

Before installing Joomla, you first task will be to install the LEMP stack. The stack is required for Joomla to function. To install it on Ubuntu server, read the post below:

Step 2: Create Joomla Database and User

Now that LEMP is installed, you next task will be to configure Joomla database and user. The database is used to store Joomla’s content and the user is used to access the content stored in the database.

To create the database and user, follow the steps below:

Run the commands below to logon to the database server

mysql -u root -p

Then run the commands below to create a new database called joomladb.


After creating the database, run the commands below to create a new user called joomlauser and set the user password.

GRANT ALL ON joomladb.* TO 'joomlauser'@'localhost' IDENTIFIED BY 'new_password_here';

After creating the user with a new password, run the commands below to save the changes to disk.


Finally, run the commands below to exit


Step 3: Download Joomla content

Now that the database and user are creating, the next task is to download Joomla content. At the time of this post, the latest version was at 3.6.5. So before downloading Joomla, adjust the version number accordingly.

Run the commands below to download Joomla

cd /tmp && wget

After downloading Joomla, run the commands below to extract the downloaded content to Nginx default root directory in /var/www/html.

sudo unzip -q Joomla*.zip -d /var/www/html

Then run the commands below to adjust the directory permission so Joomla can function properly.

sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

Don’t forget to delete Nginx default default index.html and index.nginx.debian.html files. They can create problems for new users.

sudo rm /var/www/html/index.html
sudo rm /var/www/html/index.nginx-debian.html

Step 4: Configure Nginx server

Since we want Nginx as our default webserver, let’s stop and disable Apache2 webserver so it doesn’t conflict with Nginx.

sudo systemctl stop apache2.service
sudo systemctl disable apache2.service

When Apache2 is disabled, open Nginx default site configuration file and add the below highlighted changes.

sudo nano /etc/nginx/sites-available/default

# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.

# Default server configuration
server {
	listen 80 default_server;
	listen [::]:80 default_server;

	# SSL configuration
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	# Note: You should disable gzip for SSL traffic.
	# See:
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See:
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	# include snippets/snakeoil.conf;

	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.php index.html index.htm index.nginx-debian.html;

	server_name _;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		#try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php?$args;

        # deny running scripts inside writable directories
        location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
                return 403;
                error_page 403 /403_error.html;

	# pass the PHP scripts to FastCGI server listening on
	location ~ \.php$ {
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
		include snippets/fastcgi-php.conf;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#location ~ /\.ht {
	#	deny all;

# Virtual Host configuration for
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#server {
#	listen 80;
#	listen [::]:80;
#	server_name;
#	root /var/www/;
#	index index.html;
#	location / {
#		try_files $uri $uri/ =404;
#	}

Save your changes and restart Nginx.

sudo nginx -t
sudo systemctl restart nginx.service

Step 5: Setting up Joomla

At this stage, if everything is setting up correctly, you should just open your browser and browse to the server hostname or IP address to setup Joomla. When you do that, you’ll see Joomla default setup page.

On the first page, enter the website name and create an administrator username and password, then click next.

joomla ubuntu install page

On the next, page, type the database connection information. The database and database user name with password. The one you created earlier and click nginx.

joomla database setup page

Verify all pre-installation checks are ok and everything looks good. When ready, click Install.

install joomla on ubuntu server

Finally, click the button to remove the installation folder.

remove joomla installation folder

That’s it! You should be able to access the administrator dashboard manage the site. Hope you like it and place come back soon.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.