itanzopen.com

18.3 °C
Air Quality: 2 (Fair)Frankfurt am Main

Mjesec: travanj 2019.

  • How to set up a LAMP development environment on Windows Subsystem for Linux (WSL)


    The Windows Subsystem for Linux lets developers run GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a virtual machine.


    Install the Windows Subsystem for Linux

    Before installing any Linux distros for WSL, you must ensure that the “Windows Subsystem for Linux” optional feature is enabled.
    Open PowerShell as Administrator and run:

    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

    Restart your computer when prompted.

    Install your Linux Distribution of Choice

    Open the Microsoft Store and choose your favorite Linux distribution.
    Once your distro has been downloaded and installed, you’ll need to complete initialization of the new distro.

    Launch a new instance , wait a few minutes until instalation is finished and then you will be prompted to create a new user account (and its password).

    Installing an Apache HTTP server

    First update your package catalog and upgrade your installed packages:

    sudo apt update && sudo apt upgrade

    Install Apache2

    sudo apt install apache2

    Create a project folder for your web applications. This folder should be outside of the WSL filesystem. Please replace WINUSER with your Windows username.

    sudo mkdir /mnt/c/Users/WINUSER/Workspace

    Create a symbolic link to the selected folder:

    sudo ln -s /mnt/c/Users/WINUSER/Workspace /var/www/html/

    Open the Apache default virtual host configuration file:

    sudo nano /etc/apache2/sites-enabled/000-default.conf

    Modify file with following:

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html/Workspace
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
            <Directory /var/www/html>
             Options Indexes FollowSymLinks
             AllowOverride All
             Require all granted
            </Directory>
    </VirtualHost>

    Enable mod rewrite and restart apache2 server

    sudo a2enmod rewrite
    sudo service apache2 restart

    Installing the MariaDB server

    Install MariaDB server:

    sudo apt-get install mariadb-server

    You wont be asked for password, default root user doesn’t have password in MariaDB. Start server and run a simple security script. During execution you can choose root password.

    sudo service mysql start
    sudo mysql_secure_installation

    Installing PHP

    Install PHP and helper packages and restart apache2 after installation is finished:

    sudo apt install php libapache2-mod-php php-mysql php-mbstring php-gettext php-xml php-json php-curl php-zip php-soap

    Installing PHPMyAdmin

    Install PHPMyAdmin and after installation ends enable mbstring mod and restart apache2 server

    sudo apt-get install phpmyadmin
    sudo phpenmod mbstring
    sudo service apache2 restart