How you can Set Up a LAMP Check Atmosphere on WSL

The Windows subsystem for Linux was supposed to reintroduce Windows as a development platform. With so much development for the web, WSL is ideal for quickly setting up a web development environment by putting together a LAMP (Linux / Apache / MySQL / PHP) environment.

So let's get started.

Install and start Apache

The Apache HTTP server may have more competition from upstart like NGINX, but it is still a reliable web server. Also, it's very easy to install WSL in Ubuntu:

sudo apt install apache2

You may come across other tutorials that explain how to use systemctl in Ubuntu to get systemd to start the server. WSL does not use systemd to manage services. Instead, you use the service Command to start and stop services.

To start the Apache server, enter:

sudo service apache2 start

To make sure it works, navigate to http: // localhost and you should see the standard Ubuntu test page. WSL will automatically map port numbers of the Ubuntu system to those that correspond to your host system.

By default, Apache uses the DocumentRoot of / var / www / html, so you should save your HTML files there.

Install and configure PHP

If you want to add more complex interactivity to your web pages, PHP is a widely used server-side scripting language. It's also pretty easy to install and configure to use with Apache.

To install PHP and its associated Apache module, use this command:

sudo apt install php libapache2-mod-php

To test your PHP installation, write the following short script and save it in the / var / www / html Directory. Let's call it phpinfo.php. You need root rights to save the file in this directory.

<? php
phpinfo ();

Then navigate to http: //localhost/phpinfo.php, and you should see the PHP info page. Now you can embed PHP code in your web applications.

Setting up MariaDB for the database

If you want to store data like usernames and passwords in your web app, you need a database server. For many years, MySQL was an open source relational database management system (RDBMS), but after Oracle took over the project, some of the original developers dropped the project in MariaDB.

MariaDB is a drop-in replacement for MySQL that allows users to use the same commands and all of the other plug-ins without spending too much time learning a new system.

To install MariaDB use the following command:

sudo apt install mariadb

To start the server, use the service the already mentioned command:

sudo service mysql start

Yes, this is "mysql", not "mariadb". Many of the commands are related to MySQL, but you will really be talking to MariaDB. That's what developers mean when they say MariaDB is a "drop-in replacement" for MySQL.

The default installation of MariaDB is pretty insecure as the root password for the MariaDB server is blank. If you're just developing a web app yourself, the security of your development system might not be an issue. Even so, it is a good habit to harden all of the servers that you are running on your system, even if you are the only one using them.

Fortunately, MariaDB includes a script that you can run to make the server more secure:

sudo mysql_secure_installation

This will walk you through several steps like changing the database's root password, prohibiting remote root logins, and removing the default test database.

Related: Database Engines To Consider For Your Next Project

You can use MariaDB's command line to set up and manage any database, but most people prefer a graphical front end. PhpMyAdmin is a very popular option. Installation on WSL is also easy:

sudo apt install phpmyadmin

Ubuntu also walks you through the initial setup of phpMyAdmin, including setting up a username and password. To use it, make sure Apache is up and then navigate to http: // localhost / phpmyadmin.

Enter the username and password you chose during the installation process and you can now manage your database server through your browser.

You are now ready to start developing web apps

Now that you've seen how easy it is to develop web apps with WSL, it's time to start building the next Google or Amazon. Are you looking to expand your web development skills? You can take a few courses to learn even more.

These courses will help you understand web development and design

Would you like to become a web designer, but you have no knowledge? Buy this bundle and become a pro in no time.

Continue reading

About the author

David Delony
(33 published articles)

David is a freelance writer living in the Pacific Northwest but originally from the Bay Area. He has been passionate about technology since childhood. David's interests include reading, watching quality TV shows and movies, retro games, and collecting records.

By David Delony

Subscribe to our newsletter

Subscribe to our newsletter for tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Leave a Reply

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