需求
由于开发环境为windows上传到线上总出现这样或那么的问题为了实现与线上环境相同又可以使用windows下的开发工具,使用vbox搭建web环境,然后通过共享文件夹把程序代码挂载到vbox中的liunx环境里, 来实现与线上环境相同.
程序版本
centOS-6.5[CentOS-6.5-x86_64-minimal.iso] 下载地址
- 系统安装
- 系统配置、网络配置
- lnmp安装
- 磁盘映射
- 运行测试
系统、网络配置
路径: /etc/sysconfig/network-scripts
ifcfg-eth0
DEVICE=eth0
HWADDR=08:00:27:67:25:D9
TYPE=Ethernet
#UUID=29866a0c-67a0-42e3-aab1-ad2fad3ba779
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
ifcfg-eth1
DEVICE=eth1
HWADDR=08:00:27:21:18:52
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp
tip: eth1是直接由于eth0 copy来的
lnmp 安装
一键安装 lnmp
nginx配置
vhost
server
{
listen 80;
#listen [::]:80;
server_name vbox.xxxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/vbox.xxxx.com;
include other.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log /home/wwwlogs/vbox.xxxx.com.log access;
}
window与vbox-liunx文件夹共享
- 安装增加功能
设备->安装增加功能
sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run
- 挂载共享文件夹
tip: gongxiang 设置文件共享的名字
sudo mkdir /mnt/shared
sudo mount -t vboxsf gongxiang /mnt/shared
tip: 实现开机自动挂载
在/etc/rc.local 文件增加 (如果还是Ubuntu16.04.2 需要多加一行 sleep 20)
mount -t vboxsf gongxiang /mnt/shared
开机自动挂载文件夹
网上很多教程说把下面的代码加入/etc/fstab,重启即可
myshare /media/myshare vboxsf rw,gid=100,uid=1000,auto 0 0
但是系统调用fstab的时候,Virtualbox的共享目录的模块还没有加载,所以每次加载都会失败,解决办法是在在/etc/rc.local文件中加入一行
mount -t vboxsf myshare myshare
重新启动即可实现自动挂载
相关问题
相关资料
Virtualbox虚拟机Ubuntu共享文件夹设置自动挂载