Setting up WordPress on Debian 9.3 x64 on a Virtual Machine on Windows 10

In this article I am documenting the exact steps that one needs to host a wordpress based site on a Debian based virtual machine (VM). I choose debian since that’s one of the preferred distro based on it’s stability and smaller footprint on resources compared to Ubuntu. But you may very well choose Ubuntu, only some steps in below documentation would differ.
This article deals with following technologies:

  1. Windows 10: The host operating system
  2. Oracle VirtualBox: The Virtual Machine software
  3. Debian 9.3 x64: The distro which we will install on the VM
  4. nginx: The web server
  5. mariadb: MySQL database solutions
  6. php: The package which installs on Debian automatically as a dependency
  7. phpMyAdmin: Administration tool for MariaDB


You need to downloaded the latest version of Debian x64 from here:
In my case I happen to download the iso image “debian-9.3.0-amd64-DVD-1.iso” from
Note that I didn’t need the other two ISO image since you can always choose to install additional packages via Internet (if you have good fast broadband).
Then I downloaded and installed the latest version of VirtualBox from here:
Next thing is to install Debian OS on the virtualbox. This was done by creating a new virtual machine. I made sure to give it 2 GB or memory and 20 GB of space and 2 cores of processor and 64 MB of video memory for speedy and responsive virtual machine performance. You can provide resources depending on how much you want to allocate.

The VirtualBox and the virtual machine setting I choose

The settings of virtual hard disk I setup

I also added an additional IDE drive since it makes it easier to have reference to two different ISO images. On one of the IDE I gave it the reference of the Debian ISO image we downloaded earlier since we would need it to install debian on the virtual machine.
The settings page of the storage solution of VM showin debian ISO attached with one of the IDE

Lastly it’s important to set the network adapter as “Bridged Adapter”. It’s required to have the virtual machine access to Internet while also retaining an IP address that we can use to browse the wordpress site that will be hosted on the debian VM.
Bridged Adapter is required for Internet and Intranet to work optimally

Installing Debian 9.3 on VirtualBox:

Now I started the virtual machine and since we had already setup the debian ISO image as primary bootable disk, I was greeted by the installation screen. Here I installed the debian like I would on a normal machine.

The Debian installer menu when VM is started for the first time

During the installation it would ask for a hostname. Enter something sensible. I entered Later we will do something that would let us visit the sites hosted on this VM, using browser from host machine, through this hostname, “”.
You can enter anything here. Whatever you enter needs to be updated in host file as described later

After some time the installation also ask to insert 2nd ISO. If you haven’t downloaded the other two ISO images you may skip this step.
Once the installation reaches a certain step you should also select a desktop environment. I selected GNOME, since that’s the desktop environment I like.
You can also choose multiple desktop environments and toggle between them at the login screen

After debian installation completes, the VM will ask for a reboot. Do it, and you should be greeted with following grub bootloader screen:
The GRUB bootloader menu. Selecting first option boots into Debian homescreen

Debian’s Login Screen. You can toggle desktop environment by clicking the gear icon on left of “Sign In” button

Once the debian desktop is loaded, you might want to add “Terminal” to favorites since we would need to launch it a lot of times.
At this point when you launch Terminal, you will be greeted by a black text on white background terminal window. I like to change it to white on black from preferences. I like it that way.
When you click Activities (top left) and enter term in the search box, you can see the terminal icon, which you can then right click and add to favorites

I like my terminal colour scheme to be jassy!

Now, if you notice even if you notice the resolution of the desktop will be limited to 1024 x 768 and you can’t use copy paste text from machine or to your host OS. We would need to do perform certain steps in order for the VM to function optimally.
So low resolution!

A. Install Sudo: By default sudo is not installed. So it’s important to install sudo before we do anything. To do this run following commands on terminal:

su root
apt-get install sudo -y

If you get the message “please insert the disc labelled, Debian…” make sure you have the debian ISO loaded on IDE (Devices -> Optical drive -> Debian ISO).

Selecting debian ISO image on secondary IDE drive

Installing SUDO!

B. Add yourself in sudoer list: If you don’t do that you will encounter following error message if you try to run a command in sudo mode:
I have SUDO, but no love from SUDO for me! ๐Ÿ™

