Update updated_install1.sh
This commit is contained in:
parent
0a5c473489
commit
9fbd37c40d
|
@ -5,6 +5,7 @@ HOSTNAME="wordpress.local"
|
|||
IP="127.0.0.1"
|
||||
SITE_CONF="/etc/apache2/sites-available/wordpress.conf"
|
||||
WEB_ROOT="/srv/www/wordpress"
|
||||
DB_PASSWORD="changeme123"
|
||||
# ============================
|
||||
|
||||
# Update system
|
||||
|
@ -38,16 +39,33 @@ cat << EOF | sudo tee "$SITE_CONF" > /dev/null
|
|||
EOF
|
||||
|
||||
# Add hostname to /etc/hosts if not already present
|
||||
if grep -q "$HOSTNAME" /etc/hosts; then
|
||||
echo "Entry for $HOSTNAME already exists in /etc/hosts."
|
||||
else
|
||||
echo "Adding $HOSTNAME to /etc/hosts..."
|
||||
if ! grep -q "$HOSTNAME" /etc/hosts; then
|
||||
echo "$IP $HOSTNAME" | sudo tee -a /etc/hosts > /dev/null
|
||||
echo "Done."
|
||||
fi
|
||||
|
||||
# Enable site and modules, disable default
|
||||
a2ensite wordpress.conf
|
||||
a2enmod rewrite
|
||||
a2dissite 000-default.conf
|
||||
systemctl reload apache2
|
||||
systemctl reload apache2
|
||||
|
||||
# Create WordPress database and user
|
||||
sudo mysql -u root <<EOF
|
||||
CREATE DATABASE IF NOT EXISTS wordpress;
|
||||
CREATE USER IF NOT EXISTS 'wordpress'@'localhost' IDENTIFIED BY '$DB_PASSWORD';
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON wordpress.* TO 'wordpress'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
EOF
|
||||
|
||||
# Create wp-config.php from the sample
|
||||
sudo -u www-data cp /srv/www/wordpress/wp-config-sample.php /srv/www/wordpress/wp-config.php
|
||||
|
||||
# Replace database settings in wp-config.php
|
||||
sudo -u www-data sed -i "s/database_name_here/wordpress/" /srv/www/wordpress/wp-config.php
|
||||
sudo -u www-data sed -i "s/username_here/wordpress/" /srv/www/wordpress/wp-config.php
|
||||
sudo -u www-data sed -i "s/password_here/${DB_PASSWORD}/" /srv/www/wordpress/wp-config.php
|
||||
|
||||
# Replace salts in wp-config.php
|
||||
WP_CONFIG="/srv/www/wordpress/wp-config.php"
|
||||
sed -i "/AUTH_KEY/d;/SECURE_AUTH_KEY/d;/LOGGED_IN_KEY/d;/NONCE_KEY/d;/AUTH_SALT/d;/SECURE_AUTH_SALT/d;/LOGGED_IN_SALT/d;/NONCE_SALT/d" "$WP_CONFIG"
|
||||
curl -s https://api.wordpress.org/secret-key/1.1/salt/ >> "$WP_CONFIG"
|
||||
|
|
Loading…
Reference in New Issue