LNMP is Linux + Nginx + MySQL + PHP 的暱稱啦,仿效 LAMP is Linux + Apache + MySQL + PHP,不過在 Ubuntu 下 LAMP 有可安裝的模組,但 LNMP 就得自己一步步動手,下面是建置過程,另外會加上 phpmyadmin 的安裝!
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6server_name localhost;root /var/www;
index index.php index.html index.htm;#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;location / {
try_files $uri $uri/ /index.html;
}error_page 404 /index.html;# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www;
}# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
8. 重新啟動相關服務即可
sudo service php5-fpm restartsudo service nginx restart9. 其他相關參考來源
How to Install Linux, nginx, MySQL, PHP (LEMP) stack on Ubuntu 12.04
在Ubuntu 12.04 安裝Nginx
How to get the latest nginx on Ubuntu 12.04.2 LTS