# Bash - Build : InstallNextcloud.sh

<table id="bkmrk-status-%3A-%C2%A0termin%C3%A9%C2%A0-a" style="border-collapse:collapse;width:53.7037%;border-width:0px;height:121px;"><colgroup><col style="width:42.9899%;"></col><col style="width:57.0139%;"></col></colgroup><tbody><tr style="height:28.8px;"><td style="border-width:0px;height:28.8px;">**Status :**  
</td><td style="border-width:0px;height:28.8px;"><span style="background-color:rgb(191,237,210);color:rgb(22,145,121);"> Terminé </span>  
</td></tr><tr style="height:28.8px;"><td style="border-width:0px;height:28.8px;">**Auteur :**  
</td><td style="border-width:0px;height:28.8px;"><span style="background-color:rgb(236,202,250);color:rgb(132,63,161);"> Olivier </span>  
</td></tr><tr style="height:28.8px;"><td style="border-width:0px;height:28.8px;">**Dernière version :**  
</td><td style="border-width:0px;height:28.8px;"><span style="background-color:rgb(194,224,244);color:rgb(35,111,161);"> V 1.0 </span>  
</td></tr><tr style="height:34.6px;"><td style="border-width:0px;height:34.6px;">**Dernière modification :**  
</td><td style="border-width:0px;height:34.6px;"><span style="background-color:rgb(206,212,217);color:rgb(52,73,94);"> 05/03/2023 </span>  
</td></tr></tbody></table>

---

#### <span style="text-decoration:underline;">I. Fonctionnalités</span>

Peut être utilisé dans les modes suivants : *<span style="background-color:rgb(236,202,250);color:rgb(132,63,161);"> CLI </span>*

La commande "-help" est présente :<span style="color:rgb(22,145,121);"> </span><span style="color:rgb(22,145,121);background-color:rgb(191,237,210);"><span style="color:rgb(186,55,42);background-color:rgb(248,202,198);"> non </span></span>

---

#### <span style="text-decoration:underline;">II. Captures d'écran</span>

<span style="background-color:rgb(251,238,184);">n/a</span>

---

#### <span style="text-decoration:underline;">III. Script</span>

<details id="bkmrk-createtechnicalfolde"><summary>InstallNextcloud.sh</summary>

```shell
#!/bin/bash

#Take Arguments
NEXTCLOUD_DOWNLOAD_LINK="https://download.nextcloud.com/server/releases/latest.zip"
NEXTCLOUD_APP_NAME=""

#Upgrade systservicessem
apt update
apt upgrade -y

#disable interactive mode
export DEBIAN_FRONTEND=noninteractive

#Install prerequisites
apt install -y wget vim zip

#Install apache2
apt install -y apache2 php8.1 libapache2-mod-php8.1
#Install required php modules
apt install -y php8.1-common php8.1-curl php8.1-dom php8.1-gd php8.1-mbstring php8.1-xml php8.1-zip php8.1-mysql
#Install optionnal php modules
apt install -y php8.1-bz2 php8.1-intl php8.1-ldap php8.1-smbclient php8.1-imap php8.1-bcmath php8.1-gmp php8.1-apcu 

#Go into apache directory
cd /etc/apache2/sites-available

#Disable all sites
a2dissite *

#Create site Configuration file
touch /etc/apache2/sites-available/nextcloud-http.conf
cat << EOF >> /etc/apache2/sites-available/nextcloud-http.conf
<VirtualHost *:80>
  DocumentRoot /var/www/nextcloud/
  ServerName  $NEXTCLOUD_APP_NAME

  <Directory /var/www/nextcloud/>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    <IfModule mod_dav.c>
      Dav off
    </IfModule>
  </Directory>
</VirtualHost>
EOF

#Enable nextcloud site
a2ensite nextcloud-http

#Enable necessary apache module
a2enmod rewrite env dir mime

#Create website directory
mkdir /var/www/nextcloud

#Go into apache directory
cd /var/www/

#Download nextcloud installer
wget $NEXTCLOUD_DOWNLOAD_LINK

#Unzip
unzip *.zip

#Remove zip file
rm *.zip

#set permissions
chown -R www-data:www-data /var/www/nextcloud/

#restart apache2 service
service apache2 restart
```

</details>---

#### <span style="text-decoration:underline;">IV. Changelog</span>

##### V 1.0

- Met à jour.
- Installe les prérequis.
- Installe le serveur web.
- Installe nextcloud.
- Adapte les configurations.
- Lance le serveur web.