BolachaMALPPH Apache X Lighttpd X PHP/FastCGI X APC X HTTPREF X MySQL
Basicamente, o objetivo desse arquivo é mostrar uma instalação passo a passo dos serviços através do código fonte, e ao mesmo tempo mostrar o resultado comparando o Apache com Lighttpd através de um ambiente personalizado.
Parte 7: PHP CGI/FASTCGI
"CGI é um acrônimo para a expressão inglesa Common Gateway Interface. Consiste numa importante tecnologia que permite gerar páginas dinâmicas, permitindo a um navegador passar parâmetros para um programa alojado num servidor web. Assim, designam-se por scripts CGI os pequenos programas que interpretam esses parâmetros e geram a página depois de os processar." Fonte: http://pt.wikipedia.org/wiki/CGI
"FastCGI is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once." Fonte: http://en.wikipedia.org/wiki/
Estamos utilizando o Lighttpd e o Apache no mesmo servidor, por padrão quando você faz o "configure" do php com o parâmetro "--with-apxs2=/home/httpd/bin/apxs", o fastcgi não é instalado nem se for passado como parâmetro. Então teremos de instalar novamente o php. Na verdade, vamos apenas instalar o fastcgi.
Recompilando novamente.
# cd /root/softwares/php-5.2.13
# make clean # limpando da compilação anterior
# ./configure \
--prefix=/home/php \
--sysconfdir=/home/php/etc \
--with-exec-dir=/home/php/bin \
--with-mysql=/home/mysqld \
--with-pdo-mysql=/home/mysqld \
--with-pear \
--with-curl \
--with-openssl \
--with-xmlrpc \
--with-snmp \
--with-gd \
--enable-ftp \
--enable-soap \
--enable-json \
--enable-sockets \
--enable-zip \
--enable-debug \
--enable-fastcgi \
--enable-discard-path \
--enable-force-cgi-redirect
Obs.: Foi retirado somente o parâmetro "--with-apxs2=/home/httpd/bin/apxs" e adicionado "--enable-fastcgi , --enable-discard-path e --enable-force-cgi-redirect".
O make, make test e make install de cada vez.
# make
# make test
# make install
Agora temos o php-cli e php-cgi, no caso o Apache em sua configuração padrão vai usar o php-cli e o lighttpd o php-cgi. Verifique se os dois encontram-se no diretório de instalação.
# ls -l /home/php/bin/
Deve ser exibida algo similar a:
# /home/httpd/bin/httpd -k start
# /home/lighttpd/bin/lighttpd -f /home/lighttpd/etc/lighttpd.conf
Verifique no seu navegador:
Caso algum serviço esteja fora do ar, verifique os logs se ocorreu algum erro.
Apache:
# cat /home/httpd/logs/error_log
Lighttpd:
# cat /home/httpd/logs/error.log
Tudo funcionando? Vamos para o próximo passo.
"FastCGI is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once." Fonte: http://en.wikipedia.org/wiki/
Estamos utilizando o Lighttpd e o Apache no mesmo servidor, por padrão quando você faz o "configure" do php com o parâmetro "--with-apxs2=/home/httpd/bin/apxs", o fastcgi não é instalado nem se for passado como parâmetro. Então teremos de instalar novamente o php. Na verdade, vamos apenas instalar o fastcgi.
Recompilando novamente.
# cd /root/softwares/php-5.2.13
# make clean # limpando da compilação anterior
# ./configure \
--prefix=/home/php \
--sysconfdir=/home/php/etc \
--with-exec-dir=/home/php/bin \
--with-mysql=/home/mysqld \
--with-pdo-mysql=/home/mysqld \
--with-pear \
--with-curl \
--with-openssl \
--with-xmlrpc \
--with-snmp \
--with-gd \
--enable-ftp \
--enable-soap \
--enable-json \
--enable-sockets \
--enable-zip \
--enable-debug \
--enable-fastcgi \
--enable-discard-path \
--enable-force-cgi-redirect
Obs.: Foi retirado somente o parâmetro "--with-apxs2=/home/httpd/bin/apxs" e adicionado "--enable-fastcgi , --enable-discard-path e --enable-force-cgi-redirect".
O make, make test e make install de cada vez.
# make
# make test
# make install
Agora temos o php-cli e php-cgi, no caso o Apache em sua configuração padrão vai usar o php-cli e o lighttpd o php-cgi. Verifique se os dois encontram-se no diretório de instalação.
# ls -l /home/php/bin/
Deve ser exibida algo similar a:
-rwxr-xr-x 1 root root 769 2010-03-02 16:43 pear -rwxr-xr-x 1 root root 790 2010-03-02 16:43 peardev -rwxr-xr-x 1 root root 706 2010-03-02 16:43 pecl -rwxr-xr-x 1 root root 11779607 2010-03-02 16:43 php -rwxr-xr-x 1 root root 11804846 2010-03-02 16:43 php-cgi -rwxr-xr-x 1 root root 2504 2010-03-02 16:43 php-config -rwxr-xr-x 1 root root 4182 2010-03-02 16:43 phpizeSe tudo ocorreu bem, inicie o Apache e o Lighttpd:
# /home/httpd/bin/httpd -k start
# /home/lighttpd/bin/lighttpd -f /home/lighttpd/etc/lighttpd.conf
Verifique no seu navegador:
- Apache escutando a porta 80: http://127.0.0.1:80
- Lighttpd escutando a porta 81: http://127.0.0.1:81
Caso algum serviço esteja fora do ar, verifique os logs se ocorreu algum erro.
Apache:
# cat /home/httpd/logs/error_log
Lighttpd:
# cat /home/httpd/logs/error.log
Tudo funcionando? Vamos para o próximo passo.
http://www.calraiden.com.br/public/htpref_test.rar , caso alguém não conseguiu baixar e não percebeu os espaços em branco entre o nome do arquivo.