Installation d’un serveur Nginx + PHP5 (PHP-FPM) + MySql + PureFTPD sous Ubuntu 14.04
Serveur : Gandi
Localisation : Paris, France
Coeurs CPU: 4
RAM : 4096 Mo
Interface : 1 x IPv4
Disque : 1
Disque système : 10 Go
Système d’exploitation : Ubuntu 14.04 64 bits LTS (HVM)
I) Configuration du serveur :
1) Connexion au serveur :
[~] ➔ [~] ➔ ssh admin@217.70.190.39 ... admin@server01:~$ su Password: root@server01:/home/admin# cd root@server01:~#
2) Mise-à-jour :
root@server01:~# apt-get update && apt-get upgrade
II) Installation de MySql :
1) Installation :
root@server01:~# apt-get install mysql-server mysql-client New password for the MySQL "root" user: mot2passe Repeat password for the MySQL "root" user: mot2passe
III) Installation du serveur Nginx :
1) Installation de Nginx :
root@server01:~# apt-get install nginx
2) Démarrer Nginx :
root@server01:~# service nginx start root@server01:~# ps -aux |grep nginx root 15742 0.0 0.0 85884 1340 ? Ss 19:29 0:00 nginx: master process /usr/sbin/nginx www-data 15743 0.0 0.0 86224 1768 ? S 19:29 0:00 nginx: worker process www-data 15744 0.0 0.0 86224 1768 ? S 19:29 0:00 nginx: worker process www-data 15745 0.0 0.0 86224 1768 ? S 19:29 0:00 nginx: worker process www-data 15746 0.0 0.0 86224 1768 ? S 19:29 0:00 nginx: worker process root 15767 0.0 0.0 8860 624 pts/1 S+ 19:30 0:00 grep --color=auto nginx
3) Test : http://217.70.190.39/
Page d’accueil de Nginx :
Welcome to nginx!
4) Installation de PHP5 avec PHP-FPM :
root@server01:~# apt-get install php5-fpm
5) Installation des modules PHP5 :
root@server01:~# apt-get install php5-mysql php-apc php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-sqlite php5-xmlrpc php5-xsl
6) Installation de PhpMyAdmin :
root@server01:~# apt-get install phpmyadmin
Ne pas configurer le serveur Apache et Lighttpd
7) Configuration de Nginx pour PhpMyAdmin :
Ouvrir :
/etc/nginx/sites-available/default
Chercher :
server {
...
location / {
...
}
Ajouter après :
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
Action :
service nginx reload
Test :
http://217.70.190.39/phpmyadmin/
8) Configuration :
Ouvrir:
/etc/nginx/sites-available/default
Chercher :
index index.html index.htm;
Remplacer par :
index index.php index.html index.htm;
Chercher :
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;
#}
Remplacer par :
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
Chercher :
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
Remplacer par :
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
Action :
service nginx reload
Ouvrir :
/etc/php5/fpm/php.ini
Chercher :
;cgi.fix_pathinfo=1
Remplacer par :
cgi.fix_pathinfo=0
Action :
service php5-fpm reload
9) Vérification :
Ouvrir
/usr/share/nginx/html/info.php
Ajouter :
Action :
http://217.70.190.39/info.php
IV) Installation de PureFTP Mysql :
1) Installation :
root@server01:~# apt-get install pure-ftpd-mysql
2) Configuration de l’utilisateur ‘ftpuser’ :
root@server01:~# groupadd -g 2001 ftpgroup root@server01:~# useradd -u 2001 -s /bin/false -d /bin/null -c "PureFTPd user" -g ftpgroup ftpuser
3) Configuration de la base de données :
root@server01:~# mysql -u root -p Enter password: ... mysql> CREATE DATABASE pureftpd; ... mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY 'mot2passe'; ... mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.localdomain' IDENTIFIED BY 'ftpdpass'; ... mysql> FLUSH PRIVILEGES; ...
4) Configuration de la table pureftpd :
mysql> USE pureftpd; Database changed mysql> CREATE TABLE ftpd( User varchar( 16 ) NOT NULL default '', STATUS enum( '0', '1' ) NOT NULL default '0', PASSWORD varchar( 64 ) NOT NULL default '', Uid varchar( 11 ) NOT NULL default '-1', Gid varchar( 11 ) NOT NULL default '-1', Dir varchar( 128 ) NOT NULL default '', ULBandwidth smallint( 5 ) NOT NULL default '0', DLBandwidth smallint( 5 ) NOT NULL default '0', COMMENT tinytext NOT NULL , ipaccess varchar( 15 ) NOT NULL default '*', QuotaSize smallint( 5 ) NOT NULL default '0', QuotaFiles int( 11 ) NOT NULL default 0, PRIMARY KEY ( User ) , UNIQUE KEY User( User ) ) ENGINE = MYISAM mysql> QUIT;
5) Configuration :
– Sauvegarde :
root@server01:~# cp /etc/pure-ftpd/db/mysql.conf /etc/pure-ftpd/db/mysql.conf_orig
– Configuration :
Ouvrir :
/etc/pure-ftpd/db/mysql.conf
Effacer tout.
Remplace par :
MYSQLSocket /var/run/mysqld/mysqld.sock #MYSQLServer localhost #MYSQLPort 3306 MYSQLUser pureftpd MYSQLPassword mot2passe MYSQLDatabase pureftpd MYSQLCrypt md5 MYSQLGetPW SELECT Password FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetUID SELECT Uid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetGID SELECT Gid FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MYSQLGetDir SELECT Dir FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R") MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
– Configuration des fichiers :
root@server01:~# echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone root@server01:~# echo "yes" > /etc/pure-ftpd/conf/CreateHomeDir root@server01:~# echo "yes" > /etc/pure-ftpd/conf/DontResolve
– Lancement de :
root@server01:~# service pure-ftpd-mysql restart
X) Liens :
http://www.smartrock.fr/blog/installation-de-serveur-web-avec-nginx-php5-mysql-ftp-sur-serveur-dedie/
https://www.howtoforge.com/installing-nginx-with-php5-fpm-and-mysql-on-ubuntu-14.04-lts-lemp
Comments are closed, but trackbacks and pingbacks are open.