step 1. Installiamo Apache
# yum install httpd -y
Dopo averlo installato, facciamo alcuni step intermedi:
# systemctl enable httpd # systemctl start httpd # systemctl status httpd
Se l'outpu del comando si presenta simile al seguente:
httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-09-09 11:00:56 CEST; 4min 24s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 13270 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─13270 /usr/sbin/httpd -DFOREGROUND ├─13271 /usr/sbin/httpd -DFOREGROUND ├─13272 /usr/sbin/httpd -DFOREGROUND ├─13273 /usr/sbin/httpd -DFOREGROUND ├─13274 /usr/sbin/httpd -DFOREGROUND └─13275 /usr/sbin/httpd -DFOREGROUND Sep 09 11:00:55 repository.local systemd[1]: Starting The Apache HTTP Server... Sep 09 11:00:56 repository.local httpd[13270]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using repository.l...s message Sep 09 11:00:56 repository.local systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full.
E abbiamo un messaggio tipo questo :
repository.local httpd[13270]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using repository.l...s message
Editiamo il file /etc/hosts e aggiungiamo il nome del nostro server accanto all'indirizzo IP 127.0.0.1
# vim /etc/hosts
Inseriamo la seguente entry :
127.0.0.1 localhost repository.local repository
Facciamo una copia di backup del file /etc/httpd/conf/httpd.conf
# cp -p -r /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_$(date +%Y%m%d)
Editiamo il file /etc/httpd/conf/httpd.conf aggiungendo la seguente entry in fondo al file:
# vim /etc/httpd/conf/httpd.conf ServerName 127.0.0.1
Giusto per scrupolo, configuriamo il Firewall per permettere il traffico dell'apache:
# sudo firewall-cmd --permanent --add-port=80/tcp # sudo firewall-cmd --permanent --add-port=443/tcp # sudo firewall-cmd --reload
Adesso riavviamo il servizio httpd:
# systemctl restart httpd
Verifichiamo nuovamente lo stato del servizio:
# systemctl status httpd
la riga con l'errore
repository.local httpd[13270]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name,
using repository.l...s message
Non dovrebbe essere più presente.
###
Una info in più, giusto per completezza, vediamo come configurare un VirtualHost.
All'interno della directory /etc/httpd/conf.d creiamo un nuovo file; la cosa confamentale è che il file termini con un .conf.
Ad esempio :
# vim repository.local.conf
e all'interno del file inseriamo :
ServerName repository.local # ServerAlias www.repository.local DocumentRoot /var/www/html Options Indexes FollowSymLinks MultiViews AllowOverride All ErrorLog /var/log/repository.local.com/logs/error.log CustomLog /var/log/repository.local.com/logs/access.log combined # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn
Per non avere problemi, ho rinominato il file /etc/httpd/conf.d/welcome.conf in /etc/httpd/conf.d/welcome.conf_OLD, in modo da averlo a portata di mano qual'ora dovessi riabilitarlo. Una volta, creato il file dobbiamo riavviare il seervizio httpd:
# systemctl restart httpd
E adesso possiamo testare il nuovo VirtualHost.
###
step 2. Creiamo un repository locale
# yum install createrepo -y
step 3. Installiamo il pacchetto che ci permette di creare, configurare e gestire il tuo repository locale
# yum install yum-utils -y
step 4. Creiamo le directory che conterranno i pacchetti e le relative informaizoni necessarie al funzionamento del repository
# mkdir -p /var/www/html/repos/{base,centosplus,extras,updates,cloudera}
step 5. Sincroniziamo il repository CentOS nella directory locale che abbiamo creato
# reposync -g -l -d -m --repoid=base --newest-only --download-metadata --download_path=/var/www/html/repos/ # reposync -g -l -d -m --repoid=centosplus --newest-only --download-metadata --download_path=/var/www/html/repos/ # reposync -g -l -d -m --repoid=extras --newest-only --download-metadata --download_path=/var/www/html/repos/ # reposync -g -l -d -m --repoid=updates --newest-only --download-metadata --download_path=/var/www/html/repos/
Vediamo brevemente cosa sono le opzioni che abbiamo usato nel comando reposync:
step 6. Verificare che i pacchetti siano stati scaricati tutti correttamente
Basta fare un check nelle directory che sono state create allo step 4
step 7. Creiamo un Repository repomd (metadati rpm basati su XML) da un set di rpm
# sudo createrepo /var/www/html/
Step 8. Da un browser, proviamo a collegarci all'indirizzo ip del nostro server che fa da repository.
Nello step 1, quando viene installato l'apache c'è una sezione in cui indico i comandi per configurare correttamente l'apache e un VirtualHost.
Step 9. Sulla macchina client
# cd /etc/yum.repos.d/
Rinominiamo tutti i file presenti aggiungendo un _OLD
# yum repolist all Loaded plugins: fastestmirror repolist: 0
Al momento il server non ha repository di riferimento.
Creiamo il nostro file repository :
# vim repository.local.repo
Inseriamo le seguenti entry nel file :
[local-base] name=CentOS Base baseurl=http://repository.local/ gpgcheck=0 enabled=1 [local-centosplus] name=CentOS CentOSPlus baseurl=http://repository.local/ gpgcheck=0 enabled=1 [local-extras] name=CentOS Extras baseurl=http://repository.local/ gpgcheck=0 enabled=1 [local-updates] name=CentOS Updates baseurl=http://repository.local/ gpgcheck=0 enabled=1 [local-cloudera] name=CentOS Updates baseurl=http://repository.local/ gpgcheck=0 enabled=1
Salviamo ed usciamo.
Sempre sulla nostra macchina client, dobbiamo editare il file /etc/hosts in modo che il client punti al nostro repository server.
Nel mio caso la entry nel file hosts sarà :
192.168.1.117 repository.local
Eseguiamo il seguente comando:
# yum repolist all
Verifichiamo l'output che riceviamo:
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile local-base | 2.9 kB 00:00:00 local-centosplus | 2.9 kB 00:00:00 local-cloudera | 2.9 kB 00:00:00 local-extras | 2.9 kB 00:00:00 local-updates | 2.9 kB 00:00:00 (1/4): local-centosplus/primary_db | 6.6 MB 00:00:00 (2/4): local-base/primary_db | 6.6 MB 00:00:00 (3/4): local-extras/primary_db | 6.6 MB 00:00:00 (4/4): local-updates/primary_db | 6.6 MB 00:00:00 repo id repo name status local-base CentOS Base enabled: 10,372 local-centosplus CentOS CentOSPlus enabled: 10,372 local-cloudera CentOS Updates enabled: 10,372 local-extras CentOS Extras enabled: 10,372 local-updates CentOS Updates enabled: 10,372 repolist: 51,860
Step 10. Verifichiamo sul client che funzioni tutto
Per fare una prova verifichamo un pacchetto non presente sul nostro client, come ad esempio wget
# rpm -qa |grep -i wget --color
Se il pacchetto non è presente sul server, proviamo ad installarlo:
# yum install wget -y
Se la prova va a buon fine, possiamo considerare conclusa la guida per "Installare e Configurare un Repository Locale su CentOS 7".
Per qualsiasi dubbio o domanda non esitate a scrivere sfruttando la sezione contatti del sito.