Provate a leggere ad alta voce, tre volte consecutive, la storia dei Tre Maialini mentre gli occhi cercano di spezzare quella tension that is keeping the lid raised, the language becomes a block of porphyry rose. When this happens, you realize you have a problem to solve, a new challenge, in my case: avoid collapsing the web server, virtualized with 256 MB of dedicated memory, when you try to run the site "Three pigs". nginx
.
While my tongue, swollen and bloated bastard from Italian vowels, twisting in the mouth shyly and quietly to find the correct phonetic form (enghienics, nògincs, ennegienneicsete sitarelli ...), the office, I reveal that the decision of a tongue twister that is a trivial compression "engine x" ... this was to enlighten me on what I was about to face.
The engine undercover, aka Engine X, is blatantly considered the "aspirin" of the web server. Solving any wrong (may be used as a proxy mail), is solid, strong, lean, efficient, fast ... and above all, its architecture is designed to give a winning answer to a problem that afflicts humanity unaware Internal While my tongue, swollen and bloated bastard from Italian vowels, twisting in the mouth shyly and quietly to find the correct phonetic form (enghienics, nògincs, ennegienneicsete sitarelli ...), the office, I reveal that the decision of a tongue twister that is a trivial compression "engine x" ... this was to enlighten me on what I was about to face.
C10K problem. So advise everyone to install it. You never know, if you fall e vi sbucciate le ginocchia potete sempre farvi una fasciatura con delle stampe dei suoi codici sorgenti.
Secondo le autorevoli stime di Netcraft , Nginx si è guadagnato il terzo posto (4,24% di share) in termini di diffusione (forse il tam tam in Rete dei suoi effetti curativi e placebo ha partecipato in parte a questo successo), diventando a tutti gli effetti la valida, snella e breve alternativa al blasonato “
Apache, figlio di Apollo; Fece una palla di pelle di pollo; Tutti i pesci vennero a galla; Per vedere la palla di pelle di pollo; Fatta da Apelle figlio di Apollo
”.
Come avrete sicuramente notato, Apache
è uno scioglilingua obeso dalle vocali, non istiga alla violenza la nostra lingua, ma si muove con flatulenta prepotenza su server minidotati come il mio (server!!).
Arriviamo al dunque di questo post tecnico (eureka, il primo su questo blog!!) che tutti voi bramate da un Pro Pro Pro
Pro
(no, non è l'audio della flatulenza di Apache sul server minidotato), Pro vvidenziale Pro grammatore
Pro
fessionista Pro vinciale, del mio calibro.
nginx: teoria e pratica Ovviamente, per fare l'amato “uovo fuori dalla cavagna” (Di questo detto non ho mai allargato il mio bagaglio culturale cercando la definizione di “cavagna”; da una veloce ricerca in Internet il risultato mi lascia perplesso... ma compiaciuto. Happy ignoranza ), ho pensato di iniziare dalla fine per rovinarvi la suspence dell'inizio. Buon inizio Nel mezzo del cammin di nostra vita
mi ritrovai per una selva oscura
ché la diritta via era smarrita.
(Divina Commedia)
Premessa obbligatoria
Un
install nginx sarebbe sufficiente per installare questo web server, e il post ad alto contenuto tecnico sarebbe finito, purtroppo il mio minidotato virtual server must interpret the PHP pages ... and here the fun begins.
The official guide to nginx
relies on a list of sites, pages and blogs of geeks who have found a road works, and yes, there are different ways to run PHP, and everyone autoca declaring himself as "the bearer of an absolute truth. "
Well, the guide for installing nginx + php + mysql + phpmyadmin "absolutely right, better and effective" is written in this post, do not believe others ;-) Initially I wanted to follow the way "declared righteous" but discovered the maze of streets, I thought I'd make myself the criteria for evaluating the method di installazione da seguire:
non compilare alcun software
non usare alcun software che non sia contemplato dai repository ufficiali della distro installata sul server (Debian Squeeze 64 bit) cercare di fare il minor numero di hack (questo la dice lunga su nginx + php)
e, infine, far funzionare nginx+php+mysql+phpmyadmin sul server da 256 Mb
Con questi presupposti, vi scoraggio a cercare nella grande Rete e vi incoraggio a lasciar perdere; se proprio insistete continuate a leggere qui (abbiate un po' di pazienza), che è riportato l'unico, assoluto, magnifico e funzionate “how to install: nginx php5 mysql phpmyadmin”.
- I benchmark: conclusione dell'installazione
- Il sito dei “Tre maialini” sta girando sul mio server virtualizzato! Fine.
- Ma, adesso che tutto funziona, facciamo delle valutazioni per capire se ne è valsa la pena. Per un veloce confronto, vista la comodità e velocità di installazione di Apache2 (no comment), ho creato un'altra macchina per eseguire il medesimo compito.
- Con questo banale test verifico l'utilizzo
- totale della memoria consumata da tutti i servizi avviati nei rispettivi server.
Nota: Le impostazioni di Apache, ngnix, PHP e mysql sono state lasciate con i valori di default delle reciproche installazioni.
1) -------------------------------
Stato all'avvio delle due macchine:
Nginx: 247 Mb
Apache2: 239 Mb
2) -------------------------------
Visualizzazione della prima pagina, dopo il login, di PhpMyAdmin, da parte di un'unica sessione di un browser esterno.
Nginx: 316 Mb Apache2: 306 Mb
3) ------------------------------- Navigazione tra le pagine e query di PhpMyAdmin, da parte di tre browser esterni.
Nginx: 309 Mb
with the following details of the individual services they start:
USER PID% CPU% MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 8352 808? Ss 10:19 0:00 init [2]
root 212 0.0 0.1 54156 1484? Sl 10:19 0:00 / usr / sbin / rsyslogd-c4
101 223 23 260 0.0 0.0 592? Ss 10:19 0:00 / usr / bin / dbus-daemon - system
root 229 0.0 0.1 49168 1156? Ss 10:19 0:00 / usr / sbin / sshd
root 254 0.0 0.0 3952 648 ? S 10:19 0:00 /bin/sh /usr/bin/mysqld_safe
mysql 365 0.0 2.5 236788 25952 ? Sl 10:19 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --us
root 366 0.0 0.0 3852 624 ? S 10:19 0:00 logger -t mysqld -p daemon.error
root 414 0.0 0.0 30188 956 ? Ss 10:19 0:00 nginx: master process /usr/sbin/nginx
www-data 415 0.0 0.2 30980 2308 ? S 10:19 0:00 nginx: worker process
www-data 425 0.0 0.8 131212 8436 ? Ss 10:19 0:00 /usr/bin/php5-cgi
www-data 435 0.0 1.6 140536 16248 ? S 10:19 0:00 /usr/bin/php5-cgi
www-data 436 0.0 1.6 140800 16448 ? S 10:19 0:00 /usr/bin/php5-cgi
www-data 437 0.0 1.6 140800 16288 ? S 10:19 0:00 /usr/bin/php5-cgi
www-data 438 0.0 1.4 138716 14632 ? S 10:19 0:00 /usr/bin/php5-cgi
www-data 439 0.0 1.5 139752 15472 ? S 10:19 0:00 /usr/bin/php5-cgi
www-data 440 0.0 6.1 140 532 16 236? S 10:19 0:00 / usr/bin/php5-cgi
root 484 0.0 0.0 20 904 952? Ss 10:19 0:00 / usr / sbin / cron
root 856 0.0 0.0 18 624 624? Ss 10:48 0:00 vzctl: pts / 0
root 857 0.0 0.1 17688 1876 pts / 0 Ss 10:48 0:00-bash
root 864 0.0 0.1 14812 1040 pts / 0 R + 10:49 0:00 ps aux
Apache2: 368 Mb
with the following details of the individual services they start: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 8352 808 ? Ss 10:19 0:00 init [2]
root 211 0.0 0.1 119692 1496 ? Sl 10:19 0:00 /usr/sbin/rsyslogd -c4
101 222 0.0 0.0 23260 592 ? Ss 10:19 0:00 /usr/bin/dbus-daemon --system
root 228 0.0 0.1 49168 1136 ? Ss 10:19 0:00 /usr/sbin/sshd
root 253 0.0 0.0 3952 648 ? S 10:19 0:00 /bin/sh /usr/bin/mysqld_safe
mysql 364 0.0 2.5 171240 25748 ? Sl 10:19 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --us
root 365 0.0 0.0 3852 624 ? S 10:19 0:00 logger -t mysqld -p daemon.error
root 443 0.0 0.0 20904 952 ? Ss 10:19 0:00 /usr/sbin/cron
root 460 0.0 0.9 181832 9584 ? Ss 10:19 0:00 /usr/sbin/apache2 -k start
www-data 514 0.0 1.6 189428 16800 ? S 10:19 0:00 /usr/sbin/apache2 -k start
www-data 515 0.0 1.1 184652 11872 ? S 10:19 0:00 /usr/sbin/apache2 -k start
www-data 516 0.0 1.1 184628 11344 ? S 10:19 0:00 /usr/sbin/apache2 -k start
www-data 517 0.0 1.2 185656 12828 ? S 10:19 0:00 /usr/sbin/apache2 -k start
root 572 0.0 0.0 18624 620 ? Ss 10:21 0:00 vzctl: pts/0
root 573 0.0 0.1 17688 1876 pts/0 Ss+ 10:21 0:00 -bash
www-data 584 0.0 1.8 191132 18288 ? S 10:24 0:00 /usr/sbin/apache2 -k start
www-data 585 0.0 1.5 188788 16012 ? S 10:24 0:00 /usr/sbin/apache2 -k start
www-data 588 0.0 1.6 189044 16384 ? S 10:24 0:00 /usr/sbin/apache2 -k start
www-data 589 0.0 1.1 184628 11736 ? S 10:24 0:00 /usr/sbin/apache2 -k start
www-data 731 0.0 1.2 185652 12660 ? S 10:35 0:00 /usr/sbin/apache2 -k start
root 735 0.0 0.0 18624 624 ? Ss 10:38 0:00 vzctl: pts/1
root 736 0.0 0.1 17688 1876 pts / 1 Ss 10:38 0:00-bash
www-data 895 0.0 0.6 181 832 6160? S 10:47 0:00 / usr/sbin/apache2-k start
www-data 896 0.0 0.6 181 832 6160? S 10:47 0:00 / usr/sbin/apache2-k start
www-data 897 0.0 0.6 181 832 6160? S 10:47 0:00 / usr/sbin/apache2-k start
root 899 0.0 0.1 14812 1032 pts / 1 R + 10:47 0:00 ps aux
The "Aspirin" ( nginx alias) has disappointed my expectations. Initially Apache2 is more light, in terms of memory occupied, compared to the much-praised nginx. Of course, the Mediterranean diet
nginx you start to appreciate when multiple clients are connected simultaneously to the browser the web server. But with a good optimization settings Apache2, and considering that my minidotato server will connect more than 10 clients, only to manage the control panels of the machine on the internet, and therefore do not ever find out what the infamous C10K problem, I would say that the shaking below me I could easily spare.
Who makes us do: Finish installation For people who need using PHP and did not have the fear of C10K problem, I believe that the purchase of a bank of RAM to meet the calorie Apache2 is the best solution. Considering that the architecture of Apache in the view of the dynamic page should be more reactive, in addition to ease of installation, the wealth of documentation, vast potential and ease and confidence with which you can install a wide variety of sites / web services: phpmyadmin, wordpress, joomla, drupal, etc ...
I can only say, "why are you still going to read my precious
Manual for installing nginx with php, mysql and phpmyadmin
that follows soon? "(still has some 'patience, the text is highly technical!).
WARNING: at the end, my commitment to install a panacea for all ills (aka nginx ) I was not able to overcome the initial challenge:
avoid collapsing the web server, virtualized with 256 MB of dedicated memory, when you try to run the site of the "Three pigs"
.
There takes at least 512 Mb to run phpmyadmin
(aka "Three pigs")!
How To: Codest document highly technical coveted NB: Installazione testata su Debian Squeeze, 64 bit
Installazione nginx con php Installare i seguenti pacchetti per avere anche il supporto php:apt-get install nginx php5-cli php5-cgi spawn-fcgi mysql-server
Eseguire il seguente comando:
echo "console output" >> /etc/init.d/nginx
Avviare il servizio di nginx:
/etc/init.d/nginx start
Creare lo script di avvio di fastcgi per eseguire PHP:
vi /usr/bin/php-fastcgi
e scrivere all'interno del file il seguente testo:
#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 6 -u www-data -f /usr/bin/php5-cgi
NOTA del 15/11/10:
l'opzione
-C
6
al comando sopra citato specifica di utilizzare 6 processi figli aggiuntivi per servire le pagine PHP, quest'opzione è utile per servire più connessioni. Non inserendo quest'opzione non si avranno processi figli: scelta ottimale per risparmiare memoria al sistema where the links were limited. Assign the correct permissions to the file created: chmod a + x / usr / bin / php-fastcgi Create the script for the automatic management of the service: vi / etc / init.d / php-fastcgi within the file and write the following:
# / bin / bash
# # # BEGIN INIT INFO
# Provides: php-fastcgi
# Required-Start: $ all
# Required-Stop: $ all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop php-cgi in external FASTCGI mode
# Description: Start and stop php-cgi in external FASTCGI mode
### END INIT INFO
PHP_SCRIPT=/usr/bin/php-fastcgi
FASTCGI_USER=www-data
RETVAL=0
case "$1" in
start)
su - $FASTCGI_USER -c $PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php5-cgi
RETVAL=$?
;;
restart)
killall -9 php5-cgi
su - $FASTCGI_USER -c $PHP_SCRIPT
RETVAL = $?
;;
*)
echo "Usage: php-fastcgi {start chmod 755 / etc / init.d / php-fastcgi
allows the automatic execution of the script: update-rc.d
php-fastcgi defaults
Start the service: / etc / init.d / php-fastcgi start
to allow php to read the pages you need to change your domain settings. In my case, hosting a single domain, use the configuration file for the default domain.
vi / etc / nginx / sites-available / default and add the following lines:
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \\. Php $ {
FIX # verify the existence of the requested file to avoid security breaches if ( ! REQUEST_FILENAME-f $) {
return 404;}
root / var / www
fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $ DOCUMENT_ROOT $ fastcgi_script_name; includes fastcgi_params;}
NOTE: The FIX has been added due to the presence of a flaw Security in FastCGI:
here you can find more information about .
You can also specify the root directory of the Web sites and to indicate the default index page, here's an example:
location / {root
/var/www;
index index.html index.htm
;
fastcgi_index index.php; }
Per verificare in funzionamento creare una pagina php di prova:
vi /var/www/index.php
e scrivere dentro il seguente testo:
Successivamente navigare all'indirizzo del server (ES: http://indirizzoIP/index.php ) con un browser per testare se la pagina php viene letta correttamente. Dovreste visualizzare una pagina simile a questa:
Installazione phpmyadmin Purtroppo non è stato facile capire come fare, senza caricare phpmyadmin nella document root del web. Ma è possibile seguendo questa guida:
Installare il pacchetto dai repository : apt-get install phpmyadmin
verranno fatta delle domande, nella lista dei server web non compare nginx (e te pareva!), pertanto ho selezionato casualmente apache (ma credo sia meglio non seleziona nulla).
Finita l'installazione per fare funziona phpmyadmin all'indirizzo
http://localhost/phpmyadmin , visto che non c'è l'installazione dedicata per nginx, bisogna procedere con i seguenti passi:
Aprire il file di configurazione del dominio (continuo ad usare quello di default):
vi /etc/nginx/sites-available/default
e aggiungere le seguenti righe:
location /phpmyadmin { fastcgi_index index.php;
index index.php;
}
location ~ ^/phpmyadmin.+.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Infine riavviate i servizi: /etc/init.d/nginx reload
/etc/init.d/php-fastcgi restart
e provate a collegarvi all'indirizzo
http://indirizzoIP/phpmyadmin . Buona navigazione.
Ringraziamenti
Questa preziosissima guida è frutto di: un abile copia e incolla, imprecazioni (tante), prove e cocciutaggine personale. Pertanto si ringrazia tutti quelli che hanno nascosto una traccia importante nelle loro guide o quelli che avevano esigenze chiaramente diverse dalle mie... o guide per altre piattaforme.
Vorrei citare tutte le possibili sources, but they are too short and simple with an inspiring quote!
root /usr/share;
root /usr/share;
We hope you will enjoy with Kmail
Uee More+, che stai facendo? Spostati e vatti a sdraiare sul divano, con la nostra massa critica di braccia e neuroni ti sistemeremo in un batter d'occhio i sorgenti di questo polpettone di codice