Update install_wordpress_vestacp

This commit is contained in:
vijay 2025-05-05 23:47:17 +00:00
parent 1097bca957
commit d851b2d4e1

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# bash <(curl -s https://git.technozone.com.au/vijay/Scripts/raw/branch/main/install_wordpress_vestacp) && rm -f install_wordpress_vestacp # bash <(curl -s https://git.technozone.com.au/vijay/Scripts/raw/branch/main/install_wordpress_vestacp) && rm -f install_wordpress_vestacp
# Function to prompt for input with default value # Function to prompt for input with default value
prompt() { prompt() {
local prompt_message=$1 local prompt_message=$1
@ -22,9 +23,9 @@ DOMAIN_NO_TLD=$(echo "$DOMAIN_NAME" | cut -d '.' -f 1)
MAX_USERNAME_LENGTH=16 MAX_USERNAME_LENGTH=16
TRUNCATED_USERNAME=$(echo "$USERNAME" | cut -c1-10) # Limit to 10 characters TRUNCATED_USERNAME=$(echo "$USERNAME" | cut -c1-10) # Limit to 10 characters
# Construct database name and user # Construct database name and user without username prefix
DB_NAME="${TRUNCATED_USERNAME}_${DOMAIN_NO_TLD}_d" # Construct database name DB_NAME="${DOMAIN_NO_TLD}_d" # Construct database name
DB_USER="${TRUNCATED_USERNAME}_${DOMAIN_NO_TLD}_u" # Construct database user DB_USER="${DOMAIN_NO_TLD}_u" # Construct database user
# Ensure the database name and user do not exceed 16 characters # Ensure the database name and user do not exceed 16 characters
if [ ${#DB_NAME} -gt $MAX_USERNAME_LENGTH ]; then if [ ${#DB_NAME} -gt $MAX_USERNAME_LENGTH ]; then
@ -46,6 +47,10 @@ else
v-add-domain $USERNAME $DOMAIN_NAME v-add-domain $USERNAME $DOMAIN_NAME
fi fi
# Create MySQL database and user
echo "Creating database and user..."
v-add-database $USERNAME $DB_NAME $DB_USER $DB_PASS
# Download and extract WordPress # Download and extract WordPress
echo "Downloading and installing WordPress..." echo "Downloading and installing WordPress..."
WP_DIR="/home/$USERNAME/web/$DOMAIN_NAME/public_html" WP_DIR="/home/$USERNAME/web/$DOMAIN_NAME/public_html"
@ -90,15 +95,11 @@ RewriteRule . /index.php [L]
</FilesMatch> </FilesMatch>
EOL EOL
# Create MySQL database and user
echo "Creating database and user..."
v-add-database $USERNAME $DB_NAME $DB_USER $DB_PASS
# Create WordPress configuration file # Create WordPress configuration file
echo "Configuring WordPress..." echo "Configuring WordPress..."
cp $WP_DIR/wp-config-sample.php $WP_DIR/wp-config.php cp $WP_DIR/wp-config-sample.php $WP_DIR/wp-config.php
sed -i "s/database_name_here/$DB_NAME/" $WP_DIR/wp-config.php sed -i "s/database_name_here/${TRUNCATED_USERNAME}_${DB_NAME}/" $WP_DIR/wp-config.php
sed -i "s/username_here/$DB_USER/" $WP_DIR/wp-config.php sed -i "s/username_here/${TRUNCATED_USERNAME}_${DB_USER}/" $WP_DIR/wp-config.php
sed -i "s/password_here/$DB_PASS/" $WP_DIR/wp-config.php sed -i "s/password_here/$DB_PASS/" $WP_DIR/wp-config.php
sed -i "s/localhost/localhost/" $WP_DIR/wp-config.php sed -i "s/localhost/localhost/" $WP_DIR/wp-config.php
@ -108,7 +109,7 @@ chmod 600 $WP_DIR/wp-config.php
# Display credentials # Display credentials
echo "Installation complete. Here are your credentials:" echo "Installation complete. Here are your credentials:"
echo "Domain Name: $DOMAIN_NAME" echo "Domain Name: $DOMAIN_NAME"
echo "Database Name: $DB_NAME" echo "Database Name: ${TRUNCATED_USERNAME}_${DB_NAME}"
echo "Database User: $DB_USER" echo "Database User: ${TRUNCATED_USERNAME}_${DB_USER}"
echo "Database Password: $DB_PASS" echo "Database Password: $DB_PASS"
echo "WordPress Directory: $WP_DIR" echo "WordPress Directory: