Script generatore Host Virtuali - generate VirtualHost

News dal mondo dell' I.T.C. Partecipa anche tu.
Post Reply
User avatar
Roberto_65
Collaboratore
Collaboratore
Posts: 516
Joined: 6 December 2007, 23:56
OpenMandriva: 2009.1
Kernel: i686 x86_64
Desktop: Gnome Xfce4
Location: Triangolo delle Bermude
Contact:

Script generatore Host Virtuali - generate VirtualHost

Post by Roberto_65 »

Script to generate Web Virtual Host

Image Script generatore di Host Virtuali Web - Link alla Guida in Italiano
Image Script to generate Web Virtual Host

Wanting to set up a virtual Web server on my physical server in my intranet, with Mandriva I found a very winding road with lots of configuration scripts to create and modify or rewrite and finally there is a high risk that the whole thing does not work, and that is that's why I decided to create a bash script suitable and easy to use.

These notes allow you to create all the virtual servers that you want in a single PC.
Useful to emulate Web pages locally or for many Web servers running on the network.
Before proceeding to describe the script, you better know how to create a physical server in your network with a local physical IP.

Open a terminal and we logged in as Root and paste the following lines:

Code: Select all

urpmi task-lamp -a -y
urpmi ssh -a -y
urpmi drakwizard -y
urpme proftpd -y
urpmi pure-ftpd- -a -y

ifconfig eth0 | awk '/inet/ {print $2}'> /file.txt; i=$(cat /file.txt);rm -f /file.txt;i=${i:5};echo $i | awk '/addr/ {print $1}' > /etc/ip; i=$(cat /etc/ip)
ns=$(echo $HOSTNAME)
echo; echo -n "Name for the physical server: ["${ns}"]-->"; read nsf
if [ ! $nsf ]; then
   nsf=$ns
fi
echo "HOSTNAME="$nsf >> /etc/sysconfig/network
export HOSTNAME=${nsf}
echo $nsf > /etc/hostname
echo "<html><body><h1>It works!</h1>" > /var/www/html/index.html
echo "<p>This is the default web page for this server.</p>" >> /var/www/html/index.html
echo "<p>The web server software is running but no content has been added, yet.</p>" >> /var/www/html/index.html
echo "<p>Welcome to http://$nfs</p>" >> /var/www/html/index.html
echo "<p>IP for the FTP service: $nfs</p>" >> /var/www/html/index.html
echo "<p>Physical location of $nsf: /var/www/html/</p>" >> /var/www/html/index.html
echo "</body></html>" >> /var/www/html/index.html
echo $i" "$nfs >> /etc/hosts
As you can see the board to replace the default ftp server with proftpd pure-ftpd, is to have greater flexibility in service management ftp.

After the reboot run the following script (mkvhost) to generate the virtual host:

Code: Select all

#! /bin/bash
# Script is to be saved in: /usr/sbin/ of server
echo $0
echo "##########################################################################"
echo "#             MKVHOST - (c)-2011 - Vr. 1.1 - /14/07/2011                 #"
echo "#       Automatic procedure to create a Virtual Host in Web server.      #"
echo "##########################################################################"
# We read the counter of virtual hosts
if [ /etc/httpd/conf/nvh ]; then
    nh=$(cat /etc/httpd/conf/nvh)
    else
    nh="0"
fi
# We increment the counter of virtual hosts
nh=$(expr $nh + 1)

# We identify the name assigned to the server PC;
# Of good practice on all versions of Linux, except on Mandriva,
# It is written in /etc/hostname
if [ ! -f /etc/hostname ]; then
    echo; echo "ERROR: This computer does not have a name or the server HTTPD is missing!"
    echo -n "Do you want to assign a name to this server (y / n)? [s] -->"; read sn
    if [ ! $sn ]; then
	sn="s"
      else
        sn="n"
    fi
    if [ $sn == "s" ]; then
    ns=$(echo $HOSTNAME)
    echo; echo -n "Name for the physical server: ["${ns}"]-->"; read nsf
    if [ ! $nsf ]; then
	nsf=$ns
	fi
	echo "HOSTNAME="$nsf >> /etc/sysconfig/network
	export HOSTNAME=${nsf}
	echo $nsf > /etc/hostname
	echo; echo "Rerun the command: MKVHOST"
    fi
    exit 1
fi

# We identify the IP number and write it along with the name of the server in /etc/hosts
ifconfig eth0 | awk '/inet/ {print $2}'> /file.txt; i=$(cat /file.txt);rm -f /file.txt;i=${i:5};echo $i | awk '/addr/ {print $1}' > /etc/ip; i=$(cat /etc/ip)
echo $i" "$(cat /etc/hostname)

