Home / SIDU


    How to install databases

    2013-01-01 00:00
    893696   0   2

    Install ubuntu 24.04 LAMP via wsl, PHP 8 MySQL 8 PostgreSQL 13 etc

    A - Install Git Bash for windows

    If you are already on Linux or Mac, this is optional.

    Tool "Git Bash", on "gitforwindows.org", it says "Git for windows", when installed, it is called "MINGW64".

    This tool for windows is similar to linux terminal. Use Shift + Ctrl + C | V for copy and paste.

    B - Make a project

    eg Let's call our new project as "sun", you can make this folder at any place.

    $ mkdir ~/sun

    C - Install WSL

    $ wsl --install

    Check linux version

    $ lsb_release -a

    Check if you need upgrade ubuntu:

    $ sudo apt update
    $ sudo apt upgrade

    D - Install Apache2

    $ sudo apt install apache2

    And check after installed:

    $ apache2 -v

    Also you might need do the following:

    $ sudo a2enmod rewrite
    ## php.net/manual/en/timezones.php
    $ sudo timedatectl set-timezone Australia/Sydney
    $ sudo service apache2 restart

    $ ip addr

    And you might see some IP like 172.23.x.x, and open your browser to check if your localhost working:

    http://172.23.x.x

    or you can make a better name via

    /c/Windows/System32/drivers/etc/hosts

    eg add a line like this:

    172.23.x.x sun.loc

    Then you will be able to visit via: http://sun.loc

    E - install PHP

    $ sudo apt install php libapache2-mod-php php-mysql
    $ sudo apt install sqlite3 php-curl php-xml php-mbstring php-zip
    $ sudo apt-get install php-sqlite3
    $ sudo apt-get install php-gd php-soap php-intl

    Check PHP version

    $ php -v

    F1 - install mariaDB

    $ sudo apt install mariadb-server

    Login into MariaDB

    $ sudo mysql

    Check date

    $ select now();

    Update root password

    $ SELECT * FROM mysql.user WHERE user = 'root';

    $ ALTER USER 'root'@'localhost' IDENTIFIED BY 'new-pass';
    $ FLUSH PRIVILEGES;

    F2 - Install MySQL 8

    # in case need to un-install mysql
    # sudo apt-get remove --purge mysql*

    $ sudo apt install mysql-server
    $ sudo mysql

    # do not install next line -- save time skip next line
    # sudo mysql_secure_installation

    # sudo vim /etc/mysql/my.cnf -- mysql.cnf no need to change
    [mysqld]
    default-time-zone = "+10:00"
    $ sudo service mysql restart
    $ sudo mysql –e "SELECT NOW();"

    $ SELECT host,user,plugin,authentication_string,Grant_priv FROM mysql.user;

    $ CREATE USER 'sun'@'localhost' IDENTIFIED BY 'password';
    $ GRANT ALL ON *.* TO 'sun'@'localhost' WITH GRANT OPTION;

    $ CREATE DATABASE sun;
    $ GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, SHOW VIEW, LOCK TABLES, EVENT, TRIGGER ON sun.* TO 'sun'@'localhost';
    $ FLUSH PRIVILEGES;

    G - install PostgreSQL

    $ sudo apt install postgresql postgresql-contrib
    $ sudo apt install php-pgsql
    $ sudo -i -u postgres psql ## login via cmd
    $ \password postgres ## input new password twice
    $ \q ## quit

    H - Additional info if using WSL

    next time to start wsl:

    $ wsl -d Ubuntu

    /home/sun $ ln -s /c/Users/userName/sun www

    you might able to edit /etc/apache2/sites-enabled/sun.conf as



    And then you will be able to edit www files in windows folder ~/sun
    Back « SIDU Support and Help Desk
    Next » Optional sidu_fk table

    Comments

    Leave a commentEdit comment

    Category