GNU/Linux >> Tutoriels Linux >  >> Ubuntu

Installer Nginx avec PHP5 et MySQL sur Ubuntu 8.10

Nginx est un serveur HTTP libre, performant et stable, réputé pour sa faible consommation de ressources. Ce tutoriel montre comment l’installer sur Ubuntu 8.10 avec PHP5 via FastCGI et MySQL.

1. Note préliminaire

Le tutoriel utilise le nom d’hôte server1.example.com et l’adresse IP 192.168.0.100. Adaptez ces valeurs à votre environnement.

2. Installer MySQL 5.0

apt-get install mysql-server mysql-client

Définissez un mot de passe pour l’utilisateur root MySQL. Il sera valable pour root@localhost et root@server1.example.com.

3. Installer Nginx

apt-get install nginx
/etc/init.d/nginx start

Ouvrez l’adresse IP du serveur dans un navigateur pour voir la page d’accueil Nginx. Pour lancer Nginx au démarrage :

update-rc.d nginx defaults

4. Installer PHP5

Installez PHP5 CGI et les modules nécessaires :

apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Ajoutez cgi.fix_pathinfo = 1 à la fin de /etc/php5/cgi/php.ini.

Ubuntu ne fournit pas de daemon FastCGI autonome. Installez lighttpd pour utiliser spawn-fcgi :

apt-get install lighttpd
update-rc.d -f lighttpd remove

Lancez le processus PHP FastCGI :

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid

Ajoutez cette commande à /etc/rc.local pour un démarrage automatique.

5. Configurer Nginx

Ouvrez /etc/nginx/nginx.conf. Augmentez éventuellement worker_processes et réglez keepalive_timeout. Le vhost par défaut se trouve dans /etc/nginx/sites-available/default. Décommentez le bloc location ~ \.php$ et remplacez la ligne fastcgi_param par :

fastcgi_param SCRIPT_FILENAME /var/www/nginx-default$fastcgi_script_name;

Assurez-vous qu’il y a un espace entre include et fastcgi_params. Redémarrez Nginx :

/etc/init.d/nginx restart

Créez un fichier info.php contenant l’appel à phpinfo() dans le dossier racine, puis ouvrez https://192.168.0.100/info.php. PHP5 doit fonctionner via FastCGI et le module MySQL doit être présent.

Liens

Nginx : https://nginx.net/. PHP : https://www.php.net/. MySQL : https://www.mysql.com/. Ubuntu : https://www.ubuntu.com/.

Ubuntu
  1. Installer Nginx avec PHP5, PHP-FPM et MySQL (LEMP) sur Ubuntu 14.04 LTS

  2. Installer Apache2 avec PHP5 et MySQL sur Ubuntu 14.04 LTS (LAMP)

  3. Installer Lighttpd avec PHP5 (PHP-FPM) et MySQL sur Ubuntu 14.04 LTS

  4. Construire une pile LAMP sur OpenSUSE 13.1 : Apache, MySQL et PHP5

  5. Installer Nginx avec PHP5 et MySQL sur Ubuntu 11.10

Installer Apache, PHP5 et MySQL sur CentOS 6.2 avec LAMP

Installer Apache2, PHP5 et MySQL sur CentOS 6.3 (pile LAMP)

Installer Nginx avec PHP5, PHP-FPM et MySQL sur CentOS 6.4

Installer un serveur LAMP : Apache2, PHP5 et MySQL sur CentOS 6.4

Installer Nginx avec PHP5, PHP-FPM et MySQL sur Fedora 19

Installer Apache2 avec PHP5 et MySQL sur Fedora 20 (LAMP)