This repository has been archived by the owner on Nov 2, 2024. It is now read-only.
Replies: 2 comments 3 replies
-
https://www.turnkeylinux.org/wordpress You can use https://tteck.github.io/Proxmox/#turnkey-lxc-appliances |
Beta Was this translation helpful? Give feedback.
1 reply
-
For those who don't want to use turnkey, here is a script that can be used to install all the services from a Debian lxc (I use the one from tteck). The script will only ask you for the name of the domain you want to use. In any case, the script itself will identify the IP of the lxc and register it in Apache so that you can access it from there. #!/bin/bash
# Colores para mensajes
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Función para mostrar errores
show_error() {
echo -e "${RED}Error: $1${NC}"
exit 1
}
# Solicitar el nombre de dominio
read -p "Ingrese el nombre de dominio para WordPress: " domain_name
# Generar credenciales aleatorias para la base de datos
db_name="wp_$(openssl rand -hex 4)"
db_user="user_$(openssl rand -hex 4)"
db_password=$(openssl rand -base64 12)
# Obtener la dirección IP local
ip_address=$(hostname -I | awk '{print $1}')
# Actualizar e instalar dependencias
apt update && apt upgrade -y || show_error "No se pudo actualizar el sistema"
apt install -y apache2 mariadb-server php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip || show_error "No se pudieron instalar las dependencias"
# Configurar MariaDB
mysql_secure_installation <<EOF
y
y
y
y
y
EOF
# Crear base de datos y usuario
mysql -e "CREATE DATABASE ${db_name};"
mysql -e "CREATE USER '${db_user}'@'localhost' IDENTIFIED BY '${db_password}';"
mysql -e "GRANT ALL PRIVILEGES ON ${db_name}.* TO '${db_user}'@'localhost';"
mysql -e "FLUSH PRIVILEGES;"
# Descargar e instalar WordPress
wget https://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
mv wordpress/* /var/www/html/
rm -rf wordpress latest.tar.gz
# Configurar wp-config.php
cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
sed -i "s/database_name_here/${db_name}/" /var/www/html/wp-config.php
sed -i "s/username_here/${db_user}/" /var/www/html/wp-config.php
sed -i "s/password_here/${db_password}/" /var/www/html/wp-config.php
# Agregar salt keys
curl -s https://api.wordpress.org/secret-key/1.1/salt/ >> /var/www/html/wp-config.php
# Configurar Apache
cat > /etc/apache2/sites-available/${ip_address}.conf <<EOF
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName ${ip_address}
ErrorLog \${APACHE_LOG_DIR}/error.log
CustomLog \${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOF
cat > /etc/apache2/sites-available/${domain_name}.conf <<EOF
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName ${domain_name}
ErrorLog \${APACHE_LOG_DIR}/error.log
CustomLog \${APACHE_LOG_DIR}/access.log combined
<IfModule mod_headers.c>
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-SSL "on"
</IfModule>
</VirtualHost>
EOF
a2ensite ${ip_address}.conf
a2ensite ${domain_name}.conf
a2dissite 000-default.conf
systemctl reload apache2
# Mejorar seguridad
chown -R www-data:www-data /var/www/html/
find /var/www/html/ -type d -exec chmod 750 {} \;
find /var/www/html/ -type f -exec chmod 640 {} \;
# Deshabilitar el acceso remoto de root a MariaDB
sed -i 's/bind-address\s*=\s*127.0.0.1/bind-address = 127.0.0.1/' /etc/mysql/mariadb.conf.d/50-server.cnf
systemctl restart mariadb
# Eliminar archivo index de Apache
rm /var/www/html/index.html
# Mensaje final
echo -e "${GREEN}¡La instalación de WordPress se ha completado correctamente!${NC}"
echo -e "Acceso local: ${BLUE}http://${ip_address}${NC}"
echo -e "Acceso por dominio: ${BLUE}http://${domain_name}${NC}" |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey!
thanks for all the amazing work !
already thought about having a script for Wordpress (debian + php + apache + mariadb + ... ) ?
Beta Was this translation helpful? Give feedback.
All reactions