Script: Install Joomla 3.7 on a CentOS/Fedora VPS



In one of our previous posts, we explained how to install Joomla 3 on Ubuntu 14.04. Joomla is a Content Management System (CMS for short) – this is user-friendly software that allows you to build websites and manage the content on your websites easier than ever before.

In this tutorial, unlike the previous Joomla install guide, we wrote a script for you to help make the installation of Joomla 3.7 on a CentOS/Fedora VPS even faster and easier. This script will automatically do everything that should be done on your server, including the creation of a MySQL database while also creating an Apache virtual host for your Joomla website. All you need to do is to create a file on your server containing the script below, then simply execute the script and enter your details when prompted to.

(Note: You will need to have MySQL and Apache installed on your server in order for this script to work correctly.)

Create a file on your server with your favorite text editor and copy this script into your file:

# Install Joomla on a CentoOS/Fedora VPS

# Create MySQL database
read -p "Enter your MySQL root password: " rootpass
read -p "Database name: " dbname
read -p "Database username: " dbuser
read -p "Enter a password for user $dbuser: " userpass
mysql -uroot <<MYSQL_SCRIPT
delete from mysql.user
where user='$dbuser'
and host = 'localhost';
flush privileges;
CREATE USER [email protected];
GRANT ALL PRIVILEGES ON $dbname.* TO [email protected]ocalhost IDENTIFIED BY '$userpass';
echo "New MySQL database has been successfully created"
sleep 2

# Download, unpack and configure Joomla
read -r -p "Enter your Joomla URL? [e.g.]: " joomlaurl
mkdir -p /var/www/html/$joomlaurl && 
wget -P /var/www/html/$joomlaurl && 
cd /var/www/html/$joomlaurl
echo "Installing unzip package if necessary..." && yum -yq install unzip
sleep 3
unzip Joomla*.zip && rm -f Joomla_*.zip && 
chown apache: -R /var/www/html/$joomlaurl
killall httpd

# Create the Apache virtual host
echo "

<VirtualHost $(dig TXT +short | awk -F'"' '{ print $2}'):80>
 ServerName www.$joomlaurl
 DocumentRoot "/var/www/html/$joomlaurl"
 DirectoryIndex index.php
 Options FollowSymLinks
 ErrorLog logs/$joomlaurl-error_log
 CustomLog logs/$joomlaurl-access_log common

" >> /etc/httpd/conf/httpd.conf
service httpd restart

echo -en "aPlease go to http://www.$joomlaurl and finish the installationn"

#End of script

Make the script executable, then execute the script:

chmod +x <script name> && ./<script name>

(Replace <script name> with the name that you have given to your file)

After running the script, you will have successfully installed Joomla 3.7 on your CentOS or Fedora VPS! All that is left to do is to set up the remainder of Joomla at your web domain.