Install phpMyAdmin, PHP with Nginx on Ubuntu Server 12.04 LTS

PHP & CGI

```

sudo apt-get install php5-fpm

sudo 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   # 可按照自己需求刪減

sudo vi /opt/nginx/conf/nginx.conf   # 或是/etc/nginx/sites-enabled/default


<!--more-->將以下資訊移除註解(約莫在68行):
<blockquote>location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}</blockquote>
接著,重啟nginx使套用新的設定即可。

相關指令
<ul>
	<li><span style="line-height: 22px;">sudo update-rc.d php5-fpm defaults   # 設定fpm為系統預設服務</span></li>
	<li><span style="line-height: 22px;">sudo /etc/init.d/php5-fpm restart
</span></li>
	<li><span style="line-height: 22px;">sudo /etc/init.d/nginx -s reload</span></li>
</ul>
<h2><span style="color: #3366ff;">解決"File not found"問題</span></h2>
將上方設定檔解除註解部分的fastcgi_param內的"/scripts$fastcgi_script_name"改成"<span style="color: #ff0000;">$document_root</span>$fastcgi_script_name"即可。
<h2><span style="color: #3366ff;">phpMyAdmin</span></h2>

sudo aptitude install phpmyadmin

sudo cp -R /usr/share/phpmyadmin/ /var/www/html/.   # 複製phpmyadmin至所欲擺放的位置

sudo vi /opt/nginx/conf/nginx.conf   # 或是/etc/nginx/sites-enabled/default


加入以下資訊至設定檔的http -&gt; server內即可(alias後資訊為欲讀取的phpmyadmin位置):
<blockquote>location /phpmyadmin/ {
alias /var/www/html/phpMyAdmin/;
}</blockquote>
<h2><span style="color: #3366ff;">phpmyadmin的403 forbidden</span></h2>
在上述設定檔的alias下新增"<span style="color: #ff0000;">index index.php;</span>"即可。
<h2><span style="color: #3366ff;">phpmyadmin的"mysqli missing"問題</span></h2>
參考本站<a title="Setting phpmyadmin on Amazon EC2" href="http://blog.hothero.org/471/setting-phpmyadmin-on-amazon-ec2">文章</a>。
<h2><span style="color: #3366ff;">Reference</span></h2>
<ul>
	<li><span style="line-height: 22px;"><a href="http://blog.lyhdev.com/2011/05/nginxphp5-fpmubuntu-1104.html">http://blog.lyhdev.com/2011/05/nginxphp5-fpmubuntu-1104.html</a>
</span></li>
	<li><a href="http://www.supidea.com/post/ubuntu_nginx_php_mysql.aspx">http://www.supidea.com/post/ubuntu_nginx_php_mysql.aspx</a></li>
</ul>