# We generate the configuration for your virtual servers with virtual IP
# Are then required: the name of the administrator of the new host,
# the name for the host and the last digit of the new virtual IP to be generated
# Obviously the user must already exist on your PC as an account of the physical server
echo "You're creating the virtual server N°: "$nh
echo -n "Virtual server name to be generated:       -->"; read vserver
nsip=$i
ni=${nsip:0:9}
echo -n " VIrtual Host's IP number ${ni}.###  (IP: Only final part): -->"; read nvip
nvip=${ni}"."${nvip}
echo $nvip
echo; echo -n "Username:                                -->"; read utente
echo
webdir="/home/"${utente}"/web/"${vserver}

# Checking the existence of the user
if [ ! "/home/"${utente} ]; then
	echo "User: ${utente} It does not exist."
	exit 1
fi

# Creation of the structure, and sample index.html page in the new virtual server
mkdir -p ${webdir}
echo "<html><body><h1>It works!</h1>" > ${webdir}/index.html
echo "<p>This is the default web page for this server.</p>" >> ${webdir}/index.html
echo "<p>The web server software is running but no content has been added, yet.</p>" >> ${webdir}/index.html
echo "<p>Welcome to http://$nsip</p>" >> ${webdir}/index.html
echo "<p>Virtual Server: $vserver</p>" >> ${webdir}/index.html
echo "<p>Virtual IP: $nvip</p>" >> ${webdir}/index.html
echo "<p>IP for the FTP service: $nsip</p>" >> ${webdir}/index.html
echo "<p>Owner user: $utente</p>" >> ${webdir}/index.html
echo "<p>Physical directory on the server: /home/$utente/web/$vserver/</p>" >> ${webdir}/index.html
echo "</body></html>" >> ${webdir}/index.html
chmod -R 777 /home/${utente}/web
chown -R ${utente}:${utente} /home/${utente}/web

echo "Generating: VirtualHost N° "$nh
echo $nh > /etc/httpd/conf/nvh

# Editing the configuration file /bin/vhost
# if it does not already exist is created
# It is used to enable hosts based on IP
if [ ! /bin/vhost ]; then
	echo "#! /bin/bash" > /bin/vhost
	echo "##############" >> /bin/vhost
	echo "# /bin/vhost #" >> /bin/vhost
	echo "#################################" >> /bin/vhost
	echo "# Procedura generata da MKVHOST #" >> /bin/vhost
	echo "#################################" >> /bin/vhost
	echo "# script to run on bootup to bind additional IP addresses to the" >> /bin/vhost
	echo "# ethernet interface." >> /bin/vhost
	echo "" >> /bin/vhost
	cd /bin
	chmod 777 vhost
	cd /
	# Entering the command to run the vhosts script in /etc/rc.d/rc.local
	# so you turn on all the virtual hosts with the launch of the PC
	echo "vhost" >> /etc/rc.d/rc.local
fi
echo "echo \"Assign IP: ${nvip} to Virtual Hosts: ${vserver}\"" >> /bin/vhost
echo "ifconfig eth0:"$nh" add $nvip" >> /bin/vhost

# Editing the configuration file: /etc/httpd/conf/vhosts.d/vhosts.conf
# if it does not already exist is created
# This file is set to configure the new Virtual Host with the path of the web directory
if [ ! /etc/httpd/conf/vhosts.d/vhosts.conf ]; then
	echo "########################################" > /etc/httpd/conf/vhosts.d/vhosts.conf
	echo "# /etc/httpd/conf/vhosts.d/vhosts.conf #" >> /etc/httpd/conf/vhosts.d/vhosts.conf
	echo "########################################" >> /etc/httpd/conf/vhosts.d/vhosts.conf
	echo "# Procedura generata da MKVHOST #" >> /etc/httpd/conf/vhosts.d/vhosts.conf
	echo "#################################" >> /etc/httpd/conf/vhosts.d/vhosts.conf
fi
echo "" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "# NOME VIRTUAL HOST: "$vserver >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "# PROPRIETARIO: "$utente >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "NameVirtualHost ${nvip}" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "<VirtualHost ${nvip}>" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	ServerName ${vserver}" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	ServerAlias www.${vserver}" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	ErrorLog logs/sick-internals-error_log" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	ServerPath /home/${utente}/web" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	DocumentRoot /home/${utente}/web/${vserver}" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	<Directory \"\">" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "		Options Indexes FollowSymLinks MultiViews" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "		AllowOverride None" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "		Order allow,deny" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "		Allow from all" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	</Directory>" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "</VirtualHost>" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo $nvip" "$vserver >> /etc/hosts
echo; echo "Add the following line in \"/etc/hosts\" of Client PC."
echo; echo $nvip" "$vserver" www."$vserver
echo; echo "Restart the HTTPD server:"

# Restart the HTTPD server
service httpd restart

# Activate virtual hosts manually
vhost

echo; echo "Edit from the browser: http://"$nvip

This script, I recommend you to save it in /usr/sbin/ with the name: mkvhost
Of course, set the execute permissions:

