-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathautomated server config.sh
35 lines (29 loc) · 977 Bytes
/
automated server config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/sh
# Automated Server Configuration
# Install required packages
apt-get update
apt-get install -y apache2 mysql-server php php-mysql
# Configure MySQL database
mysql -u root -e "CREATE DATABASE myapp;"
mysql -u root -e "CREATE USER 'myapp'@'localhost' IDENTIFIED BY 'password';"
mysql -u root -e "GRANT ALL PRIVILEGES ON myapp.* TO 'myapp'@'localhost';"
# Configure Apache virtual host
cat << EOF > /etc/apache2/sites-available/myapp.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/myapp
ServerName myapp.example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
EOF
a2ensite myapp.conf
systemctl reload apache2
# Clone and configure application repository
git clone https://github.com/myapp/myapp.git /var/www/myapp
cd /var/www/myapp
cp .env.example .env
composer install
php artisan migrate --seed
# Print success message
echo "Server configuration complete!"