| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/local/mojo/bin/ |
Upload File : |
#!/bin/bash
#
# Script: install_wordpress
#
# Usage: install_wordpress
#
# Description: A tool for installing WordPress
#
# Author: Nikita Shchetinin
#
# Changelog:
# * 12.04.2021: Nikita Shchetinin
# - Initial write
# * 30.07.2021: Nikita Shchetinin
# - Security fix
if [ "$(whoami)" != 'root' ]
then
echo "You must execute this script as the root user!"
exit 1
fi
INSTALL () {
if [ ! -f /usr/local/bin/wp ]
then
echo "WP CLI is not found. Starting its installation now..."
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
chmod +x /usr/local/bin/wp
fi
install_dir=$(pwd)
if [ -f $install_dir/wp-config.php ]
then
echo "The configuration file of WordPress already exists here!"
exit 1
fi
local_user=$(stat -c '%U' $install_dir)
if [ $local_user == 'root' ]
then
echo "The installation directory may not belong to the root user!"
exit 1
fi
read -p "Enter the domain name: " domain
while [ -z "$domain" ]
do
echo "The domain name is required!"
read -p "Enter the domain name: " domain
done
while [ $(grep -c -P '(?=^.{4,253}$)(^(?:[a-zA-Z0-9](?:(?:[a-zA-Z0-9\-]){0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$)' <<< $domain) != 1 ]
do
echo "The entered domain name is invalid!"
read -p "Enter the domain name: " domain
done
read -p "Enter the admin user's email address: " admin_email
while [ -z "$admin_email" ]
do
echo "The admin user's email address is required!"
read -p "Enter the admin user's email address: " admin_email
done
echo "Creating a database for WordPress..."
db_prefix=$(</dev/urandom tr -dc A-Za-z | head -c5)
db=$(mjact_mysql -D ${db_prefix}_wp)
db_name=$(echo $db | awk '{ print $5 }')
db_username=$(echo $db | awk '{ print $8 }')
db_password=$(echo $db | awk '{ print $12 }')
echo "Starting WordPress installation now..."
admin_user=$(</dev/urandom tr -dc A-Za-z | head -c5)
admin_password=$(</dev/urandom tr -dc A-Za-z0-9 | head -c16)
sudo -u $local_user /usr/local/bin/wp core download
sudo -u $local_user /usr/local/bin/wp config create --dbname=$db_name --dbuser=$db_username --dbpass=$db_password
sudo -u $local_user /usr/local/bin/wp core install --url=$domain --title=$domain --admin_user=$admin_user --admin_password=$admin_password --admin_email=$admin_email
sudo -u $local_user /usr/local/bin/wp plugin delete $(sudo -u $local_user /usr/local/bin/wp plugin list --status=inactive --field=name)
sudo -u $local_user /usr/local/bin/wp theme delete $(sudo -u $local_user /usr/local/bin/wp theme list --status=inactive --field=name)
sudo -u $local_user /usr/local/bin/wp plugin install wordfence
chgrp -R apache wp-content
add_wp_ftp
echo "WordPress has been installed on $domain"
echo "The admin panel is available on $domain/wp-admin"
echo "Admin email address: $admin_email"
echo "Admin user: $admin_user"
echo "Admin password: $admin_password"
tput setaf 1
echo "You MUST log in to the admin panel of WordPress and complete Wordfence installation now!"
tput init
}
HELP () {
echo "A tool for installing WordPress"
echo "usage: install_wordpress"
}
if [[ "${1}" == "-h" ]] || [[ "${1}" == "--help" ]]
then
HELP
else
INSTALL
fi