Code: Select all

chmod 777 /usr/sbin/mkvhost
It can run all the time you want to create a Virtual Host.

Attach summary of instructions with steps to follow:

Instructions for the configurations:
1) install Mandriva on your PC without to select the server part during the installation
2) assign a static IP like: 192.168.0.XX 192.168.1.xx or (depending on your router) to your PC
3) perform a normal update of packages from repository
4) reboot
5) open the console and you log in as Root
6) Install and configure a physical server (as above)
7) Turn off all ports on the firewall from the Control Panel -> Security
8) restart the system and already has the physical server with HTTP: / / <ip server> and FTP anonymous FTP: / / <ip server>
9) run the command from the console and set DRAKWIZARD SSH (if desired)
10) always with a console as root run the command: MKVHOST to generate the first virtual server

So you can create as many virtual servers you want with its virtual IP for each different user.
Each registered user to the server via a client-ftp enters its own space and manages their virtual servers.
Each virtual host has a virtual IP in addition to its name.

MySQL is installed: you have to activate the administrator user as:

Code: Select all

mysqladmin -u <utente> password <password>
Replace <utente> and <password> with user name and password.

Let me know how you found with this script!
Bye
Last edited by Roberto_65 on 24 July 2011, 15:53, edited 3 times in total.
Roberto_65
Packager delle MIB-Live
Il creatore delle MIB-Live
L'inventore di MIB-LiveToFlash
Triangolo delle Bermude http://www.sitohd.com/siti/3209

User avatar
Roberto_65
Collaboratore
Collaboratore
Posts: 516
Joined: 6 December 2007, 23:56
OpenMandriva: 2009.1
Kernel: i686 x86_64
Desktop: Gnome Xfce4
Location: Triangolo delle Bermude
Contact:

Re: Script generatore Host Virtuali - generate VirtualHost

Post by Roberto_65 »

Script to generate Web Virtual Host!

Image Script to generate Web Virtual Host - English Guide link

Volendo configurare un server Web virtuale nel mio server fisico della mia intranet, con Mandriva ho trovato una strada molto tortuosa con molti script di configurazione da creare e modificare o riscrivere e alla fine vi è un altissimo rischio che il tutto non funzioni; ed è per questo che mi sono deciso di creare uno script in bash adatto e di facile utilizzo.

Queste note permettono di creare tutti i server virtuali che si vogliono in un unico PC.
Utile per emulare pagine Web in locale o per avere tanti server Web funzionanti in rete.
Prima di procedere a descrivere lo script, è meglio saper creare un server fisico nella propria rete con un IP fisico locale.

Apriamo un terminale e ci logghiamo come Root e incolliamo quando segue:

Code: Select all

urpmi task-lamp -a -y
urpmi ssh -a -y
urpmi drakwizard -y
urpme proftpd -y
urpmi pure-ftpd- -a -y

ifconfig eth0 | awk '/inet/ {print $2}'> /file.txt; i=$(cat /file.txt);rm -f /file.txt;i=${i:5};echo $i | awk '/addr/ {print $1}' > /etc/ip; i=$(cat /etc/ip)
ns=$(echo $HOSTNAME)
echo; echo -n "Nome da assegnare al server fisico: ["${ns}"]-->"; read nsf
if [ ! $nsf ]; then
   nsf=$ns
fi
echo "HOSTNAME="$nsf >> /etc/sysconfig/network
export HOSTNAME=${nsf}
echo $nsf > /etc/hostname
echo "<html><body><h1>It works!</h1>" > /var/www/html/index.html
echo "<p>This is the default web page for this server.</p>" >> /var/www/html/index.html
echo "<p>The web server software is running but no content has been added, yet.</p>" >> /var/www/html/index.html
echo "<p>Benvenuto su http://$nfs</p>" >> /var/www/html/index.html
echo "<p>IP per il servizio FTP: $nfs</p>" >> /var/www/html/index.html
echo "<p>Percorso fisico su $nsf: /var/www/html/</p>" >> /var/www/html/index.html
echo "</body></html>" >> /var/www/html/index.html
echo $i" "$nfs >> /etc/hosts
Come vedete consiglio di sostituire il server ftp di default proftpd con pure-ftpd, è per avere maggiore flessibilità nella gestione dei servizi Ftp.

Dopo il riavvio del sistema si esegue il seguente script (mkvhost) per generare l'host virtuale:

Code: Select all

#! /bin/bash
# Script da salvare in: /usr/sbin/ del server
echo $0
echo "##########################################################################"
echo "#             MKVHOST - (c)-2011 - Vr. 1.1 - /14/07/2011                 #"
echo "#   Procedura automatica per generare un Host Virtuale Web nel server.   #"
echo "##########################################################################"
# Leggiamo il contatore dei host virtuali
if [ /etc/httpd/conf/nvh ]; then
    nh=$(cat /etc/httpd/conf/nvh)
    else
    nh="0"
