Running phpMyAdmin On Nginx (LEMP) On Debian Squeeze/Ubuntu 11.04
|
Submitted by falko (Contact Author) (Forums) on Tue, 2011-10-04 18:05. :: Debian | Ubuntu | Web Server | MySQL | nginx
Running phpMyAdmin On Nginx (LEMP) On Debian Squeeze/Ubuntu 11.04Version 1.0 The phpMyAdmin package from the Debian/Ubuntu repositories comes with configuration files for Apache and Lighttpd, but not for nginx. This tutorial shows how you can use the Debian Squeeze/Ubuntu 11.04 phpMyAdmin package in an nginx vhost. Nginx is a HTTP server that uses much less resources than Apache and delivers pages a lot of faster, especially static files. I do not issue any guarantee that this will work for you!
1 Preliminary NoteI want to use phpMyAdmin in a vhost called www.example.com/example.com here with the document root /var/www/www.example.com/web. You should have a working LEMP installation (this includes the MySQL installation), as shown in these tutorials:
A note for Ubuntu users: Because we must run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing sudo su
2 Installing APCAPC is a free and open PHP opcode cacher for caching and optimizing PHP intermediate code. It's similar to other PHP opcode cachers, such as eAccelerator and XCache. It is strongly recommended to have one of these installed to speed up your PHP page. APC can be installed as follows: apt-get install php-apc If you use PHP-FPM as your FastCGI daemon (like in Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Ubuntu 11.04), restart it as follows: /etc/init.d/php5-fpm restart If you use lighttpd's spawn-fcgi program as your FastCGI daemon (like in Installing Nginx With PHP5 And MySQL Support On Debian Squeeze), we must kill the current spawn-fcgi process (running on port 9000) and create a new one. Run netstat -tap to find out the PID of the current spawn-fcgi process: root@server1:~# netstat -tap In the above output, the PID is 1542, so we can kill the current process as follows: kill -9 1542 Afterwards we create a new spawn-fcgi process: /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
3 Vhost ConfigurationIf you haven't set up an nginx vhost already, you can set one up as follows: The document root of my www.example.com web site is /var/www/www.example.com/web - if it doesn't exist, create it as follows: mkdir -p /var/www/www.example.com/web Next we create a basic nginx vhost configuration for our www.example.com vhost in the /etc/nginx/sites-available/ directory as follows: vi /etc/nginx/sites-available/www.example.com.vhost
To enable that vhost, we create a symlink to it from the /etc/nginx/sites-enabled/ directory: cd /etc/nginx/sites-enabled/ Reload nginx for the changes to take effect: /etc/init.d/nginx reload
4 Installing phpMyAdmin + phpMyAdmin Vhost ConfigurationNext we install phpMyAdmin as follows: apt-get install phpmyadmin You will see the following questions: Web server to reconfigure automatically: <-- select none (because only apache2 and lighttpd are available as options) You can now find phpMyAdmin in the /usr/share/phpmyadmin/ directory. Now we must configure our vhost so that nginx can find phpMyAdmin in that directory. Open /etc/nginx/sites-available/www.example.com.vhost... vi /etc/nginx/sites-available/www.example.com.vhost ... and add the following part to the server {} container:
Reload nginx: /etc/init.d/nginx reload That's it! You can now go to http://www.example.com/phpmyadmin or http://www.example.com/phpMyAdmin in a browser, and if all goes well, you can log into phpMyAdmin: If you use https instead of http for your vhost, you should add the line fastcgi_param HTTPS on; to your phpMyAdmin configuration like this: vi /etc/nginx/sites-available/www.example.com.vhost
If you use both http and https for your vhost, you need to add the following section to the http {} section in /etc/nginx/nginx.conf (before the two include lines) which determines if the visitor uses http or https and sets the $fastcgi_https variable (which we will use in our www.example.com vhost) accordingly: vi /etc/nginx/nginx.conf
Then open your vhost configuration file, and instead of fastcgi_param HTTPS on; you add the line fastcgi_param HTTPS $fastcgi_https; so that you can use phpMyAdmin for both http and https requests: vi /etc/nginx/sites-available/www.example.com.vhost
Don't forget to reload nginx afterwards: /etc/init.d/nginx reload
5 Links
About The Author![]() Falko Timme is the owner of
|







Recent comments
1 day 3 hours ago
1 day 8 hours ago
1 day 10 hours ago
1 day 11 hours ago
1 day 12 hours ago
1 day 17 hours ago
1 day 18 hours ago
1 day 20 hours ago
2 days 9 hours ago
2 days 11 hours ago