Create nextcloud.sh
Browse files- nextcloud.sh +65 -0
nextcloud.sh
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# Update system packages
|
4 |
+
sudo apt update
|
5 |
+
sudo apt upgrade -y
|
6 |
+
|
7 |
+
# Install required packages
|
8 |
+
sudo apt install -y apache2 mariadb-server libapache2-mod-php7.4 php7.4-gd php7.4-json php7.4-mysql php7.4-curl php7.4-mbstring php7.4-intl php7.4-xml php7.4-zip php7.4-bz2 php7.4-common php7.4-cli php7.4-ldap php7.4-gmp
|
9 |
+
|
10 |
+
# Enable necessary Apache modules
|
11 |
+
sudo a2enmod rewrite
|
12 |
+
sudo a2enmod headers
|
13 |
+
sudo a2enmod env
|
14 |
+
sudo a2enmod dir
|
15 |
+
sudo a2enmod mime
|
16 |
+
|
17 |
+
# Create a database for Nextcloud
|
18 |
+
sudo mysql -u root -p <<EOF
|
19 |
+
CREATE DATABASE nextcloud;
|
20 |
+
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'your_password_here';
|
21 |
+
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
|
22 |
+
FLUSH PRIVILEGES;
|
23 |
+
EXIT;
|
24 |
+
EOF
|
25 |
+
|
26 |
+
# Download and extract Nextcloud
|
27 |
+
wget https://download.nextcloud.com/server/releases/latest.tar.bz2
|
28 |
+
tar -xjf latest.tar.bz2
|
29 |
+
sudo mv nextcloud /var/www/
|
30 |
+
sudo chown -R www-data:www-data /var/www/nextcloud
|
31 |
+
|
32 |
+
# Configure Apache virtual host
|
33 |
+
sudo tee /etc/apache2/sites-available/nextcloud.conf <<EOF
|
34 |
+
<VirtualHost *:80>
|
35 |
+
ServerAdmin webmaster@localhost
|
36 |
+
DocumentRoot /var/www/nextcloud
|
37 |
+
ServerName your_domain_or_ip_here
|
38 |
+
ErrorLog ${APACHE_LOG_DIR}/error.log
|
39 |
+
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
40 |
+
<Directory /var/www/nextcloud/>
|
41 |
+
Options +FollowSymlinks
|
42 |
+
AllowOverride All
|
43 |
+
Require all granted
|
44 |
+
<IfModule mod_dav.c>
|
45 |
+
Dav off
|
46 |
+
</IfModule>
|
47 |
+
SetEnv HOME /var/www/nextcloud
|
48 |
+
SetEnv HTTP_HOME /var/www/nextcloud
|
49 |
+
</Directory>
|
50 |
+
</VirtualHost>
|
51 |
+
EOF
|
52 |
+
|
53 |
+
# Enable the Nextcloud virtual host
|
54 |
+
sudo a2ensite nextcloud.conf
|
55 |
+
|
56 |
+
# Restart Apache
|
57 |
+
sudo systemctl restart apache2
|
58 |
+
|
59 |
+
# Set up Nextcloud cron job
|
60 |
+
sudo -u www-data php /var/www/nextcloud/cron.php
|
61 |
+
|
62 |
+
# Clean up
|
63 |
+
rm latest.tar.bz2
|
64 |
+
|
65 |
+
echo "Nextcloud installation is complete. Access your Nextcloud instance by visiting http://your_domain_or_ip_here in your web browser."
|