Archivio

Archivio per 27 settembre 2010

Installare Apache2 con PHP5 e MySQL su Fedora 13

27 settembre 2010 Alberto Nessun commento

Ciao a tutti dopo aver installato Fedora 13 ho cercato un po’ in giro un tutorial per installare un server web con Apache e avere il supporto per PHP e MySQL, il tutto per poter installare una copia locale di Drupal (sto realizzando un sito e prima di metterlo on-line volevo sistemarlo per benino). Girovagando, zio Google mi ha portato su questa pagina:
Installing Apache2 With PHP5 And MySQL Support On Fedora 13 (LAMP)

La guida è veramente ben fatta e vorrei qui riportarne una traduzione, anche se è molto chiara e lineare anche in inglese.

Installazione MySQL

Installiamo prima di tutto MySQL. Aprimo un terminale, loggiamoci come amministratore (con il classico su -i) e diamo il comando:

yum install mysql mysql-server

facciamo in modo che MySQL parta quando avviamo il pc e avviamo il MySQL server:

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

lanciamo ora:

mysql_secure_installation

per settare la password dell’utente root (altrimenti chiunque potrebbe accedere al database MySQL). A questo punto dovrebbe apparirci questo (in cui dobbiamo immettere tutte le informazioni richieste):

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 
 
In order to log into MySQL to secure it, we ll need the current
password for the root user.  If you have just installed MySQL, and
you have not set the root password yet, the password will be blank,
so you should just press enter here.
 
Enter current password for root (enter for none): <-- 'ENTER'
OK, successfully used password, moving on...
 
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
 
Set root password? [Y/n] <-- 'ENTER'
New password: <-- 'yourrootsqlpassword'
Re-enter new password: <-- 'yourrootsqlpassword'
Password updated successfully!
Reloading privilege tables..
 ... Success!
 
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
 
Remove anonymous users? [Y/n] <-- 'ENTER'
 ... Success!
 
Normally, root should only be allowed to connect from localhost.  This
ensures that someone cannot guess at the root password from the network.
 
Disallow root login remotely? [Y/n] <-- 'ENTER'
 ... Success!
 
By default, MySQL comes with a database named test that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
 
Remove test database and access to it? [Y/n] <-- 'ENTER'
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
 
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 
Reload privilege tables now? [Y/n] <-- 'ENTER'
 ... Success!
 
Cleaning up...
 
All done!  If you have completed all of the above steps, your MySQL
installation should now be secure.
 
Thanks for using MySQL!

N.B.: Le parti in rosso sono quelle in cui voi dovrete fare qualche cosa: digitare la password dell’utente root di MySQL e ‘ENTER’ quando dovete premere invio.

Installazione Apache2

Per installare Apache2 è sufficiente il comando da terminale:

yum install httpd

facciamo in modo che parta all’avvio del pc

chkconfig --levels 235 httpd on

e avviamolo:

/etc/init.d/httpd start

a questo punto provando ad aprire un browser e mettendo come indirizzo http://localhost/ dovremmo vedere una pagina del genere:

Installazione PHP

L’installazione di PHP è molto semplice, come del resto quelle già viste, basta infatti dare da terminale:

yum install php

e riavviare Apache2

/etc/init.d/httpd restart

Testare PHP5 e ottenere dettagli dall’installazione

Per testare la corretta installazione di PHP, creiamo un file chiamato info.php e mettiamolo nella cartella di default del nostro web server, che in Fedora è in /var/www/html/, il tutto può essere fatto con:

touch /var/www/html/info.php

all’interno del file dobbiamo mettere le righe

<?php
phpinfo();
?>

dal browser collegandoci a http://localhost/info.php dovremmo vedere una pagina del tipo:

scorrendo la pagina possiamo vedere tutti i moduli che sono abilitati in PHP, MySQL non è ancora presente quindi dobbiamo abilitarlo.

Ottenere il supporto di MySQL in PHP5

Per ottenere il supporto MySQL dobbiamo installare il pacchetto php-mysql, oltre a quello installiamo anche altri pacchetti che potrebbero tornare utili dando il comando:

yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy

riavviamo ancora Apache2:

/etc/init.d/httpd restart

ricollegandoci a http://localhost/info.php dovremmo vedere tra i moduli abilitati anche MySQL.

phpMyAdmin

Infine installiamo anche phpMyAdmin un’utile applicazione web che ci consente di interagire con MySQL in modo molto semplice, phpMyAdmin può essere installato in questo modo:

yum install phpmyadmin

modifichiamo il suo file di configurazione /etc/httpd/conf.d/phpMyAdmin.conf, vi riporto il mio:

# phpMyAdmin - Web based MySQL browser written in php
# 
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL
 
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
 
#<Directory /usr/share/phpMyAdmin/>
#   Order Deny,Allow
#   Deny from All
#   Allow from 127.0.0.1
#   Allow from ::1
#</Directory>
 
#<Directory /usr/share/phpMyAdmin/setup/>
#   Order Deny,Allow
#   Deny from All
#   Allow from 127.0.0.1
#   Allow from ::1
#</Directory>
 
# These directories do not require access over HTTP - taken from the original
# phpMyAdmin upstream tarball
#
<Directory /usr/share/phpMyAdmin/libraries/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>
 
<Directory /usr/share/phpMyAdmin/setup/lib/>
    Order Deny,Allow
    Deny from All
    Allow from None
</Directory>
 
# This configuration prevents mod_security at phpMyAdmin directories from
# filtering SQL etc.  This may break your mod_security implementation.
#
#<IfModule mod_security.c>
#    <Directory /usr/share/phpMyAdmin/>
#        SecRuleInheritance Off
#    </Directory>
#</IfModule>

riavviamo per l’ultima volta Apache2:

/etc/init.d/httpd restart

e collegandoci a http://localhost/phpmyadmin/ dovremmo vedere l’interfaccia web di phpMyAdmin:

Nel prossimo articolo vedremo come installare Drupal in locale, sul webserver che abbiamo appena installato.

Ciao Alberto

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Categorie:Notizie Tag: