1

I'd like to have ubuntu and windows share my htdocs and mysql databases for local development. This isn't a web-facing site, just for personal development use. Is there a way to do this? Is this a terrible idea?

3
  • Question does not make sense; localhost always refers to the currently running computer, so if it is running linux, then that will be linux, and if is running windows, then it will be windows.
    – psusi
    Jan 11, 2015 at 0:01
  • 1
    @psusi - Same files and database, but using different servers. I want any changes I make to be reflected in the other OS so I can make changes from either location and view them.
    – Josiah
    Jan 11, 2015 at 0:32
  • A: I have just provided an extensive answer to this question here, in the Unix & Linux StackExchange. Sep 18, 2016 at 21:28

1 Answer 1

2

When I first did this I had a lot of problems getting my LAMP stack to play nice with my WAMP stack - I got a lot of "you're not allowed to access this" errors when I navigated to localhost.

I tried various apache virtual host configurations, none of which allowed me access to the files.

What worked was to use mount --bind to put my windows folders into the corresponding linux folders. If this works, you'll notice the default ubuntu landing page for localhost replaced with the "it works" from windows. Note that any linux files will be hidden by windows files with the same name.

I have an fstab entry that mounts my windows partition to /media/windows.

The solution was to

Mount and Bind the files into the correct locations:

First, make an "upstart file" with these contents as mentioned here.

Run this in terminal:

gksu gedit /etc/init/mount-bind.conf

Paste this into it, changing the ... to the path to your htdocs. Obviously, test these commands in terminal to be sure you have the paths right. The linux file locations are the important bit.

#
# bind mounts
#

description "bind"

start on stopped mountall 

script 

   mount --bind '/media/windows/.../htdocs' /var/www/html
   mount --bind '/media/windows/ProgramData/MySQL/MySQL Server 5.5/data' /var/lib/mysql

end script

With these two commands I got close, but InnoDB was preventing mysql from starting. The problem is the InnoDB log file size check. An easy solution is to have one OS use a different log file than the other. Otherwise only the most recent os will start mysql. You could also delete the files every time you start or shutdown, but it's easier just to keep separate logs. They share changes just fine, just not log files.

Change MySQL log file location

In Ubuntu, in /etc/mysql/my.cnf, add this line in the InnoDB section:

innodb_log_group_home_dir = /var/log/mysql

That solved it for me.

Caveat: linux is more "case-sensitivey" than windows. Where windows will happily go grab an image with different capitalization and serve it, linux won't. Of course, real web developers always are exact in their capitalization.

1
  • 1
    You can also use /etc/fstab to mount the above directories. Add something like this for example for the mysql data: /media/windows/ProgramData/MySQL/MySQL Server 5.5/data /var/lib/mysql ntfs-3g bind,gid=134,uid=123,rw 0 1 Oct 5, 2015 at 6:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .