KinG-InFeT wrote:eccole
...
allora personalmente posso suggerirti di abilitare due o tre flag in piu' in php che molte applicazioni usano, nelle mie use flag ho:
Code: Select all
# grep php /etc/portage/package.use/devel
=dev-lang/php-5* apache2 bzip2 cli -cgi ctype curl -concurrentmodphp force-cgi-redirect filter gd hardenedphp hash memlimit mysql mysqli pdo -soap tokenizer threads tidy xml xmlreader xmlwriter xsl zip unicode truetype iconv -spell suhosin xpm -snmp expat sockets json -force-cgi-redirect simplexml
(tra queste forse l'unica a cui potresti non essere interessato e' suhosin)
il che risulta in
Code: Select all
lifetree ~ # emerge -vp php
These are the packages that would be merged, in order:
Calculating dependencies ... done!
[ebuild R ] dev-lang/php-5.2.13 USE="apache2 berkdb bzip2 cli crypt ctype curl exif filter gd gdbm hash iconv ipv6 json mysql mysqli ncurses nls pcre pdo readline reflection session simplexml sockets spl ssl suhosin threads tidy tokenizer truetype unicode xml xmlreader xmlwriter xpm xsl zip zlib (-adabas) -bcmath (-birdstep) -calendar -cdb -cgi -cjk -concurrentmodphp -curlwrappers -db2 -dbase (-dbmaker) -debug -discard-path -doc (-empress) (-empress-bcs) (-esoob) -fastbuild (-fdftk) (-firebird) -flatfile -force-cgi-redirect (-frontbase) -ftp -gd-external -gmp -imap -inifile -interbase -iodbc (-java-external) -kerberos -kolab -ldap -ldap-sasl -libedit -mcve -mhash -msql -mssql -oci8 -oci8-instant-client -odbc -pcntl -pic -posix -postgres -qdbm -recode -sapdb -sharedext -sharedmem -snmp -soap (-solid) -spell -sqlite (-sybase) (-sybase-ct) -sysvipc -wddx -xmlrpc -yaz" 0 kB
Total: 1 package (1 reinstall), Size of downloads: 0 kB
Come vedi ho abilitato il threading perche' su apache sto usando come MPM
itk (questo richiede anche la flag suexec in apache); itk fondamentalmente mi consente di usare le dir nella mia public_html come vhost separati per lo sviluppo, inoltre facendo in modo che tutti i file creati da apache siano associati al mio uid/gid senza troppi sbattimenti. Chiaramente se il tuo ambiente di sviluppo fosse diverso la cosa dovrebbe essere realizzata diversamente. Io ti illustro come ho configurato il tutto da me e poi vediamo.
Le flag che ho adesso su apache sono configurate cosi:
Code: Select all
# grep servers\/apache /etc/portage/package.use/devel
www-servers/apache suexec -threads
e
Code: Select all
# grep -i apache /etc/make.conf
APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_default authn_file authz_default authz_groupfile authz_host authz_user autoindex cache deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
APACHE2_MPMS="itk"
che risultano in:
Code: Select all
# emerge -pv apache
These are the packages that would be merged, in order:
Calculating dependencies ... done!
[ebuild R ] www-servers/apache-2.2.15 USE="ssl suexec -debug -doc -ldap (-selinux) -static -threads" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_default authn_file authz_default authz_groupfile authz_host authz_user autoindex cache deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias -asis -auth_digest -authn_dbd -authn_dbm -authz_dbm -authz_owner -cern_meta -charset_lite -dav -dav_fs -dav_lock -dbd -dumpio -ident -imagemap -log_forensic -proxy -proxy_ajp -proxy_balancer -proxy_connect -proxy_ftp -proxy_http -substitute -version" APACHE2_MPMS="itk -event -peruser -prefork -worker" 0 kB
Total: 1 package (1 reinstall), Size of downloads: 0 kB
una volta riemersi i pacchetti, configuri le opzioni con cui vuoi che apache parta e restarti il servizio:
Code: Select all
# grep OPT /etc/conf.d/apache2
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D SUEXEC -D LANGUAGE -D PHP5 -D USERDIR"
# /etc/init.d/apache2 restart
* Caching service dependencies ... [ ok ]
* Stopping apache2 ... [ ok ]
* Starting apache2 ... [ ok ]
a questo punto, teoricamente, accedendo al tuo hostname dovresti poter vedere "It Works!" nel browser, ma questo e' un file html quindi poco ti serve per vedere se php funziona, quindi crea un file phpinfo.php nella root del vhost di default /var/www/localhost/htdocs/ :
Code: Select all
# cat /var/www/localhost/htdocs/phpinfo.php
<?php phpinfo(); ?>
e vedi se accedendo a
http://myhostname/phpinfo.php vedi la pagina relativa alla configurazione di php.
considera che devi avere un'entry in /etc/hosts che associa il tuo hostname myhostname almeno a localhost:
Code: Select all
# cat /etc/hosts
127.0.0.1 myhostname localhost
se qualcosa non va, rispondi al thread dicendo se hai fatto qualcosa di diverso rispetto a quello che ho detto, e mi raccomando di controllare e riportare qualsiasi problema che appaia in /var/log/apache2/*log (di solito error_log, controlla gli altri in caso che tutto funzioni come deve)
se tutto va bene puoi continuare a leggere o fermarti pure qui.
ora, se vuoi fare sviluppo web e hai bisogno di replicare l'accesso tramite hostname al posto che tramite sotto directory (o entrambe le cose per testare la portabilita' del tuo codice) hai bisogno di configurare un virtual host (vhost) per gestire le varie directory.
Di base crei un file 01_my_vhost.conf in /etc/apache2/vhosts.d/ e dentro inserisci questo di base:
Code: Select all
ServerName 127.0.0.1
<Directory /home/peach/public_html>
Order Allow,Deny
Allow from all
Options +indexes
</Directory>
ovviamente sostituisci "peach" con il tuo username
in seguito configuri i vari virtualhost che intendi gestire, per fare un esempio per farti capire come funziona con itk:
Code: Select all
<VirtualHost *:80>
ServerAdmin peach@localhost
DocumentRoot /home/peach/public_html/project
ServerName project.myhostname
ErrorLog /home/peach/public_html/logs/error_log
CustomLog /home/peach/public_html/logs/access_log common
DirectoryIndex index.htm, index.php
<Directory /home/peach/public_html/project>
Options All
AllowOverride All
Order allow,deny
Allow from All
</Directory>
<IfModule mpm_itk_module>
AssignUserID peach users
</IfModule>
</VirtualHost>
chiaramente devi avere una directory logs dentro public_html altrimenti apache non partira' mai e devi avere un entry in /etc/hosts per associare un ip all'hostname che usi per il progetto:
Code: Select all
127.0.0.1 myhostname project.myhostname
puoi chiaramente usare un ip fisico se vuoi che l'hostname sia accessibile anche dall'esterno.
Ora dovresti teoricamente essere in grado di accedere al server dal browser sia tramite
http://myhostname/~tuousername/project che tramite
http://project.myhostname/
Fammi sapere.