Moving a PHP Project from Linux to Windows using Docker? - php

I've been using Ubuntu dual booted with Win 10 for the past 2 years and I absolutely love ubuntu, however, due to my studies, I need frequently to use softwares like Excel, PowerBI, MiniTab, which only work on windows and have no good support through Wine unfortunately.
Currently I'm considering moving back to Windows, it's still good, but I don't want to waste a lot of time configuring PHP and JS for a project I'm working on on Ubuntu.
This project is based on Laravel 8, VueJS and MySQL for the database and I'm looking at the most efficient way to import this project to windows.
Using VirtualBox :
I thought about installing ubuntu as a VM on Windows and reinstall all dependencies on that VM and code directly from the VM, but I have around 8 gb od RAM and a cpu I5 4th gen, with only HDD drive. I don't know if I will be comfortable coding on the VM with these specs, especially I will be running chrome and PHP Storm at the same time on the VM which can get up to 5gb of ram alone back on ubuntu.So I won't have any left for windows.
Any other solution ? I thought about using Docker, I don't know if it's suitable in this case ? like importing the project into a docker container in ubuntu, then move back to Windows and use that docker container in php storm or another IDE ?
I also tried WSL with no success since my linux partition is not a physical one.
What's the best solution given my specs to keep working on this project without leaving windows and can be set up easily ?

Related

PHP performance OS

I'm not used to ask question on forum but this one is out of my scope.
Here is my discovery :
php performances are way different on depending of OS.
Here is the experiences :
I used a brand new Laravel projet from the official documentation (I guess you can do the same with Symfony or even any PHP projet)
I used a profiler Laravel debugbar (I guess you can use any profiler you want or even browser inspector)
I deployed the projet on Windows, MacOs and Linux virtual machine (linux VM is hosted by the same PC than the one for the test on Windows)
I tried with the same PHP configuration
I disabled windows defender
I tried with PHP NTS and TS on all machines
Here are the results :
The loading basic page of the dashboard takes around
200ms on Windows
20ms on MacOs
20ms on Linux Virtual machine
Basical Windows is 10 times slower than the others OS
This is related to the performance os the CPU since Linux VM is 10X times faster than Windows on the same machine
Here is my guess :
PHP build are different depending of the OS (of course) and the one for Windows is defensively not as performante as the others (sad story)
Windows use something on top of PHP that makes it slower.
Here are my questions :
What is causing that lack of performances on Windows ?
Is it possible to run PHP faster on Windows ?
Please give constructive answer :
Windows is bad is not an answer
Windows use services that slower PHP execution without giving any name of services nor program is not a constructive answer.
Giving more tests to do to get interring result is a constructive answer.
Thank you for your help
Maybe this answer can solve your problem. The different file system on Windows and Unix/Linux.
php window 4~5 times slower in windows than linux

Docker 2.3.0.4 with Devilbox on Windows 10 WSL2 is extremely slow

I have windows 10 2004, 8-core amd cpu, 12gb ram, running an existing wsl2 debian instance just fine. I can run a typical web stack php-fpm nginx mariadb redis-server with existing WSL and the performance is fine. I have been reading that wsl2 and docker is much better now and wanted to try it out.
I installed docker 2.3.0.4 with wsl2 and installed devilbox as the web stack.
I have limited the wls process to 4gb and 4 cpus using the .wslconfig file and that's all cool and works fine.
What doesn't work fine is that a simple php page (e.g. <?php echo time(); ?> can take 15-30 seconds to show up! anything that talks to a database incurs a 90 second load time. running a stock standard empty wordpress site is out of the question. Running the same script / site / database on nginx/debian on WSL2 works perfectly.
I can't run docker desktop application after windows rebooted (it worked before I rebooted). THe icon docker installer placed on my desktop doesn't do anything when I launch it. I don't see a process turning up in task manager. Nothing seems to crash, it just doesn't work. I can right click on the docker icon in the tray and get to the dashboard that way. I generally work at the command line anyway so it's no big deal, thought I'd mention it.
the devilbox installation sets up a local web server and that all works reasonably well. i had to docker-compose up several times to get it to pull the containers properly but then I do have terrible internet. the web interface is pretty snappy, I can launch tools like phpmyadmin and they LOAD fine. If I try to restore a 10mb database with 100 tables, it will time out and crash and burn. Restoring the same database through the shell via mysql works fine, even if my disk load goes to 90% and stays there for 5 minutes.
any virtual host web server I create performs abysmally. php pages take around 90 seconds to show up. a page with phpinfo() might take 45-90 seconds of white screen to show up.
HOW do I figure out why docker is just so bad compared to straight up linux on WSL2 on the same environment? I'm guessing it's something to do with the io bit windows task manager says the disk io is averaging 2% load.
I think simply that your 2004-generation processor does not support any of the virtualization features.
Docker runs a LAMP stack reasonably fast on my mediocre i5 setup.
During the past months I had some performance issues and tried various things like copying source from the regular disk (i.e. C: a.k.a. /mnt/c/) to inside of a WSL directory (i.e. inside of \\WSL$\UBUNTU\home\user\) but git & PHPStorm had various hard to diagnose issues (although there was an improvement in latency - and an additional bouns the file system is actually case sensitive then - so 1:1 with server environment - otherwise it's on NTFS)
However, the biggest boost to performance was to minimize the number of mapped directories - initially I had set up so that the mariadb database would be accessible to the host machine:
mariadb:
image: mariadb:10
volumes:
- ./docker/mariadb:/shared # removed this for huge boost
Removing it made work with docker bearable.
I think it problem of docker volume and windows file sharing. Even though U use WSL2 it not mean U use linux file system. If you use file from windows system, for example: d:/workspace/myproject, it sill windows file and folder, windows will read and scan them before any excute from docker.
I found the solution. It is install your project in WSL distribution. Open your linux distribution, for me it Ubuntu 18.0, you will start at /home/%USER_PATH%, install your project here, for example: /home/mypc/workspace/myproject
You can remote your IDE to WSL, in VSCode, it support by extenstion Remote WSL. That make your project work on linux file system only, not share with windows, and much more faster

Complicated setup with Git, Laravel, PHPStorm and VPS

What I have so far:
Two VirtualBox LAMP machines (separate locations) where I connect my two Windows development machines via SFTP, to write code using PHPStorm.
One VPS machine where I deploy my code written for a project in Laravel.
What I am trying to achieve:
Fast and easy code deployment, as in: write the code in Windows via PHPStorm, test it on the LAMP machine, deploy to VPS if necessary.
The problem is that I need to use some php artisan commands on LAMP machines to get some code generated. This means that I always have to synchronize PHPStorm with LAMP files tree in order to see the changes. Then, I need to also sync the other dev (LAMP) machine and the other PHPStorm running on Windows machine number 2. I know that this can be done via Git.
So everytime I use the command line to generate code, I need to sync 4 machines (excluding the deployment server).
Later, if I add another pair of Windows/LAMP dev machines, the complexity grows.
Back in the days of Dreamweaver, I could write code directly on the deployment server. Not the greatest idea, but it was way much simpler and faster, and that's what I need now.
Any ideas on how can I simplify this?
Switching to WAMP so I can have files in sync with PHPStorm (because all is locally) is not OK because... Windows and PHP libraries issues :)
Also, switching to Dreamweaver is not OK either.
What other options do I have?
Thanks!
LE: on the side, I am also thinking if a NAS can be helpful for this type of problem.
LLE: is Linux Desktop + PHPStorm the only straight solution?
No matter the protocols
You can put your code outside of the guest machine and configure the guest machine to mount the code (mount a folder from the host inside the guest).
Apache will run slower because it will use the mounted remote-folder but PHPStorm will run at its maximum speed.
Taking protocols into consideration
Try using SSHFS on windows.
I use SSHFS for remote development from my Linux host machine to headless vagrant boxes (and/or to remote development servers / staging servers).
It's much faster than SAMBA (the windows SMB protocol) and oddly faster than NFS even though SSH uses encryption.
Coleages using Windows+SMB often leave their computers for 30 min while PHPStorm is indexing and git branch changes on the dev machine go unnoticed for minutes at a time.
Indexing over SSHFS usually takes less than 5 min on a Symfony2 project. Branch changes are detected in less than 15s.
Using Linux (shameless plug)
Linux is nice, and it's free, and it works out of the box (Ubuntu) -- including pesky USB-Modems which would normally require an install on windows.
You already know how to handle a Linux CLI the learning curve is already halfway crossed.
Auto-updates don't rule your life, they're not the king of you!
All the applications you need are part of the software repositories you don't need to look for anything, download 40+ executables and attempt to install them just to be welcomed by an error "invalid architecture", "windows version not supported", ".NET framework version too old", "DirectX version too new (wtf?)", "your cousin is a software pirate".
Dependency management is a concept Linux never fully solved -- but at least the bloody tried and in 90% of consumer use-cases it fits the bill. Windows is still eating glue at the back of the class.
How I solved the problem:
I have an extra Mac, on which I installed everything for my PHP ecosystem, including the IDE, so everything is local. That's the dev machine. Then I manually copy the code to the VPS when needed. Another solution was to install Ubuntu Desktop (or similar) on dual boot with Windows and use it as a local dev environment.
Much faster development / deployment :)