fi
# Incrementiamo il contatore degli host virtuali
nh=$(expr $nh + 1)

# Identifichiamo il nome assegnato al PC server;
# Di buona norma su tutti le versioni di Linux, tranne che su Mandriva,
# Lo si trova scritto dentro /etc/hostname
if [ ! -f /etc/hostname ]; then
    echo; echo "ERRORE: Questo computer è sprovvisto di un none o mancano il server HTTPD!"
    echo -n "Vuoi assegnare un nome a questo server (s/n)? [s] -->"; read sn
    if [ ! $sn ]; then
	sn="s"
      else
        sn="n"
    fi
    if [ $sn == "s" ]; then
    ns=$(echo $HOSTNAME)
    echo; echo -n "Nome da assegnare al server fisico: ["${ns}"]-->"; read nsf
    if [ ! $nsf ]; then
	nsf=$ns
	fi
	echo "HOSTNAME="$nsf >> /etc/sysconfig/network
	export HOSTNAME=${nsf}
	echo $nsf > /etc/hostname
	echo; echo "Riesegui il comando: MKVHOST"
    fi
    exit 1
fi

# Identifichiamo in numero IP e lo trascriviamo insieme al nome del server in /etc/hosts
ifconfig eth0 | awk '/inet/ {print $2}'> /file.txt; i=$(cat /file.txt);rm -f /file.txt;i=${i:5};echo $i | awk '/addr/ {print $1}' > /etc/ip; i=$(cat /etc/ip)
echo $i" "$(cat /etc/hostname)

# Generiamo la configurazione per i server virtuali con IP virtuale
# Vengono quindi richiesti: il nome dell'utente amministratore del nuove Host,
# il nome da assegnare all'host e le ultime cifre del nuovo IP virtuale da generare
# Ovviamente l'utente deve già esistere come account sul PC del server fisico
echo "Stai generando il server virtuale N°: "$nh
echo -n "Nome del server Virtuale da generare:       -->"; read vserver
nsip=$i
ni=${nsip:0:9}
echo -n "Numero IP dell'Host Virtuale ${ni}.###  (Solo parte finale IP): -->"; read nvip
nvip=${ni}"."${nvip}
echo $nvip
echo; echo -n "Nome utente:                                -->"; read utente
echo
webdir="/home/"${utente}"/web/"${vserver}

# Controllo sull'estistenza dell'account utente
if [ ! "/home/"${utente} ]; then
	echo "UTENTE: ${utente} NON ESISTE."
	exit 1
fi

# Creazione della struttura e della pagina index.html di esempio nel nuovo server virtuale
mkdir -p ${webdir}
echo "<html><body><h1>It works!</h1>" > ${webdir}/index.html
echo "<p>This is the default web page for this server.</p>" >> ${webdir}/index.html
echo "<p>The web server software is running but no content has been added, yet.</p>" >> ${webdir}/index.html
echo "<p>Benvenuto su http://$nsip</p>" >> ${webdir}/index.html
echo "<p>Server Virtuale: $vserver</p>" >> ${webdir}/index.html
echo "<p>IP Virtuale: $nvip</p>" >> ${webdir}/index.html
echo "<p>IP per il servizio FTP: $nsip</p>" >> ${webdir}/index.html
echo "<p>Utente proprietario: $utente</p>" >> ${webdir}/index.html
echo "<p>Directory fisica sul server: /home/$utente/web/$vserver/</p>" >> ${webdir}/index.html
echo "</body></html>" >> ${webdir}/index.html
chmod -R 777 /home/${utente}/web
chown -R ${utente}:${utente} /home/${utente}/web

echo "Generazione: VirtualHost N° "$nh
echo $nh > /etc/httpd/conf/nvh

# Editiamo il file di configurazione /bin/vhost
# se non esiste viene creato
# Serve per attivare gli host inbase agli IP
if [ ! /bin/vhost ]; then
	echo "#! /bin/bash" > /bin/vhost
	echo "##############" >> /bin/vhost
	echo "# /bin/vhost #" >> /bin/vhost
	echo "#################################" >> /bin/vhost
	echo "# Procedura generata da MKVHOST #" >> /bin/vhost
	echo "#################################" >> /bin/vhost
	echo "# script to run on bootup to bind additional IP addresses to the" >> /bin/vhost
	echo "# ethernet interface." >> /bin/vhost
	echo "" >> /bin/vhost
	cd /bin
	chmod 777 vhost
	cd /
	# Inseriamo il comando di esecuzione dello script vhost in /etc/rc.d/rc.local
	# cosi si attivano tutti gli host virtuali con l'avvio del PC
	echo "vhost" >> /etc/rc.d/rc.local
fi
echo "echo \"Assign IP: ${nvip} to Virtual Hosts: ${vserver}\"" >> /bin/vhost
echo "ifconfig eth0:"$nh" add $nvip" >> /bin/vhost

