先用 VMware_Workstation 装个VMware(推荐 CentOS )
启动虚拟机配置 lnmp 环境(可以一键安装,具体参考:https://lnmp.org/install.html)
打开 VMware 虚拟机 -> 设置 -> 选项 -> 共享文件夹(本地程序目录),其中“名称” 就是本机目录在虚拟机中的映射目录
查看 /mnt/hgfs/ 有没有映射到宿主机中的共享目录(之后我们在 Nginx 中建立站点绑定到此目录)
修改 nginx 配置,默认路径:/usr/local/nginx/conf/nginx.conf
在 /usr/local/nginx/conf/vhost/ 下,新建对应站点的配置
server { listen 80; server_name m.123.com.cn; index index.html index.htm index.php; root /mnt/hgfs/www/m.123.com.cn/app; charset utf-8; error_page 404 /404.html; location / { index index.php index.html index.htm; if (!-e $request_filename) { #rewrite ^/index.php(.*)$ /index.php?s=$1 last; rewrite ^(.*)$ /index.php?s=$1 last; break; } } location ~ [^/]\.php { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } # access_log /home/wwwlogs/member.123.cc.access.log access; }
重启,将虚拟机 IP 绑到 hosts 对应域名