To add yourself in sudoer list run following command:

su root
sudo adduser username sudo

Added myself to Sudoer list. Still no love. :/ Wait, you machine, lemme reboot!

Now you need to reboot the VM, else the command won’t take into effect. (Sidenote: I don’t know how many times have I missed rebooting at this point, and wondering why sudo isn’t working even after I granted it SUDO rights.)
C. Install build essentials: Now that you have SUDO, just run following commands to install build essentials.

sudo apt-get update
sudo apt-get install build-essential

Above command required 137 MB of space to install and finished in about 15 seconds.
D. Install Linux Kernal headers: Run following commands to install linux kernel headers. I don’t know why it’s requird but just bear with me:

sudo apt-get install linux-headers-$(uname -r)
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install linux-headers-amd64

Above set of commands requires about 100 MB in total of space and finished in a minute.
E. Install Virtual guest add-on: Finally we need to install the VM’s guest addon, which you guessed it right we didn’t need to do if this wasn’t a VM. But since it is, just run following command after clicking Devices -> ‘Install Guest Additions CD image’ option.

sudo sh /media/cdrom/

Installing Guest additions. It’s a VM requirement. You don’t need to do that if you are setting up wordpress on actual Debian.

If you are using two IDE drives, then you may need to change cdrom to cdrom1, since if debian’s ISO is attached with first IDE, then the guest additions image would be mounted on second IDE.
Once Guest additions are installed, reboot the VM. Once you do that you will notice that more solutions are supported. In fact the resolution will change (resize) depending on how large of the VM window you open.
Now just select Devices -> Shared clipboard -> Bidirectional, so that you can easily copy paste commands from clipboard.
Doing this will let you copy pasta!

At this point, the VM is ready for us to install next step of LAMP setup, which is installing applications on the debian OS to enable us to host a wordpress website.
Run the following commands on the console to install nginx, mariadb and phpmyadmin etc:

sudo apt-get install nginx
sudo apt-get install mariadb-server
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install phpmyadmin

If you get error finding the phpmyadmin package, make sure to choose “Main” under software sources and again trying both commands:

Installing phpMyAdmin

Select Main, if you get errors.

Press escape when it asks for configure at below screen:

On below screen, press Yes, and it’s when it will ask for a password to be setup. Enter the password which you want to keep for SQL:
Press Yes. If not you won’t be able to set root password. Not that you need it anyway later.

Now we are done installing nginx, mariadb and phpmyadmin. To confirm if nginx server is running, use following command:

sudo service nginx status

Oh my.. look nginx running smoothly!

To know the IP address of your VM, enter following command:

hostname -I

You know, there’s an easier way to find IP address. Just mouse over the network icon in bottom right of VM. I couldn’t take a screenshot of it, so I choose to find a terminal way for the same.

On my VM, it’s IP address was:
On your host windows machine, open the file “C:\Windows\System32\drivers\etc\hosts”:
Add following lines in the end and save it. It will resolve the address to the IP address of your VM:

Yea, you need to run Notepad++ in administrative mode to save changes to this host file. But Notepad++ can also start in admin mode if it requires to. Pretty neat!

Now flush DNS by running following command on windows command prompt:

ipconfig /flushdns

You need to flush every time, when your job is done. Learning life lessons, from this article.

Now open a browser and enter following address to open it:

Why this comes is a mystery to me! :/

For some reason we need to purge Apache before we see nginx page. So to purge apache run following command in debian’s terminal:

 sudo apt-get purge *apache*

Once the above command finishes purging apache, now refresh on browser. You should see following screen:

Much better. If you get this, give yourself a pat in the back.

Now we will setup a URL to access the phpmyadmin page. To do this, run following commands to create a symlink to /usr/share/phpmyadmin to a file in /srv/web/public_html:

cd /srv
sudo mkdir web
cd web
sudo mkdir public_html
cd public_html/
sudo ln -s /usr/share/phpmyadmin phpmyadmin

sudo !! repeat the previous command which you entered. Pretty good for forcing linux it to work for you. I only wish I can do that for some *non PC related tasks*.

Now we will create an nginx configuration such that points to phpmyadmin page (but only on port 2626. You may change this port for security measure):

cd /etc/nginx/sites-available/
sudo nano

