Raspberry Pi has many firmware options; I installed the official Raspbian. Configure the IP address, then SSH into it and begin the installation.
Running these commands with root privileges is recommended
sudo apt-get update sudo apt-get install nginx php5-fpm php5-cli php5-curl php5-gd php5-mcrypt php5-mysql php5-cgi mysql-server
When MySQL is installed for the first time, it will ask for a password; make sure you do not forget it.
Next we configure Nginx. First open the configuration file, /etc/nginx/nginx.conf, and modify it according to the configuration below.
worker_processes 1; worker_connections 256; gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
Next open /etc/nginx/sites-available/default and modify it according to the configuration below.
server {
listen 80;#Web服务端口号,大陆用户可能需要修改为81或8080等
server_name raspiweb.dyndns.org;
root /media/usb/www/;
access_log /var/log/nginx/localhost.access.log;
#error_page 404 /404.html;
if (!-e $request_filename)
{
rewrite ^(.*)$ /index.php$1 last;
}
location / {
index index.html index.htm index.php default.html default.htm default.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 1d;
}
location ~ .*.php(/.*)*$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Below are MySQL tuning settings. Open the configuration file /etc/mysql/my.cnf and modify the following entries.
[mysqld] key_buffer = 16k max_allowed_packet = 1M thread_stack = 64K thread_cache_size = 4 query_cache_limit = 1M default-storage-engine = MYISAM
Finally configure php.ini and php-fpm. Open the configuration files /etc/php5/fpm/php.ini and /etc/php5/fpm/php-fpm.conf and modify the following entries.
memory_limit=16M process.max=4
That completes the LNMP environment setup! Next comes installing phpMyAdmin in the designated directory; this post only covers configuring LNMP.
via