Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Oracle Linux 7.9 Script (1 Viewer)

Administrator
Staff member
Website Administrator
Joined
Nov 30, 2023
Messages
48
Since Centos 7 has reached EOL( End of Life) last June 30th 2024. I will transfer my servers to Oracle Linux 7.9 just to be able to continue normally.
I have seen an install script for all the necessary things needed for Centos 7 and converted it to fit OL7.9

Code:
#!/bin/bash

# Define colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
GRAY='\033[0;37m'
LIGHT_GREEN='\033[1;32m'
LIGHT_YELLOW='\033[1;33m'
LIGHT_RED='\033[1;31m'
LIGHT_BLUE='\033[1;34m'
LIGHT_MAGENTA='\033[1;35m'
LIGHT_CYAN='\033[1;36m'
LIGHT_GRAY='\033[1;37m'
NC='\033[0m' # No Color

# Configuring server date and time
echo -e "${BLUE}Configuring server date and time...${NC}"
timedatectl set-timezone America/Sao_Paulo
ln -sf /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
yum install -y ntp

# Installing necessary packages
echo -e "${BLUE}Installing necessary packages...${NC}"
yum install sudo -y
yum update -y
yum install net-tools nano httpd mariadb-server mariadb unzip bzip2 yum-utils -y

# Install EPEL repository
echo -e "${BLUE}Installing EPEL repository...${NC}"
yum install -y oracle-epel-release-el7
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# Install Remi repository
echo -e "${BLUE}Installing Remi repository...${NC}"
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php74

# Clear YUM cache and update
echo -e "${BLUE}Clearing YUM cache and updating...${NC}"
yum clean all
yum makecache
yum update -y

# Install PHP 7.4 and dependencies
echo -e "${BLUE}Installing PHP 7.4 and dependencies...${NC}"
yum install -y php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql php-xml php-mbstring php-bcmath

# Verify PHP version
php -v

# Install PHPMyAdmin
yum install phpMyAdmin -y

# Installing RAR
echo -e "${BLUE}Installing RAR...${NC}"
yum -y install wget
cd /usr/local/src
wget http://www.rarlab.com/rar/rarlinux-x64-5.2.1.tar.gz
tar zxvf rarlinux-x64-5.2.1.tar.gz
cp rar/unrar /usr/local/bin

# httpd services
echo -e "${BLUE}Configuring httpd services...${NC}"
systemctl enable httpd.service
systemctl start httpd.service
systemctl status httpd.service

# mariadb services
echo -e "${BLUE}Configuring mariadb services...${NC}"
systemctl enable mariadb.service
systemctl start mariadb.service
systemctl status mariadb.service

# Configuring virtual host file for PHPMyAdmin
echo -e "${BLUE}Configuring virtual host file for PHPMyAdmin...${NC}"
cat <<EOF > /etc/httpd/conf.d/phpMyAdmin.conf
Alias /phpmyadmin /usr/share/phpMyAdmin

<Directory /usr/share/phpMyAdmin/>
    AddDefaultCharset UTF-8

    <IfModule mod_authz_core.c>
        # Apache 2.4
        <RequireAny>
            Require all granted
        </RequireAny>
    </IfModule>

    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order Deny,Allow
        Deny from All
        Allow from 127.0.0.1
        Allow from ::1
    </IfModule>
</Directory>
EOF

# Renaming the phpMyAdmin folder name randomly
echo -e "${BLUE}Renaming the phpMyAdmin folder name randomly...${NC}"
dir="/etc/httpd/conf.d/"
file="phpMyAdmin.conf"
cd $dir
file_path=$(find $dir -name $file)
new_string=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
sed -i "s/phpmyadmin/${new_string}/g" $file_path

# Restarting Apache service
echo -e "${BLUE}Restarting Apache service...${NC}"
systemctl restart httpd

# Disabling the native firewall of CentOS 7
echo -e "${BLUE}Disabling the native firewall of CentOS 7...${NC}"
systemctl stop firewalld
systemctl disable firewalld

# Get the machine's IP address
ip_address=$(hostname -I | awk '{print $1}')

# General success message
echo -e "${GREEN}The configurations have been successfully applied.${NC}"

# Disabling SELinux
echo -e "${BLUE}Disabling SELinux...${NC}"
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

# Displaying access information
echo -e "${RED}INSTALLATION DETAILS${NC}"
echo -e "${YELLOW}PhpMyadmin: http://$ip_address/${new_string}/"
MYSQL_PASSWORD=$(head /dev/urandom | tr -dc 'A-Za-z0-9' | head -c 16 ; echo '')
echo -e "${YELLOW}MySQL User: root"
echo -e "${YELLOW}MySQL Password: ${MYSQL_PASSWORD}${NC}"
mysqladmin -u root password ${MYSQL_PASSWORD}

echo -e "${CYAN}PW-Developers.NET ♥ ${NC}"
 
Last edited:

Users who are viewing this thread

Translate Website

Top