Mac OS X 10.5 Apache and Subversion upgrade alternatives

I've found myself down a rabbit hole and would like advice. It looks like Mac OS X 10.5.8 comes bundled with a pre-configured version of Apache 2.2.11 (located in /usr/sbin), PHP 5.2.10 (located in /usr/bin) and subversion 1.4.4 (located in /usr/bin). I have installed MAMP for MySQL 5.0.41 (located in /Applications/MAMP/...) which comes with Apache 2.0.59 and PHP 5.2.6. The current version of MySQL is 5.1 (mysql.com). I have also installed the latest Subversion binaries 1.6.5 (they get located in /opt/subversion/...). This is becoming a mess. Ideally I would like to have one copy each of Apache, PHP, MySQL, and Subversion and have them all be the latest release and have them work together properly. Are there configuration pitfalls specific to the Mac that I need to watch for if I install the newest binaries of Apache in /usr/sbin, PHP5 in /usr/bin, subversion in /usr/bin, and Mysql in /usr/bin (or /usr/local/bin)? Am I just asking for trouble?
Do not install ANYTHING in /usr/bin or /usr/sbin. Those are managed by Apple and you can get yourself and your system in trouble when you start modifying stuff there. Other than a bit of wasted disk space, there's normally no problem with having more than one copy of things like Apache. Just accept it.
If you need newer or missing versions of open source packages, you might want to look into using MacPorts or Fink to supplement what's provided by Apple.
My personal preference is just not to do this development on my Mac at all, and instead run a Linux Virtual Machine using VMWare Fusion, VirtualBox or similar. One of thes nice things about VMWare Fusion 2 (not 3 though, bizarrely) is that you can run these virtual machines in headless mode, and simply SSH into them via terminal on your Mac.
The benefit to me here is that my VMs are able to very closely mirror the setup of my production machines, I'm able to closely control what software is actually installed on them, and if I need to work on a new machine I can simply copy the VM from one machine to another. I can also easily take snapshots of the VM at any point, and roll back to them if I do manage to muck something up.
Here's a good guide to using VMWare Fusion for doing development on OSX.
I have been developing for the LAMP stack on a Mac for bit over 4 years now. I have tried pretty much every flavor of the stack on the Mac.
Native: Not viable, because it's an old codebase.
MacPorts: I ran into trouble with OS X updates.
Self Compiled: Same as with the MacPorts, I ran into trouble with OS X updates.
MAMPP: I didn't like this package, yet this is a personal dislike. I kind of disliked it's freemium like style. The package is not easily configurable, except using the commercial configuration software.
XAMPP: I ended up sticking with XAMPP.
About XAMPP:
The XAMPP code base is rather up to date. With the Developer Package, you get all the tools necessary to compile additional extensions. Everything is configured in /Applications/XAMPP/etc/.