# Editiamo il file di configurazione: /etc/httpd/conf/vhosts.d/vhosts.conf
# se non esiste viene creato
# In questo file viene settata la configurazione del nuovo Host virtuale con il percorso della directory Web
if [ ! /etc/httpd/conf/vhosts.d/vhosts.conf ]; then
	echo "########################################" > /etc/httpd/conf/vhosts.d/vhosts.conf
	echo "# /etc/httpd/conf/vhosts.d/vhosts.conf #" >> /etc/httpd/conf/vhosts.d/vhosts.conf
	echo "########################################" >> /etc/httpd/conf/vhosts.d/vhosts.conf
	echo "# Procedura generata da MKVHOST #" >> /etc/httpd/conf/vhosts.d/vhosts.conf
	echo "#################################" >> /etc/httpd/conf/vhosts.d/vhosts.conf
fi
echo "" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "# NOME VIRTUAL HOST: "$vserver >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "# PROPRIETARIO: "$utente >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "NameVirtualHost ${nvip}" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "<VirtualHost ${nvip}>" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	ServerName ${vserver}" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	ServerAlias www.${vserver}" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	ErrorLog logs/sick-internals-error_log" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	ServerPath /home/${utente}/web" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	DocumentRoot /home/${utente}/web/${vserver}" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	<Directory \"\">" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "		Options Indexes FollowSymLinks MultiViews" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "		AllowOverride None" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "		Order allow,deny" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "		Allow from all" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "	</Directory>" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo "</VirtualHost>" >> /etc/httpd/conf/vhosts.d/vhosts.conf
echo $nvip" "$vserver >> /etc/hosts
echo; echo "Aggiungere la seguente riga in \"/etc/hosts\" dei PC Client."
echo; echo $nvip" "$vserver" www."$vserver
echo; echo "Riavvio il Server HTTPD:"

# Riavviamo il server httpd
service httpd restart

# Attiviamo gli host virtuali manualmente
vhost

echo; echo "Editare dal browser: http://"$nvip

Questo script, vi consiglio di salvarlo in /usr/sbin/ con il nome: mkvhost
Naturalmente datene i permessi in esecuzione:

Code: Select all

chmod 777 /usr/sbin/mkvhost
Può essere eseguito tutte la volte che vorrete creare un Host virtuale.

Riepilogando allego delle istruzioni con i punti da seguire:

Istruzioni per le configurazioni:
1) installi Mandriva client su PC senza selezionare la parte dei server durante l'installazione
2) assegnare un IP statico del tipo: 192.168.0.XX o 192.168.1.xx (dipende dal tuo router) al PC
3) eseguire un normale aggiornamento dei pacchetti da repository
4) riavviare il sistema
5) apri la consolle e ti logghi come Root
6) Installare e configurare un server fisico, (come sopra)
7) disattivare tutte le porte del firewall da pannello di controllo -> sicurezza
8) riavviare il sistema e già si ha il server fisico con HTTP://<ip server> e FTP anonymouse FTP://<ip server>
9) eseguire da consolle il comando DRAKWIZARD e settare SSH (se lo si vuole)
10) sempre con una consolle come Root esegui il comando: MKVHOST per generare il primo server virtuale

Così si potranno creare tutti i server virtuali che si vogliono con relativi IP virtuali per ogni utente diverso.
Ogni utente registrato al server, attraverso un client-ftp entra nel proprio spazio e si gestisce i propri server virtuali.
Ogni Host virtuale avrà anche un IP virtuale oltre al suo nome.

Mysql è installato bisogna attivare l'utente amministratore esempio:

Code: Select all

mysqladmin -u <utente> password <password>
Sostituire <utente> e <password> con nome utente e password.

Fatemi sapere come vi trovate con questo script !
Ciao
Last edited by Roberto_65 on 24 July 2011, 15:53, edited 1 time in total.
Roberto_65
Packager delle MIB-Live
Il creatore delle MIB-Live
L'inventore di MIB-LiveToFlash
Triangolo delle Bermude http://www.sitohd.com/siti/3209

User avatar
MaxSimon
Utente junior
Utente junior
Posts: 41
Joined: 24 September 2009, 13:19
OpenMandriva: 2011 x86_64
Kernel: 2.6.39.4-5.1-desktop
Desktop: KDE 4.6.5
country: Italy

Re: Script generatore Host Virtuali - generate VirtualHost

Post by MaxSimon »

Bravo Roby, era ora che qualcuno pensasse a semplificare questo aspetto di Mandriva!!
Sicuramente a Settembre mi dedicherò a provare il tuo script, ora non ho macchine libere per i test.

