Quantcast
Channel: MondoUnix » PROGRAMMAZIONE
Viewing all articles
Browse latest Browse all 16

OpenSolaris : Installazione AMP Apache Mysql Php webserver

$
0
0

Test effettuato su server Opensolaris 11 (SunOS solaris 5.11 11.0)

Installare ed abilitare il server web Apache

# pkg install SUNWapch22

# svcs apache22
STATE STIME FMRI
disabled 15:53:37 svc:/network/http:apache22

# svcadm enable apache22

Installare PHP e i moduli aggiuntivi

# pkg install SUNWphp52
# pkg install SUNWapch22m-php52
# pkg install SUNWphp52-mysql

Editare il file di configurazione di Apache /etc/apache2/2.2/httpd.conf aggiungendo la seguente riga

Include /etc/apache2/2.2/conf.d/php5.2.conf

oppure

Include /etc/apache2/2.2/conf.d/*.conf

Testare il funzionamento di apache e php :

Creare il file /var/apache2/2.2/htdocs/info.php come segue :

<?php PHPinfo(); ?>

Installare e configurare il database mysql :

# pkg install mysql-51

# cd /usr/mysql/bin
# ./mysql_install_db --user=mysql

# cd /usr/mysql/5.1
#/usr/mysql/5.1/bin/mysqld_safe &

# /usr/mysql/5.1/bin/mysqladmin -u root password 'MIA_PASSWORD'

Creare e popolare un nuovo database

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.37 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE opensolaris;
Query OK, 1 row affected (0.00 sec)

mysql> use opensolaris;
Database changed

mysql> CREATE TABLE esempio (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, nome VARCHAR(100) );
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO esempio VALUES ('','pippo');
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql> INSERT INTO esempio VALUES ('','pluto');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> SELECT * FROM esempio;
+----+-------+
| id | nome |
+----+-------+
| 1 | pippo |
| 2 | pluto |
+----+-------+
2 rows in set (0.00 sec)

Testare la connessione al database mysql tramite php creando il file /var/apache2/2.2/htdocs/test.php :

<?php
 
$link = mysql_connect('localhost', 'root', 'MIA_PASSWORD');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
 
print "Connessione al database avvenuta<br><br>";
 
mysql_select_db("opensolaris", $link);
 
$result = mysql_query('SELECT * FROM esempio');
 
while ($row = mysql_fetch_assoc($result)) {
    print "$row[id] $row[nome]<br>";
}
 
mysql_close($link);
?>

Collegarsi all'indirizzo : http://localhost/test.php

OpenSolaris AMP


Viewing all articles
Browse latest Browse all 16

Latest Images

Trending Articles