Setup Apache 2 & PHP 5.6 environment on Ubuntu 16.04

Install Apache

https://help.ubuntu.com/lts/serverguide/httpd.html

sudo apt install apache2

Check computer name

hostname

Returned ‘userver’. I’ll use it in apache configuration for setting sub-domains.

Setup enabled sites. I.e directories and its host names. I’ll setup localhost, local ip address and subdomain main.userver to point to same directory of my main project. I’ll keep the apache default page for reference on address apache.userver

Continue reading “Setup Apache 2 & PHP 5.6 environment on Ubuntu 16.04”

Ubuntu development environment setup

Here I’d like to have a list of programs setups  that I use after clean Ubuntu installation.

Chrome

Download latest official version. Then:

sudo dpkg -i ~/Downloads/google-chrome-stable_current_amd64.deb
sudo apt install -f

Install basic tools from apt

sudo apt install chromium-browser guake byobu git openssh-server openssh-client unrar

  • Chromium – The open source chrome
  • Guake – A nice terminal. Always in the background, just press F12. Type byobu to enter it
  • Byobu – Terminal multiplexer, allows tabs and other tricks. F2 – for new tab F3 switching between tabs
  • Git – The source control tool
  • Openssh – SSH server
  • Unrar – fixes built in rar extractor

Continue reading “Ubuntu development environment setup”

Docker MySQL 5.7 example

Example running MySql 5.7 inside docker container with data stored outside and access from remote computers.

Init container for the first time

docker run --name mysql-container -e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_ROOT_HOST=172.17.0.1 -p 3306:3306 -v /home/user/mysql:/var/lib/mysql -d mysql/mysql-server:5.7 --character-set-server=utf8 --collation-server=utf8_general_ci

  • --name mysql-container – Container name
  • -e MYSQL_ROOT_PASSWORD=123456 – Password for root
  • -e MYSQL_ROOT_HOST=172.17.0.1 – Virtual host
  • -p 3306:3306 – Port forwarding. Real:Virtual
  • -v /home/user/mysql:/var/lib/mysql – Data directory assignment
  • -d mysql/mysql-server:5.7 – MySQL 5.7 image
  • --character-set-server=utf8 --collation-server=utf8_general_ci – Settings

Run mysql command line client

docker exec -it mysql-container mysql -uroot -p

Enter command line inside the docker & view mysql log

docker exec -it mysql-container bash
cat /var/log/mysqld.log

Connect on hosting machine or remotely

mysql -u root -p -h 172.17.0.1

Move config outside from docker

  1. Copy config from docker to outside
    docker exec -it mysql-container cat /etc/my.cnf > /home/user/mysql/my.cnf
  2. Delete container
    docker rm mysql-container
  3. Init container and reassign config file path
    docker run --name mysql-container -v /home/user/mysql/my.cnf:/etc/my.cnf -e MYSQL_ROOT_PASSWORD=123456 -e MYSQL_ROOT_HOST=172.17.0.1 -p 3306:3306 -v /home/user/mysql:/var/lib/mysql -d mysql/mysql-server:5.7 --character-set-server=utf8 --collation-server=utf8_general_ci

Enable remote connection

docker exec -it mysql-container mysql -uroot -p

  • Enable remote connection from any host
    grant all privileges on *.* to root@'%' identified by '123456';
  • Or enable remote connection from specific host to specific databese
    grant all privileges on mydb.* to root@'10.0.0.100' identified by '123456';

Full tutorial: https://hub.docker.com/r/mysql/mysql-server/

Turn on computer remotely

Did you know that you can turn on a computer over LAN or Internet? Yes you can! Why will you need it? For example you have a computer that you need to connect to remotely. So instead of keeping it always on, you can turn it on remotely and then just turn it of when you done.

I need it for my file server that I’ve made. I’ve installed Ubuntu a cheap PC and configured it as network file server. I want to hide it somewhere far at home and it will be connected only with power and LAN cable. I don’t need it always on so here how you set the “Wake on LAN”.

Continue reading “Turn on computer remotely”