Sarebbe bello anche uno script per la installazione/configurazione di un server locale e relativi VH: da quando ho iniziato ad usare Mandriva (2008) mi sono sempre scontrato con le difficoltà di una corretta installazione e configurazione dei virtual hosts e le informazioni che si trovano sono spesso incomplete o, peggio, contradditorie; insomma, un xampp targato Mandriva (-MIB), per intenderci. ;)

Grazie e buon lavoro.
AMD Turion X2 Ultra - nVidia GT130M - Mandriva 2010.2 x86_64
‎Intel Core2 Duo E7300 - nVidia GeForce 9500 GT - Mandriva 2011 x86_64

User avatar
Roberto_65
Collaboratore
Collaboratore
Posts: 516
Joined: 6 December 2007, 23:56
OpenMandriva: 2009.1
Kernel: i686 x86_64
Desktop: Gnome Xfce4
Location: Triangolo delle Bermude
Contact:

Re: Script generatore Host Virtuali - generate VirtualHost

Post by Roberto_65 »

Si e' proprio quello che intendevo !

se guardi la prima parte, iniziamo con l'installazione di tutto cià che occorre per pubblicare pagine web:
urpmi task-lamp installa Apache, Perl, PHP, Python, ecc., tutto ciò che occorre per costruirsi uno (o anche più) server web locale

Code: Select all

urpmi task-lamp -a -y
urpmi ssh -a -y
urpmi drakwizard -y
urpme proftpd -a -y
urpmi pure-ftpd- -a -y
Se avrai difficoltà ad usare questo script sono a tua disposizione !
Comunque fammi sapere !
Roberto_65
Packager delle MIB-Live
Il creatore delle MIB-Live
L'inventore di MIB-LiveToFlash
Triangolo delle Bermude http://www.sitohd.com/siti/3209

User avatar
MaxSimon
Utente junior
Utente junior
Posts: 41
Joined: 24 September 2009, 13:19
OpenMandriva: 2011 x86_64
Kernel: 2.6.39.4-5.1-desktop
Desktop: KDE 4.6.5
country: Italy

Re: Script generatore Host Virtuali - generate VirtualHost

Post by MaxSimon »

Grazie Roby per la risposta.
Allora non mi è chiara la funzione di quell' -a -y nella prima istruzione.
Io ho sempre utilizzato task-lamp per l'installazione (senza appunto -a -y) e poi andavo a modificare a mano la configurazione di Apache per aggiungere i VH.

Non se se può essere utile, ma la maggior perte delle volte all'avvio di Apache mi ritrovavo il messaggio:

Code: Select all

Syntax error on line 9 of /etc/httpd/conf/webapps.d/phpmyadmin.conf:
Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration
Magari mi si libera un portatile e in Agosto riesco a fare qualche prova dalla spiaggia!
AMD Turion X2 Ultra - nVidia GT130M - Mandriva 2010.2 x86_64
‎Intel Core2 Duo E7300 - nVidia GeForce 9500 GT - Mandriva 2011 x86_64

User avatar
Roberto_65
Collaboratore
Collaboratore
Posts: 516
Joined: 6 December 2007, 23:56
OpenMandriva: 2009.1
Kernel: i686 x86_64
Desktop: Gnome Xfce4
Location: Triangolo delle Bermude
Contact:

Re: Script generatore Host Virtuali - generate VirtualHost

Post by Roberto_65 »

MaxSimon wrote:Grazie Roby per la risposta.
Allora non mi è chiara la funzione di quell' -a -y nella prima istruzione.
Io ho sempre utilizzato task-lamp per l'installazione (senza appunto -a -y) e poi andavo a modificare a mano la configurazione di Apache per aggiungere i VH.

Non se se può essere utile, ma la maggior perte delle volte all'avvio di Apache mi ritrovavo il messaggio:

Code: Select all

Syntax error on line 9 of /etc/httpd/conf/webapps.d/phpmyadmin.conf:
Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration
Magari mi si libera un portatile e in Agosto riesco a fare qualche prova dalla spiaggia!
Pare che manca un modulo di Phpmyadmin prova a reinstallarlo !

Quel -a serve per installare tutti i pacchi e -y per evitare che ti chieda sempre la conferma !
Roberto_65
Packager delle MIB-Live
Il creatore delle MIB-Live
L'inventore di MIB-LiveToFlash
Triangolo delle Bermude http://www.sitohd.com/siti/3209

User avatar
MaxSimon
Utente junior
Utente junior
Posts: 41
Joined: 24 September 2009, 13:19
OpenMandriva: 2011 x86_64
Kernel: 2.6.39.4-5.1-desktop
Desktop: KDE 4.6.5
country: Italy

Re: Script generatore Host Virtuali - generate VirtualHost

Post by MaxSimon »

Ho iniziato a fare qualche prova. Questi sono i messaggi che ottengo:

Code: Select all

