Skip to content

Instantly share code, notes, and snippets.

@dreaddymck
Forked from abobija/wsl2-ubuntu-lamp.md
Created November 14, 2021 13:06
Show Gist options
  • Save dreaddymck/dc6c829bc202b7a0acb76e25dc857ecf to your computer and use it in GitHub Desktop.
Save dreaddymck/dc6c829bc202b7a0acb76e25dc857ecf to your computer and use it in GitHub Desktop.

Revisions

  1. @abobija abobija revised this gist Jun 19, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ sudo apt-get install -y apache2
    ## PHP

    ```sh
    sudo apt-get install -y php libapache2-mod-php sudo apt-get install -y php libapache2-mod-php php-mysql
    sudo apt-get install -y php libapache2-mod-php
    sudo apt-get install -y php-curl php-gd php-json php-mbstring php-xml
    ```

  2. @abobija abobija revised this gist Jun 19, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,8 @@ sudo apt-get install -y apache2
    ## PHP

    ```sh
    sudo apt-get install -y php libapache2-mod-php php-mysql
    sudo apt-get install -y php libapache2-mod-php sudo apt-get install -y php libapache2-mod-php php-mysql
    sudo apt-get install -y php-curl php-gd php-json php-mbstring php-xml
    ```

    ## MySQL
  3. @abobija abobija revised this gist Jun 19, 2021. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,7 @@ sudo apt-get install -y apache2
    ## PHP

    ```sh
    sudo apt-get install -y php libapache2-mod-php
    sudo apt-get install -y php-curl php-gd php-json php-mbstring php-xml
    sudo apt-get install -y php libapache2-mod-php php-mysql
    ```

    ## MySQL
  4. @abobija abobija revised this gist Dec 1, 2020. 1 changed file with 17 additions and 1 deletion.
    18 changes: 17 additions & 1 deletion wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -85,4 +85,20 @@ sudo sed -i "s;/var/www;$HOME/www;g" /etc/apache2/apache2.conf
    sudo sed -i "s;/var/www/html;$HOME/www;g" /etc/apache2/sites-available/000-default.conf
    ```

    Now you can go to `~/www` and create `index.html`
    Now you can go to `~/www` and create `index.html`

    ### Configure Apache2 for Wordpress module rewrite custom permalink structure

    First with `cd` go into your wordpress installation folder and then:

    ```sh
    sudo touch .htaccess
    sudo chown -v :www-data .htaccess
    sudo chmod -v 664 .htaccess
    sudo sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf
    sudo a2enmod rewrite
    sudo service apache2 restart
    ```

    Now go to WpAdmin -> Settings -> Permalinks. Choose permalink structure and hit "Save Changes".
    Now `.htaccess` should be populated with wordpress rewrite rules and conditions.
  5. @abobija abobija revised this gist Dec 1, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -60,7 +60,7 @@ Now you can login into phpmyadmin with username `root` and password `MyPassword`
    ```sh
    sudo mysql -u root -pMyPassword -e "UPDATE mysql.user SET plugin = 'auth_socket' WHERE User = 'root'; FLUSH PRIVILEGES;"
    ```
    _* If remotely login for root is disallowed then you need to create new MySql user._
    _* If remotely login for root is disallowed then you need to create new MySql user, otherwise you will not be able to login into PhpMyAdmin._

    ### LAMP Control Aliases

  6. @abobija abobija revised this gist Dec 1, 2020. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -72,4 +72,17 @@ echo 'alias lampstop="sudo service mysql stop ; sudo service apache2 stop"' >> .
    echo 'alias lamprestart="lampstop ; lampstart"' >> .bash_aliases
    ```

    Now you need to logout/login and then you can use `lampstatus`, `lampstart`, `lampstop` and `lamprestart` for controling LAMP stack.
    Now you need to logout/login and then you can use `lampstatus`, `lampstart`, `lampstop` and `lamprestart` for controling LAMP stack.

    ### Change document root of Apache2

    In this example document root will be changed from `/var/www/html` to `~/www`

    ```sh
    cd ~
    mkdir www
    sudo sed -i "s;/var/www;$HOME/www;g" /etc/apache2/apache2.conf
    sudo sed -i "s;/var/www/html;$HOME/www;g" /etc/apache2/sites-available/000-default.conf
    ```

    Now you can go to `~/www` and create `index.html`
  7. @abobija abobija revised this gist Nov 30, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -56,11 +56,11 @@ Now you can login into phpmyadmin with username `root` and password `MyPassword`
    ## Additional (optionally)

    ### Disallow root login remotely
    _If remotely login for root is disallowed then you need to create new MySql user._

    ```sh
    sudo mysql -u root -pMyPassword -e "UPDATE mysql.user SET plugin = 'auth_socket' WHERE User = 'root'; FLUSH PRIVILEGES;"
    ```
    _* If remotely login for root is disallowed then you need to create new MySql user._

    ### LAMP Control Aliases

  8. @abobija abobija revised this gist Nov 30, 2020. 1 changed file with 15 additions and 2 deletions.
    17 changes: 15 additions & 2 deletions wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -55,8 +55,21 @@ Now you can login into phpmyadmin with username `root` and password `MyPassword`

    ## Additional (optionally)

    Disallow root login remotely (_if remotely login for root is disallowed then you need to create new MySql user_).
    ### Disallow root login remotely
    _If remotely login for root is disallowed then you need to create new MySql user._

    ```sh
    sudo mysql -u root -pMyPassword -e "UPDATE mysql.user SET plugin = 'auth_socket' WHERE User = 'root'; FLUSH PRIVILEGES;"
    ```
    ```

    ### LAMP Control Aliases

    ```sh
    cd ~ && touch .bash_aliases
    echo 'alias lampstatus="sudo service apache2 status ; sudo service mysql status"' >> .bash_aliases
    echo 'alias lampstart="sudo service mysql start ; sudo service apache2 start"' >> .bash_aliases
    echo 'alias lampstop="sudo service mysql stop ; sudo service apache2 stop"' >> .bash_aliases
    echo 'alias lamprestart="lampstop ; lampstart"' >> .bash_aliases
    ```

    Now you need to logout/login and then you can use `lampstatus`, `lampstart`, `lampstop` and `lamprestart` for controling LAMP stack.
  9. @abobija abobija revised this gist Nov 29, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # LAMP stack on WSL2 (Ubuntu 20.04) - Apache, PHP, MySQL, PhpMyAdmin
    # LAMP stack on WSL2 (Ubuntu 20.04) - Apache, MySQL, PHP, PhpMyAdmin

    ## Apache

  10. @abobija abobija created this gist Nov 29, 2020.
    62 changes: 62 additions & 0 deletions wsl2-ubuntu-lamp.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,62 @@
    # LAMP stack on WSL2 (Ubuntu 20.04) - Apache, PHP, MySQL, PhpMyAdmin

    ## Apache

    ```sh
    sudo apt-get update && sudo apt-get upgrade
    sudo apt-get install -y apache2
    ```

    ## PHP

    ```sh
    sudo apt-get install -y php libapache2-mod-php
    sudo apt-get install -y php-curl php-gd php-json php-mbstring php-xml
    ```

    ## MySQL

    ```sh
    sudo apt-get install -y mysql-server php-mysql
    sudo service mysql restart
    sudo mysql_secure_installation
    #> Validate password component: N
    #> New password: MyPassword
    #> Remove anonymous users: Y
    #> Disallow root login remotely: Y
    #> Reload privilege tables now: Y
    sudo service mysql stop
    sudo usermod -d /var/lib/mysql mysql
    sudo service mysql start
    ```

    Allow remote root login

    ```sh
    sudo mysql -u root -pMyPassword -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root'; FLUSH PRIVILEGES;"
    ```

    ## PhpMyAdmin

    ```sh
    sudo apt-get install -y phpmyadmin
    #> Use apache2
    #> Configure db with dbconfig-common: Yes
    #> Random password (leave password blank)
    ```

    ```sh
    sudo service mysql restart && sudo service apache2 restart
    ```

    Now you can login into phpmyadmin with username `root` and password `MyPassword`.

    ---

    ## Additional (optionally)

    Disallow root login remotely (_if remotely login for root is disallowed then you need to create new MySql user_).

    ```sh
    sudo mysql -u root -pMyPassword -e "UPDATE mysql.user SET plugin = 'auth_socket' WHERE User = 'root'; FLUSH PRIVILEGES;"
    ```