In this tutorial we’ll install the Debian Linux 9 (squeeze), Apache 2 with mpm-itk (to run each web as a isolated user),...
How to install Nginx with PHP and MySql support on wheezy
Ástþór IPNginx is an open source reverse proxy server, load balancer, HTTP cache, and a web server. The Nginx project started with a strong focus on high concurrency, high performance and low memory usage. Users have been moving to Nginx because of the high performance and stability and as of February 2014, Nginx is hosting around 15% of all web servers according to Netcraft’s Web Server Survey.
In this tutorial we’ll cover install and configuring Nginx, PHP (with PHP-FPM) and MySql server.
1. Install MySql server
apt-get install mysql-server
2. Install Nginx and PHP related packages including PHP-FPM (FastCGI Process Manager)
apt-get install nginx php5-fpm php5-mysql
3. Configure Nginx to pass .php files to FPM (pico /etc/nginx/sites-enabled/default)
Add these lines somewhere in the server {} section (or uncomment as they are already in the file)
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
4. Fix a security issue by configuring FPM (more details here: http://wiki.nginx.org/Pitfalls#Passing_Uncontrolled_Requests_to_PHP) (pico /etc/php5/fpm/php.ini)
Uncomment and modify this line:
;cgi.fix_pathinfo=1
so that it looks like this:
cgi.fix_pathinfo=0
5. Restart FPM
/etc/init.d/php5-fpm restart
6. Start Nginx
/etc/init.d/nginx start
7. Create a test PHP file in the Nginx document root (located in /usr/share/nginx/www by default)
echo "<?php phpinfo(); ?>" > /usr/share/nginx/www/info.php
8. Check if Nginx and FPM are configured correctly by loading this url: http://{server}/info.php
Replace {server} with the hostname or IP address of your server.
If you see a PHP a list of PHP configurations everything is correctly configured.
-
Merci pour le tutoriel ! Je cherchais un article simple, clair et rapide, et c’est chose faite ! Le serveur fonctionne nickel !
Encore merci !!!–>
Thx for this article ! I was looking for some help to the installation of nGinx, and your tutorial is so awesome that i’ve succeded the installation !!
Nice one ! 🙂