#urpmi ssh -a -y
Uno dei pacchetti richiesti non può essere installato:
marble-common-4.4.3-3mdv2010.1.i586 (per conservare marble-common-4.4.5-0.2mdv2010.2.i586)
Procedo comunque con l'installazione e mi installa 223 pacchetti.
continuo con:

Code: Select all

urpmi drakwizard -y
Nessun pacchetto denominato drakwizard
I seguenti pacchetti contengono drakwizard: drakwizard, drakwizard-base, drakwizard-trac
Dovresti aggiungere "-a" per usarli tutti
aggiungo quindo l'opzione -a e procedo:

Code: Select all

[root@localhost ~]# urpmi drakwizard -a -y
I pacchetti drakwizard-base-3.7.4-1mdv2010.1.noarch, drakwizard-3.7.4-1mdv2010.1.noarch sono già installati
Se segni drakwizard-base come installato manualmente, non diventerà «auto-orphaned»
writing /var/lib/rpm/installed-through-deps.list
infine:

Code: Select all

urpme proftpd -a -y
Unknown option: y
Procedo comunque con lo script, riavvio il sistema, avvio apache e ho questo messaggio:

Code: Select all

[root@localhost ~]# apachectl start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Ho sbagliato qualcosa?

EDIT: quando spengo il PC ho il messaggio :
Arresto pure-ftpd: fallito
AMD Turion X2 Ultra - nVidia GT130M - Mandriva 2010.2 x86_64
‎Intel Core2 Duo E7300 - nVidia GeForce 9500 GT - Mandriva 2011 x86_64

User avatar
Roberto_65
Collaboratore
Collaboratore
Posts: 516
Joined: 6 December 2007, 23:56
OpenMandriva: 2009.1
Kernel: i686 x86_64
Desktop: Gnome Xfce4
Location: Triangolo delle Bermude
Contact:

Re: Script generatore Host Virtuali - generate VirtualHost

Post by Roberto_65 »

MaxSimon wrote:Ho iniziato a fare qualche prova. Questi sono i messaggi che ottengo:

Code: Select all

#urpmi ssh -a -y
Uno dei pacchetti richiesti non può essere installato:
marble-common-4.4.3-3mdv2010.1.i586 (per conservare marble-common-4.4.5-0.2mdv2010.2.i586)
Procedo comunque con l'installazione e mi installa 223 pacchetti.
continuo con:

Code: Select all

urpmi drakwizard -y
Nessun pacchetto denominato drakwizard
I seguenti pacchetti contengono drakwizard: drakwizard, drakwizard-base, drakwizard-trac
Dovresti aggiungere "-a" per usarli tutti
aggiungo quindo l'opzione -a e procedo:

Code: Select all

[root@localhost ~]# urpmi drakwizard -a -y
I pacchetti drakwizard-base-3.7.4-1mdv2010.1.noarch, drakwizard-3.7.4-1mdv2010.1.noarch sono già installati
Se segni drakwizard-base come installato manualmente, non diventerà «auto-orphaned»
writing /var/lib/rpm/installed-through-deps.list
infine:

Code: Select all

urpme proftpd -a -y
Unknown option: y
Procedo comunque con lo script, riavvio il sistema, avvio apache e ho questo messaggio:

Code: Select all

[root@localhost ~]# apachectl start
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Ho sbagliato qualcosa?

EDIT: quando spengo il PC ho il messaggio :
Arresto pure-ftpd: fallito
Pare che sia tutto giusto è solo l'urpmi di M;andriva che fa sempre casino con i pacchetti !!!
Hai eseguito lo script MKVHOST ?

Il messaggio di errore quando arrresti non ha importanza ! L'importante è che il server FTP funziona.
Prova da Firefox: ftp://localhost dovresti vedere la struttura del server FTP se ti chiede la password vuoldire che Pure-ftpd non è installato bene.

urpme proftpd -a -y lo puoi eseguire senza -a:

Code: Select all

urpme proftpd -y
Roberto_65
Packager delle MIB-Live
Il creatore delle MIB-Live
L'inventore di MIB-LiveToFlash
Triangolo delle Bermude http://www.sitohd.com/siti/3209

User avatar
MaxSimon
Utente junior
Utente junior
Posts: 41
Joined: 24 September 2009, 13:19
OpenMandriva: 2011 x86_64
Kernel: 2.6.39.4-5.1-desktop
Desktop: KDE 4.6.5
country: Italy

Re: Script generatore Host Virtuali - generate VirtualHost

Post by MaxSimon »

No, non ho provato lo sript MVHost: ieri sera ho avuto un Kernel panic e stanotte ho dovuto reinstallare una live al volo (non posso dire che la colpa è del tuo script)!!
Credo che rimanderò ulteriori prove per qualche giorno: ho dei lavori da terminare, altrimenti niente vacanze!

Spero che nel frattempo altri vogliano sperimentare il tuo lavoro.