Paste following lines in the text editor which opens on terminal:

server {
        listen 2626 ;
        root /srv/web/public_html ;
        # Add index.php to the list if you are using PHP
        index index.php index.html ;
        server_name ;
        location / {
                try_files $uri $uri/ =404;
                autoindex on;
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

Once the file is sucessfully saved, create a symlink with below command:

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Lastly, reload nginx:

sudo service nginx reload

Now try to open the URL, “” from the browser. If you have followed every step correctly, you should be greeted with this beautiful screen of phpmyadmin console:

Aren’t you feeling accomplished?

You may be tempted to login to this admin using the root password we entered while installing phpmyadmin, but hold your horses, cause due to some security measure, it won’t allow you to do that. So now we need to create a new mySQL user and use it to access the phpmyadmin.

sudo mysql -u root
CREATE USER 'vyom'@'localhost' IDENTIFIED BY 'MySQLPass';
GRANT ALL PRIVILEGES ON `vyom\_%`.* TO 'vyom'@'localhost';

So easy to work on SQL from terminal, innit?

Now on this phpMyAdmin console you can create a database for wordpress, and proceed to install wordpress.
phpMyAdmin console. Power of SQL in your hands. Use it responsibly!

Installing WordPress:

To install wordpress, you just need to follow the guide I wrote earlier, and access it via browser like you would normally do. For completion sake, I would document rest of the steps too:
Run following command on terminal to download wordpress and install it in respective directory:

cd /home/vyom
mkdir www
cd www
tar -xzvf latest.tar.gz
mv wordpress/ public_html/

Don’t forget to chown the www directory so that all the fils are owned by www-data. This step is important so that wordpress don’t face permission issue later:

sudo chown -R www-data /home/vyom/www

Now create an nginx config so that points to this wordpress installation:

cd /etc/nginx/sites-available/
sudo nano

Enter following configuration into the text editor which opens in terminal:

server {
	listen 80;
	root /home/vyom/www/;
	index index.php index.html index.htm;
	location / {
		try_files $uri $uri/ /index.html /index.php;
	# enforce NO www
	if ($host ~* ^www\.(.*)) {
		set $host_without_www $1;
		rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
	# unless the request is for a valid file, send to bootstrap
	if (!-e $request_filename) {
		rewrite ^(.+)$ /index.php?q=$1 last;
	error_page 404 /404.html;
	# redirect server error pages to the static page /50x.html
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root /usr/share/nginx/html;
	# pass the PHP scripts to FastCGI server listening on
	location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		#fastcgi_split_path_info ^(.+\.php)(/.+)$;
		# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
		# With php5-cgi alone: fastcgi_pass; With php5-fpm:
		fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
		#fastcgi_index index.php; include fastcgi_params;
	# deny access to .htaccess files, if Apache's document root concurs with nginx's one
	location ~ /\.ht {
		deny all;
	location = /favicon.ico {
	log_not_found off;
	access_log off;
	location = /robots.txt {
		allow all;
		log_not_found off;
		access_log off;
	# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). Keep
	# logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
	location ~ /\. {
		deny all;
	# Deny access to any files with a .php extension in the uploads directory Works in sub-directory
	# installs and also in multisite network Keep logging the requests to parse later (or to pass to
	# firewall utilities such as fail2ban)
	location ~* /(?:uploads|files)/.*\.php$ {
		deny all;

Run following command to symlink the nginx config:

sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Reload nginx:

sudo service nginx reload

Now open on the browser, and if everything is ok, you will be greeted with wordpress setup screen:

1st ever wordpress setting page

2nd every wordpress settings page. Enter it carefully.

Enter database name which you created earlier and credential of the sql user which you created, and hit, “Submit”. If you have done everything alright, you will be greeted with this welcome screen:
Final wordpress setup page.

Enter details, and hit “Install WordPress” and viola, you have now configured wordpress on your virual debian machine, and can access it from your host machine!
If you are able to follow this article successfully till the end, do yourself a favour. Do a Rick and Morty dance! ๐Ÿ˜€

One thought on “Setting up WordPress on Debian 9.3 x64 on a Virtual Machine on Windows 10

Leave a Reply

Your email address will not be published. Required fields are marked *