# DirectAdmin

Hébergement web

# Base

## Debian base
```bash
su -s && \
apt update && apt upgrade -y && apt dist-upgrade -y && apt autoremove -y && apt purge && apt autoclean && apt install -y \ 
vim htop sudo curl software-properties-common dirmngr ca-certificates apt-transport-https qemu-guest-agent git parted \ 
&& sudo usermod -a -G sudo nom utilisatewur
```

#### Ajouter utilisateur en sudo
```bash
vim /etc/sudoers
mon_user ALL=(ALL:ALL) ALL
systemctl reboot
```

#### Fdisk : commande introuvable
Si la commande fdisk ne fonctionne pas exécuter cette command comme ci-dessous:
```bash
user@myhost:~$ PATH="/sbin:$PATH"
user@myhost:~$ command -v fdisk
/sbin/fdisk
```

## DirectAdmin
> #### Avant d'installer **DirectAdmin** effectuer d'abord cette procédure [Home avec Stockage](https://wiki.fuseboat.co/books/debian/page/hdd-home)

#### Installation des packages pour directadmin
[Packages DirectAdmin](https://docs.directadmin.com/getting-started/installation/overview.html)
```bash
sudo -s && \ 
apt-get update && \ 
apt-get install -y gcc g++ make flex bison openssl libssl-dev perl perl-base perl-modules libperl-dev libperl4-corelibs-perl libwww-perl libaio1 libaio-dev \
zlib1g zlib1g-dev libcap-dev cron bzip2 zip automake autoconf libtool cmake pkg-config python libdb-dev libsasl2-dev \
libncurses5 libncurses5-dev libsystemd-dev bind9 dnsutils quota patch logrotate rsyslog libc6-dev libexpat1-dev \
libcrypt-openssl-rsa-perl libnuma-dev libnuma1
```

#### Installation DirectAdmin Server
[Install Directadmin Server](https://docs.directadmin.com/getting-started/installation/installguide.html)
```bash
sudo -s && bash <(curl -fsSL https://download.directadmin.com/setup.sh) 'Ma Licencebash <(curl -fsSL https://download.directadmin.com/setup.sh) 'Ma Licence`'
```

# Adresse ip & DNS

## Changer ip wan et hostname
Ici on va changer notre ip wan => ***ip sur internet***:
```bash
/usr/local/directadmin/scripts/ipswap.sh old_ip new_ip
```
pour changer votre subdomain => ***vim /etc/hosts | vim /etc/hostname*** pour hostname important de mettre ***mail.mydomain.com***.
## Ajouter les clef DMARC
```bash
cd /usr/local/directadmin/data/templates

## modifier les fichiers /usr/local/directadmin/data/templates/dns_spf.conf & /usr/local/directadmin/data/templates/dns_txt.conf
|DOMAIN|.="v=spf1 a mx ip4:|SERVER_IP||EXTRA_SPF||SPF_IPV6| include:mail.mydomain.com -all"
_dmarc="v=DMARC1; p=none"
```

## Permet à letsencrypt de générer des certificats
```bash
vim /etc/network/interfaces
# ajouter => dns-nameservers 8.8.8.8
# ajouter => dns-nameservers 1.1.1.1

vim /etc/resolv.conf
# ajouter => nameserver 8.8.8.8
# ajouter => nameserver 1.1.1.1
```

# Packages

## Ajouter packages
##### Lestencrypt & nginx-apache
```bash
./build update && ./build letsencrypt && ./build update_da && \
./build set webserver nginx_apache && \
./build nginx_apache && \
./build rewrite_confs
# si une erreur se produit redemarrer le serveur et réinstaller ce package
```
##### Spamassasin
```bash
./build update  && ./build set exim yes && \ 
./build set eximconf yes  && ./build set eximconf_release 4.5  && \
./build set spamassassin yes  && ./build update  && \
./build exim && ./build exim_conf
```
#### Wordpress installer
``/usr/local/directadmin/custombuild/build wp``

#### Serveur mail
```bash
./build update 
./build set eximconf yes && ./build set eximconf_release 4.5 && \ 
./build set blockcracking yes && ./build set easy_spam_fighter yes && \
./build set spamd spamassassin && ./build set exim yes && ./build exim && \
./build set dovecot_conf yes && ./build dovecot_conf && \
./build update && ./build spamassassin && ./build dovecot && ./build roundcube && \
./build update && ./build exim_conf && /usr/local/directadmin/directadmin set one_click_webmail_login 1
```
#### PHP multi versions
```bash
./build set php1_release 8.1 && ./build set php2_release 8.0 && ./build set php3_release 7.4 && \
./build set php1_mode php-fpm && ./build set php2_mode php-fpm && ./build set php3_mode php-fpm && \
./build php n && ./build secure_php && ./build rewrite_confs
```

#### NGINX unit pour java node ruby python
```bash
cd /usr/local/directadmin/custombuild && \
./build set unit yes && ./build unit && \ 
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt-get install -y nodejs
```

#### Modsecurity
```bash
./build update && ./build set modsecurity yes && \ 
./build set modsecurity_ruleset "comodo" && ./build modsecurity && \ 
./build update
```

#### proftpd php_xmlrpc php_opcache htscanner
```bash
./build update && ./build set ftpd "proftpd" && ./build proftpd && \ 
./build set htscanner yes && ./build mod_htscanner2 && \
./build php_opcache && ./build php_xmlrpc && \
./build update
```

#### Autre packages
```bash
./build update  && ./build pigz && ./build geoipupdate && ./build pigeonhole && ./build freetype && \
./build imapsync && ./build composer && ./build imagemagick && ./build set curl yes && ./build curl && \ 
./build set awstats && ./build rewrite_confs
```


#### ajout d'extentions php
`vim /usr/local/directadmin/custombuild/php_extensions.conf`

```conf
#PHP Extension Settings
bz2=yes
gmp=yes
htscanner=yes
igbinary=no
imagick=yes
imap=yes
ioncube=yes
ldap=yes
opcache=yes
phalcon=yes
redis=yes
readline=yes
suhosin=no
snuffleupagus=no
xmlrpc=yes
zend=no
```
```bash 
cd /usr/local/directadmin/custombuild && ./build update && \
./build rewrite_confs
```