Fix deployment
This commit is contained in:
parent
3ea80eda6c
commit
ba2807a8f8
@ -7,63 +7,31 @@ if [ "$(id -u)" -ne 0 ]; then
|
||||
fi
|
||||
|
||||
# Update package list and install necessary packages
|
||||
apt-get update -y
|
||||
apt-get install -y php apache2 mysql-server php libapache2-mod-php php-mysqli php-json php-common php-mbstring php-zip php-xml php-gd php-curl php-bz2 php-ldap php-imagick
|
||||
apt-get update
|
||||
apt-get install -y mariadb-server
|
||||
service mariadb start
|
||||
|
||||
# Automatically select Apache2 during phpMyAdmin installation (without user intervention)
|
||||
echo "phpmyadmin phpmyadmin/webserver select apache2" | debconf-set-selections
|
||||
###
|
||||
# Set debconf to non-interactive mode
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install phpMyAdmin (with no user interaction)
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
|
||||
# Set the phpMyAdmin password (leave blank for random password)
|
||||
PHPADMIN_PASSWORD=""
|
||||
|
||||
# Generate a random password for phpMyAdmin user
|
||||
phpmyadmin_password=$(openssl rand -base64 12)
|
||||
# Set the web server (1 for apache2, 2 for lighttpd)
|
||||
WEB_SERVER="apache2"
|
||||
|
||||
# Set the MySQL root password (if not already set)
|
||||
#mysql_root_password=$(openssl rand -base64 12)
|
||||
mysql_root_password="forgotten"
|
||||
# Preconfigure the phpMyAdmin installation
|
||||
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections
|
||||
echo "phpmyadmin phpmyadmin/app-password-confirm password $PHPADMIN_PASSWORD" | debconf-set-selections
|
||||
echo "phpmyadmin phpmyadmin/mysql/admin-pass password" | debconf-set-selections
|
||||
echo "phpmyadmin phpmyadmin/mysql/app-pass password $PHPADMIN_PASSWORD" | debconf-set-selections
|
||||
echo "phpmyadmin phpmyadmin/reconfigure-webserver select $WEB_SERVER" | debconf-set-selections
|
||||
|
||||
# Set MySQL root password if not already set
|
||||
echo "Setting MySQL root password"
|
||||
mysqladmin -u root password "$mysql_root_password"
|
||||
# Install phpMyAdmin
|
||||
apt install -y phpmyadmin
|
||||
|
||||
# Check if the phpmyadmin user already exists and drop it if it does
|
||||
echo "Checking if phpMyAdmin user exists"
|
||||
existing_user=$(mysql -u root -p"$mysql_root_password" -e "SELECT COUNT(*) FROM mysql.user WHERE User = 'phpmyadmin';" | tail -n 1)
|
||||
|
||||
if [ "$existing_user" -gt 0 ]; then
|
||||
echo "Dropping existing phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "DROP USER IF EXISTS 'phpmyadmin'@'localhost';"
|
||||
fi
|
||||
|
||||
# Create phpMyAdmin user with mysql_native_password plugin
|
||||
echo "Creating phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY '$phpmyadmin_password';"
|
||||
|
||||
# Grant privileges to phpMyAdmin user
|
||||
echo "Granting privileges to phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'localhost';"
|
||||
mysql -u root -p"$mysql_root_password" -e "FLUSH PRIVILEGES;"
|
||||
|
||||
# Link phpMyAdmin to Apache's web directory (optional)
|
||||
# ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin # Uncomment if necessary
|
||||
|
||||
# Configure Apache to automatically restart and reconfigure
|
||||
echo "Reconfiguring Apache to apply changes"
|
||||
a2enmod rewrite
|
||||
|
||||
# Enable PHP module (adjust according to PHP version installed)
|
||||
a2enmod php7.4 # Adjust according to the PHP version installed (e.g., php7.4, php8.0)
|
||||
|
||||
# Restart Apache to apply changes
|
||||
# If using apache2, restart the apache2 service (adjust if using other web servers)
|
||||
service apache2 restart
|
||||
cp /home/tibia/1mindeploy/phpmyadmin.conf /etc/apache2/conf-available
|
||||
a2enconf phpmyadmin
|
||||
|
||||
# Output phpMyAdmin password and MySQL root password for user reference
|
||||
#echo "phpMyAdmin user created with the following password: $phpmyadmin_password"
|
||||
echo "MySQL root password: $mysql_root_password"
|
||||
|
||||
# Clean up and remove unnecessary packages
|
||||
#apt-get clean
|
||||
|
||||
echo "phpMyAdmin installation completed successfully."
|
||||
|
@ -1,68 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Ensure the script runs with root privileges
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update package list and install necessary packages
|
||||
apt-get update -y
|
||||
apt-get install -y apache2 mysql-server php libapache2-mod-php php-mysqli php-json php-common php-mbstring php-zip php-xml php-gd php-curl php-bz2 php-ldap php-imagick
|
||||
|
||||
# Automatically select Apache2 during phpMyAdmin installation (without user intervention)
|
||||
echo "phpmyadmin phpmyadmin/webserver select apache2" | debconf-set-selections
|
||||
|
||||
# Install phpMyAdmin (with no user interaction)
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
|
||||
|
||||
# Generate a random password for phpMyAdmin user
|
||||
phpmyadmin_password=$(openssl rand -base64 12)
|
||||
|
||||
# Set the MySQL root password (if not already set)
|
||||
mysql_root_password=$(openssl rand -base64 12)
|
||||
|
||||
# Set MySQL root password if not already set
|
||||
echo "Setting MySQL root password"
|
||||
mysqladmin -u root password "$mysql_root_password"
|
||||
|
||||
# Check if the phpmyadmin user already exists and drop it if it does
|
||||
echo "Checking if phpMyAdmin user exists"
|
||||
existing_user=$(mysql -u root -p"$mysql_root_password" -e "SELECT COUNT(*) FROM mysql.user WHERE User = 'phpmyadmin';" | tail -n 1)
|
||||
|
||||
if [ "$existing_user" -gt 0 ]; then
|
||||
echo "Dropping existing phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "DROP USER IF EXISTS 'phpmyadmin'@'localhost';"
|
||||
fi
|
||||
|
||||
# Create phpMyAdmin user with mysql_native_password plugin
|
||||
echo "Creating phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY '$phpmyadmin_password';"
|
||||
|
||||
# Grant privileges to phpMyAdmin user
|
||||
echo "Granting privileges to phpMyAdmin user"
|
||||
mysql -u root -p"$mysql_root_password" -e "GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'localhost';"
|
||||
mysql -u root -p"$mysql_root_password" -e "FLUSH PRIVILEGES;"
|
||||
|
||||
# Link phpMyAdmin to Apache's web directory (optional)
|
||||
# ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin # Uncomment if necessary
|
||||
|
||||
# Configure Apache to automatically restart and reconfigure
|
||||
echo "Reconfiguring Apache to apply changes"
|
||||
a2enmod rewrite
|
||||
|
||||
# Enable PHP module (adjust according to PHP version installed)
|
||||
a2enmod php7.4 # Adjust according to the PHP version installed (e.g., php7.4, php8.0)
|
||||
|
||||
# Restart Apache to apply changes
|
||||
service apache2 restart
|
||||
cp phpmyadmin.conf /etc/apache2/conf-available
|
||||
a2enconf phpmyadmin
|
||||
|
||||
# Output phpMyAdmin password and MySQL root password for user reference
|
||||
echo "phpMyAdmin user created with the following password: $phpmyadmin_password"
|
||||
echo "MySQL root password: $mysql_root_password"
|
||||
|
||||
# Clean up and remove unnecessary packages
|
||||
#apt-get clean
|
||||
|
Loading…
x
Reference in New Issue
Block a user