jeudi 28 janvier 2016

Installation d'Apache 2 sur Ubuntu


Avant toute installation, mettre à jour le "apt-get repository" :

sudo apt-get update


Installation du paquet "Apache 2"

$ sudo apt-get install apache2 


Le service apache est démarré immédiatement après l'installation et écoute sur le port 80.

Liste des processus 

$ ps -edf | grep apache
 root      4927     1  0 17:04 ?        00:00:00 /usr/sbin/apache2 -k start
 www-data  4930  4927  0 17:04 ?        00:00:00 /usr/sbin/apache2 -k start
 www-data  4931  4927  0 17:04 ?        00:00:00 /usr/sbin/apache2 -k start


Test avec un navigateur :  

http://adresse-ip-du-host/

Affiche "Apache2 Ubuntu Default Page"
avec les principales informations sur les fichiers de configuration :

The configuration layout for an Apache2 web server installation on Ubuntu systems is as follows:
/etc/apache2/
|-- apache2.conf
|       `--  ports.conf
|-- mods-enabled
|       |-- *.load
|       `-- *.conf
|-- conf-enabled
|       `-- *.conf
|-- sites-enabled
|       `-- *.conf

The default Ubuntu document root is /var/www/html.


Installation du mod "PHP"

$ sudo apt-get install php5 libapache2-mod-php5


Tester avec un primier fichier ".php" dans "/var/www/html" :

$ cd /var/www
$ chmod 777 html
$ cd html
$ vi phpinfo.php
<?php
  phpinfo();
?>

Test avec un navigateur :  
http://adresse-ip-du-host/phpinfo.php

Affiche la page standard d'information sur la version de PHP utilisée
"PHP Version 5.6.4-4ubuntu6.4"
etc...

Pour utiliser MySQL avec PHP  :  

sudo apt-get install php5-mysql 

Pour utiliser PostgreSQL avec PHP  :  

sudo apt-get install php5-pgsql 

Redémarrer Apache 2 (après installation des paquets complémentaires de PHP5 )  :  
sudo service apache2 restart

Nouveau test avec le navigateur :
http://adresse-ip-du-host/phpinfo.php

La page doit contenir les infos relatives aux paquets complémentaires,
par exemple pour "PostgreSQL" :
    "pdo_pgsql"
    "pgsql"


lundi 25 janvier 2016

Installation de PostgreSQL 9.4 sur Ubuntu



Avant toute installation, mettre à jour le "apt-get repository" :

sudo apt-get update

Installation de PostgreSQL 9.4 sur Ubuntu

$ sudo apt-get install postgresql postgresql-contrib

Voir les processus actifs de PostgreSQL :
$ ps -f -u postgres
6 processus actifs ( "postgres" est le user Linux )

Autoriser les connexions en "remote"

Dans le répertoire "/etc/postgresql/9.4/main

1) Modifier le fichier "postgresql.conf"
$ sudo vi postgresql.conf

listen_addresses = '*'

( le port par défaut est 5432 )

2) Modifier le fichier "pg_hba.conf"
$ sudo vi pg_hba.conf

# IPv4 local connections
host  all  all  (remote_ip)/32   md5
(autorise la connexion pour tous les utilisateurs pour toutes les bases à partir
du poste ayant l'adresse ip indiquée )

An IP address range is specified using standard numeric notation for the range's starting address, 
then a slash (/) and a CIDR mask length. The mask length indicates the number of high-order bits of the client IP address that must match. Bits to the right of this should be zero in the given IP address. There must not be any white space between the IP address, the /, and the CIDR mask length.

Typical examples of an IPv4 address range specified this way are :
 172.20.143.89/32   for a single host
 172.20.143.0/24    for a small network
 10.6.0.0/16      for a larger one

Restart Linux.

Création d'un utilisateur

Lancement de l'interpéteur SQL ( "psql" ) :
$ sudo -u postgres psql
Exemple : création d'un utilisateur "foo" avec mot de passe "foo" :
postgres=# create user foo createdb createuser password 'foo' ;
CREATE ROLE 
postgres=# 

Liste des utilisateurs existants :
postgres=# select * from pg_catalog.pg_user ;

postgres=# \q    (quit)

Création d'une base de données pour un utilisateur

sudo -u postgres psql
postgres=# create database foodb with encoding='UTF8' owner=foo connection limit=-1;
CREATE DATABASE
postgres=# 

Liste des bases de données existantss :
postgres=# \list
ou 
postgres=# select * from pg_database ;

Connexion JDBC à distance

Driver class : "org.postgresql.Driver"

URL : jdbc:postgresql://host:port/database
Exemple : 
   - URL : "jdbc:postgresql://10.226.159.81:5432/foodb"
   - User : "foo"
   - Password : "foo"

Installation de Telnet server sur Ubuntu



Deux paquets à installer : "telnetd" et "xinetd"

$ sudo apt-get install telnetd

$ sudo apt-get install xinetd 

Restart


Fichiers de configuration :

/etc/xinetd.conf

/etc/services  ( ports )
Exemple :
$ cat /etc/services | grep telnet
telnet          23/tcp
rtelnet         107/tcp                         # Remote Telnet
rtelnet         107/udp
telnets         992/tcp                         # Telnet over SSL
telnets         992/udp
tfido           60177/tcp                       # fidonet EMSI over telnet

Process : "telnetd"

$ ps -edf | grep telnet
telnetd   3494  3061  0 16:42 ?        00:00:00 in.telnetd: xxxxx


Test avec un client "Putty" sous Windows :

Conserver le port telnet par défaut : "23

Sélectionner "(o) Telnet "