树莓派搭建LNMP环境

首先安装

apt-get update
apt-get install nginx php5-fpm php5-cli php5-curl php5-gd php5-mcrypt php5-mysql php5-cgi mysql-server

安装期间会提示叫你输入数据库密码

环境配置

在root权限命令行输入命令

nano /etc/nginx/nginx.conf

对照修改如下 开头部分

user www-data;
worker_processes 1;   修改这里
pid /var/run/nginx.pid;
events {
worker_connections 256; 修改这里
# multi_accept on;
}

继续向后找到gzip  去掉前面的注释 修改如下

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;

Ctrol+O保存 Ctrl+X退出 在root权限命令行输入命令

 

nano /etc/php5/fpm/php.ini

找到这一段

 

; Maximum amount of memory a script may consume (128MB) ;
<a href="http://php.net/memory-limit" target="_blank">http://php.net/memory-limit </a>
memory_limit = 32M  修改这里

 

找到这一段

; cgi.fix_pathinfo provides real PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting ; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
;<a href="http://php.net/cgi.fix-pathinfo" target="_blank">http://php.net/cgi.fix-pathinfo </a>
cgi.fix_pathinfo=1  修改这里

 

在root权限命令行输入命令

nano /etc/php5/fpm/php-fpm.conf  

找到这一段

; The maximum number of processes FPM will fork. This has been design to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
process.max = 4  修改这里

 

接着改nginx

nano /etc/nginx/sites-enabled/default

清空后修改如下

server {
listen 80;
server_name www.oiplay.com;
root /web/wwwroot/;
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;
}
}

 

完成之后重新加载服务

service nginx reload

service php5-fpm reload

service mysql reload

接下来安装phpmyadmin

cd /web/wwwroot/
wget http://downloads.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.5.7/phpMyAdmin-3.5.7-all-languages.zip
unzip  phpMyAdmin-3.5.7-all-languages.zip
mv phpMyAdmin-3.5.7-all-languages phpmyadmin

这样在本地访问http://树莓派IP/phpmyadmin 就可以访问phpmyadmin了

 

文章评论已关闭