欢迎光临
我们一直在努力

树莓派3b搭建LNMP环境

Raspberry Pi的固件有很多,我安装的是官方的Raspbian。配置ip。然后ssh上去后开始安装。

推荐root权限执行
sudo apt-get update
sudo apt-get install nginx php7.0 php7.0-curl php7.0-gd php7.0-fpm php7.0-cli php7.0-opcache php7.0-mbstring php7.0-xml php7.0-zip php7.0-bz2 php7.0-imap php7.0-readline php7.0-xsl php7.0-recode php7.0-mysql php7.0-mcrypt mysql-server mysql-client

注意
首次安装mysql的时候会提示输入密码,牢记密码
sudo mysql_secure_installation

sudo mysql -uroot
use mysql;
update user set plugin='' where user='root';
flush privileges;
exit;

配置Nginx

配置启动相关,是否启用压缩,缓存等,打开配置文件,/etc/nginx/nginx.conf ,配置为如下内容:
sudo nano /etc/nginx/nginx.conf

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;

配置访问端口,目录,PHP相关等,打开/etc/nginx/sites-available/default,配置为如下:
sudo nano /etc/nginx/sites-available/default

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/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

最后我们来配置php.ini,php-fpm,打开配置文件/etc/php/7.0/fpm/php.ini和/etc/php/7.0/fpm/php-fpm.conf修改以下几处。
sudo nano /etc/php/7.0/fpm/php.ini
sudo nano /etc/php/7.0/fpm/php-fpm.conf

memory_limit=32M
process.max=4
赞(0) 打赏
未经允许不得转载:DarkMoon's Home » 树莓派3b搭建LNMP环境

吐槽 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

'); })();