Which Linux distro is best for running in a virtual machine, for programming research?

I'd like to learn LAMP development for my own personal edification.
I tried setting up Ubuntu 8.10 "Hardy Heron" in Microsoft VPC, but I can't get the video to work above 800x600. Played with xorg.conf a million times but no joy. Can anyone recommend a good distro to work with that plays well with VPC? Any guidance on getting started with Apache and Perl/PHP would also be welcome.
I installed ubuntu 8.10 in a virtual machine on my Vista 64-bit laptop. I attempted the install with Virtual PC, VM Ware and Virtual Box from SUN. Virtual Box was the only vm software that I was successful with from the start. In the setup you choose that you are installing linux as your guest OS and everything works without spending your evening sifting through blogs trying to get install to work.
Firstly, if your goal is to learn LAMP development, I'd start by just downloading the WAMP stack for windows from http://www.wampserver.com/en/ or one of it's competitors. The "Linux" part of LAMP programming isn't likely to be a major part of your learning experience. Avoiding running a VM will be much less resource intense on your development workstation and avoid having issues with suspend/resume and disk IO contention.
Secondly, any linux should work, under virtualbox or msvpc. All the modern desktop virtualization systems emulate a full system, so it's just a matter of configuration and getting the right drivers. Like others said, virtualbox is more open source friendly so give that a shot.
Finally, I don't usually run X on my development VM's, since it just eats unnecessary resources. Just use putty on the host and ssh in to a VM running in console mode.
Not entirely the answer to your question, but I think it attacks your goal more directly.
If you're not wedded to VPC, a quick way to start might be to download the free VMWare Player at
http://vmware.com/products/player/
and then you can try any of many, many distros prepackaged for VMWare here:
http://vmware.com/appliances/directory/cat/508
The appliances at the second link should work out of box, so you don't have to fiddle with X conf files, which is probably not the topic of your research. As a bonus, you may be exposed to distros you normally wouldn't know about.
Edit: Here's an appliance with Ubuntu 8.10:
http://www.vmware.com/appliances/directory/54735
http://www.virtualbox.org/wiki/Guest_OSes
This is largely a matter of preference. As has been mentioned, Ubuntu is a good choice. I tend to prefer debian as it is a bit less cutting edge (and therefor more stable). But it's not as easy a platform to learn as Ubuntu.
As has also been pointed out, I would recommend VirtualBox as Virtual PC doesn't support non-MS operating systems.
I use Ubuntu 8.10 and Mono.
However, to get the graphics to work properly, you need the
noreplace-paravirt
kernel parameter.
I use Scientific Linux 5.2 (which is just a rebranded RedHat Enterprise Linux 5.2) and it works fine. I also have had success with many flavors of Ubuntu. I run all of my machines under VMWare Server and have successfully used them with both the 1.0.x versions and the 2.0.x versions of VMWare server.
Does it have to be Microsoft Virtual PC? Virtual Box is much more open-source friendly and I used it with no problems to display higher resolutions of the guest OS.
Check Bitnami stacks. They are ISO live disks images. You just need to attach the iso to the boot cd of the vistual machine. There is a LAMP stack based on Ubuntu.
If you like how it works, there is an option to install to a virtual disk.
I was able to get VMWare Server (free) to work fine with Ubuntu without much hassle (display, etc works out of the box). Install VMWare tools on the VM (they make it for linux) and you'll get a more seamless experience. My specific configuration:
VMWare Server 2.0
Host OS: Windows XP Pro, SP 3
Guest OS: KUbuntu 0804

Categories