Update updated_install1.sh
This commit is contained in:
parent
24675aab3e
commit
0f6a5ba1e9
|
@ -1,65 +1,53 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ====== CONFIGURATION ======
|
||||||
|
HOSTNAME="wordpress.local"
|
||||||
|
IP="127.0.0.1"
|
||||||
|
SITE_CONF="/etc/apache2/sites-available/wordpress.conf"
|
||||||
|
WEB_ROOT="/srv/www/wordpress"
|
||||||
|
# ============================
|
||||||
|
|
||||||
|
# Update system
|
||||||
apt update
|
apt update
|
||||||
apt upgrade -y
|
apt upgrade -y
|
||||||
|
|
||||||
|
# Install required packages
|
||||||
apt install -y apache2 ghostscript libapache2-mod-php mysql-server php php-bcmath php-curl php-imagick php-intl php-json php-mbstring php-mysql php-xml php-zip
|
apt install -y apache2 ghostscript libapache2-mod-php mysql-server php php-bcmath php-curl php-imagick php-intl php-json php-mbstring php-mysql php-xml php-zip
|
||||||
|
|
||||||
sudo mkdir -p /srv/www
|
# Create WordPress directory and download
|
||||||
|
mkdir -p /srv/www
|
||||||
chown www-data: /srv/www
|
chown www-data: /srv/www
|
||||||
curl https://wordpress.org/latest.tar.gz | -u www-data tar zx -C /srv/www
|
curl https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /srv/www
|
||||||
|
|
||||||
cat << EOF | sudo tee /etc/apache2/sites-available/wordpress.conf > /dev/null
|
# Configure Apache VirtualHost
|
||||||
|
cat << EOF | sudo tee "$SITE_CONF" > /dev/null
|
||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
DocumentRoot /srv/www/wordpress
|
ServerName $HOSTNAME
|
||||||
<Directory /srv/www/wordpress>
|
DocumentRoot $WEB_ROOT
|
||||||
|
<Directory $WEB_ROOT>
|
||||||
Options FollowSymLinks
|
Options FollowSymLinks
|
||||||
AllowOverride Limit Options FileInfo
|
AllowOverride Limit Options FileInfo
|
||||||
DirectoryIndex index.php
|
DirectoryIndex index.php
|
||||||
Require all granted
|
Require all granted
|
||||||
</Directory>
|
</Directory>
|
||||||
<Directory /srv/www/wordpress/wp-content>
|
<Directory $WEB_ROOT/wp-content>
|
||||||
Options FollowSymLinks
|
Options FollowSymLinks
|
||||||
Require all granted
|
Require all granted
|
||||||
</Directory>
|
</Directory>
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
a2ensite wordpress
|
# Add hostname to /etc/hosts if not already present
|
||||||
a2enmod rewrite
|
|
||||||
a2dissite 000-default
|
|
||||||
|
|
||||||
cat << EOF | sudo tee /etc/apache2/sites-available/wordpress.conf > /dev/null
|
|
||||||
<VirtualHost *:80>
|
|
||||||
ServerName wordpress.local
|
|
||||||
DocumentRoot /srv/www/wordpress
|
|
||||||
<Directory /srv/www/wordpress>
|
|
||||||
Options FollowSymLinks
|
|
||||||
AllowOverride Limit Options FileInfo
|
|
||||||
DirectoryIndex index.php
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
<Directory /srv/www/wordpress/wp-content>
|
|
||||||
Options FollowSymLinks
|
|
||||||
Require all granted
|
|
||||||
</Directory>
|
|
||||||
</VirtualHost>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
HOSTNAME="wordpress.local"
|
|
||||||
IP="127.0.0.1"
|
|
||||||
LINE="$IP $HOSTNAME"
|
|
||||||
|
|
||||||
# Check if the entry already exists
|
|
||||||
if grep -q "$HOSTNAME" /etc/hosts; then
|
if grep -q "$HOSTNAME" /etc/hosts; then
|
||||||
echo "Entry for $HOSTNAME already exists in /etc/hosts."
|
echo "Entry for $HOSTNAME already exists in /etc/hosts."
|
||||||
else
|
else
|
||||||
echo "Adding $HOSTNAME to /etc/hosts..."
|
echo "Adding $HOSTNAME to /etc/hosts..."
|
||||||
echo "$LINE" | sudo tee -a /etc/hosts > /dev/null
|
echo "$IP $HOSTNAME" | sudo tee -a /etc/hosts > /dev/null
|
||||||
echo "Done."
|
echo "Done."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Enable site and modules, disable default
|
||||||
a2ensite wordpress.conf
|
a2ensite wordpress.conf
|
||||||
systemctl reload apache2
|
a2enmod rewrite
|
||||||
a2dissite 000-default.conf
|
a2dissite 000-default.conf
|
||||||
systemctl reload apache2
|
systemctl reload apache2
|
Loading…
Reference in New Issue