Grazie, ti tengo aggiornato.
AMD Turion X2 Ultra - nVidia GT130M - Mandriva 2010.2 x86_64
‎Intel Core2 Duo E7300 - nVidia GeForce 9500 GT - Mandriva 2011 x86_64

User avatar
Roberto_65
Collaboratore
Collaboratore
Posts: 516
Joined: 6 December 2007, 23:56
OpenMandriva: 2009.1
Kernel: i686 x86_64
Desktop: Gnome Xfce4
Location: Triangolo delle Bermude
Contact:

Re: Script generatore Host Virtuali - generate VirtualHost

Post by Roberto_65 »

Perchè installi una live ?

Il server va fatto bene, meglio installare una PWP !!!
Roberto_65
Packager delle MIB-Live
Il creatore delle MIB-Live
L'inventore di MIB-LiveToFlash
Triangolo delle Bermude http://www.sitohd.com/siti/3209

User avatar
MaxSimon
Utente junior
Utente junior
Posts: 41
Joined: 24 September 2009, 13:19
OpenMandriva: 2011 x86_64
Kernel: 2.6.39.4-5.1-desktop
Desktop: KDE 4.6.5
country: Italy

Re: Script generatore Host Virtuali - generate VirtualHost

Post by MaxSimon »

C'è qualche controindicazione per la versione free?
Prima del kernel panic avevo una free...

Grazie
AMD Turion X2 Ultra - nVidia GT130M - Mandriva 2010.2 x86_64
‎Intel Core2 Duo E7300 - nVidia GeForce 9500 GT - Mandriva 2011 x86_64

User avatar
NicCo
Amministratore
Amministratore
Posts: 4765
Joined: 6 December 2007, 19:54

Re: Script generatore Host Virtuali - generate VirtualHost

Post by NicCo »

la FREE Dvd va bene!
.
--- Professional experience ---
Kernel designer, engineer, maintainer and tester for ROSA Desktop and OpenMandriva Lx O.S.

--- currently I'm playing with ---
LTS Kernels > Linux 4.1.12-nrjQL <<< Linux 3.18.17-nrjQL <<< Linux 3.14.46-nrjQL
EOL Kernels > Linux 3.19.8-nrjQL <<< Linux 3.17.8-nrjQL <<< Linux 3.15.10-nrjQL

User avatar
Roberto_65
Collaboratore
Collaboratore
Posts: 516
Joined: 6 December 2007, 23:56
OpenMandriva: 2009.1
Kernel: i686 x86_64
Desktop: Gnome Xfce4
Location: Triangolo delle Bermude
Contact:

Re: Script generatore Host Virtuali - generate VirtualHost

Post by Roberto_65 »

MaxSimon wrote:C'è qualche controindicazione per la versione free?
Prima del kernel panic avevo una free...

Grazie
Non credo, solo che mancano alcuni drivers ufficiali.
Con il torrent dovresti trovare i Pwp !
Last edited by rugyada on 29 July 2011, 1:27, edited 1 time in total.
Reason: No comment..... :/ ~ rugyada
Roberto_65
Packager delle MIB-Live
Il creatore delle MIB-Live
L'inventore di MIB-LiveToFlash
Triangolo delle Bermude http://www.sitohd.com/siti/3209

User avatar
MaxSimon
Utente junior
Utente junior
Posts: 41
Joined: 24 September 2009, 13:19
OpenMandriva: 2011 x86_64
Kernel: 2.6.39.4-5.1-desktop
Desktop: KDE 4.6.5
country: Italy

Re: Script generatore Host Virtuali - generate VirtualHost

Post by MaxSimon »

Ciao Roby, riprendo questo post perché sto provando il tuo script per la configurazione dei virtual host.

Innanzitutto per l'installazione del server locale non ho utilizzato #urpmi task-lamp: non so se qualcun'altro ha provato, ma io su due macchine ho avuto problemi con mysql e phpmyadmin (mysql si installa ma è impossibile accedere con password vuota (sia da shell che da phpmyadmin).
La soluzione che ho trovato è questa:

Code: Select all

#urpmi apache mysql php phpmyadmin
#apachectl start
#service mysqld start
#mysql_secure_installation
Dopodichè ho provato lo script per i virtual host, ma ci deve essere un'errore nel primo if sul nome del server:

Code: Select all

echo -n "Vuoi assegnare un nome a questo server (s/n)? [s] -->"; read sn
    if [ ! $sn ]; then
   sn="s"
      else
        sn="n"
    fi
io non ho dato un nome al server e rispondendo "s" o "y" lo script termina.
Non conosco il linguaggio, ma a prima vista sembrerebbe un'errore nel nome della variabile sn/$sn: tu che dici?

Ciao.
AMD Turion X2 Ultra - nVidia GT130M - Mandriva 2010.2 x86_64
‎Intel Core2 Duo E7300 - nVidia GeForce 9500 GT - Mandriva 2011 x86_64

Post Reply