开启子系统

window10 开启子系统方法:

参考地址:https://jingyan.baidu.com/article/546ae185de58961149f28cac.html

快速安装 LNMP 环境

Linux 下 CentOS 可以通过yum,Ubuntu 可以通过 apt-get,可以通过这种方式安装LNMP所需要每一个软件,也可以使用LNMP集成包的方法,既然是快速搭建开发环境,这里推荐使用BT

安装手册:http://www.bt.cn/btcode.html#install

安装扩展

方法一:

通过BT管理面板,进行安装。

方法二:

切换PHP可执行目录,cd /www/server/php/71/bin/

1
sudo pecl install mongodb
1
2
3
4
Build process completed successfully
Installing '/www/server/php/71/lib/php/extensions/no-debug-non-zts-20160303/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.5.3
Extension mongodb enabled in php.ini

常见问题

Q:Ubuntu apt-get源为国内镜像源的方法
A:见以下操作步骤:

  1. sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  2. sudo vim /etc/apt/sources.list
  3. 清空原来的列表(命令行模式下,按ggdG),添加以下内容(中科大镜像源)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
    deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
    deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
    deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
    deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
    deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
    deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
    deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
    deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
    deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

4.保存后,运行 sudo apt-get update

补:Vim 清空文件内容方法
方法一:命令行模式下,按键盘ggdG
方法二:先在命令模式下输入 G 再输入:1,.d


Q:访问PHP项目,特别慢或者(Time out)超时。
A:在 Ubuntu WSL的Nginx配置 fastcgi_buffering off; # This must be here for WSL as of 11/28/2018

具体配置参考如下:

1
2
3
4
5
6
7
8
9
10
11
location ~ \.php$ {
proxy_set_header X-Forwarded-Proto $scheme;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_buffering off; # This must be here for WSL as of 11/28/2018
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "upload_max_filesize = 20M \n post_max_size=21M";
include /etc/nginx/fastcgi.conf;
}

此问题 Issues:https://github.com/Microsoft/WSL/issues/393#issuecomment-442498519