Install WordPress from command-line

I never tried it before but today I needed to install WordPress… From command line only. And there is a way to do this with wp-cli.

WP-CLI installation

First some requirements (as root):

apt-get install php5-cli php5-mysql mysql-client curl

And now installation of wp-cli (as root too):

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp

Check if it’s working:

$ wp --version
WP-CLI 0.22.0

WordPress installation

Now you should switch to user of your web application, ex. like this:

su - www-data -s /bin/bash

And install WP:

wp core download --path=/var/www/wordpress

wp core config --path=/var/www/wordpress \
  --dbname=wordpress \
  --dbuser=wordpress \
  --dbpass=wordpresspass \
  --dbhost=localhost \
  --locale=pl_PL

wp core install --path=/var/www/wordpress \
  --url="http://example.com" \
  --title="Example blog" \
  --admin_user=never_use_admin_here \
  --admin_password=admin_pass \
  --admin_email=admin@example.com \
  --skip-email

Here you may find more about wp-cli configuration and commands.

Install Docker Compose

When I started playing with Docker I was running a lot of commands to build image, delete containers running on old image, run containers based on new image, etc… A lot of log commands with links, volumes, etc…
Then I started searching for something to automate this task and here I get to docker-compse command, this is how you may install it:

pip install docker-compose

And install additional bash completions (run as root):

curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose

Then you may prepare docker-compose.yml file like:

web:
  build: .
  command: php -S 0.0.0.0:8000 -t /code
  ports:
    - "8000:8000"
  links:
    - db
  volumes:
    - .:/code
db:
  image: orchardup/mysql
  environment:
    MYSQL_DATABASE: wordpress

More informations about syntax may be found here: https://docs.docker.com/compose/compose-file/

And run such environment with:

docker-compose up

Or to run this in background:

docker-compose up -d

To stop and cleanup it use:

docker-compose stop && docker-compose rm -f -v

Other usable commands are:

docker-compose build --force-rm # to rebuild images and clean after
docker-compose ps               # to list containers

I’m still playing with volumes in this but don’t have anything interesting enough to paste here – maybe later.

Source:
https://docs.docker.com/compose/install/
https://docs.docker.com/compose/completion/

Some usefull commands in Docker

I started playing with Docker and here I will write some commands that where not so obvious at beginning 🙂

List running containers:

docker ps

List also not running containers:

docker ps -a

Remove all containers (be careful with that):

docker rm $(docker ps -a -q)

Remove all images:

docker rmi $(docker images -q)

Docker won’t remove any old volumes used by containers, so after some time you may be interested in deleting them all:

docker volume rm $(docker volume ls -q)

Run container and enter bash:

docker run --name deb -t -i debian:jessie /bin/bash

Run containter and remove it after exit:

docker run --name deb -t -i --rm debian:jessie /bin/bash

Show build logs from container:

docker logs deb

Enter bash into running container:

docker exec -it deb /bin/bash

Build image from Dockerfile in current directory:

docker build -t my_web .

After playing a little with this command I started searching for something to automate my tasks a little, and found docker-compose – you may be interested in it too.

Source:
https://techoverflow.net/blog/2013/10/22/docker-remove-all-images-and-containers/

Manual installation of Docker on Debian/Ubuntu

I've played with Docker a little in it early days but didn't stick for longer with it. It's stable now so I wanted to check how it's running now.

I really can't accept this method of installation:

$ curl -fsSL https://get.docker.com/ | sh

I think that world is going to it's end when I see such scritps… I prefer to do this manually, knowing exactly what I have to do.

Install prerequisites:

apt-get update
apt-get install -y apt-transport-https ca-certificates

Purge old packages if you used them:

apt-get purge lxc-docker*
apt-get purge docker.io*

Add GPG key:

apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Add repo – use ONLY ONE repo appropriate for your system (lsb_release -a to check):

echo "deb https://apt.dockerproject.org/repo debian-wheezy main" > /etc/apt/sources.list.d/docker.list
echo "deb https://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list
echo "deb https://apt.dockerproject.org/repo debian-stretch main" > /etc/apt/sources.list.d/docker.list
echo "deb https://apt.dockerproject.org/repo ubuntu-precise main" > /etc/apt/sources.list.d/docker.list
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list

Refresh repos and install Docker:

apt-get update
apt-get install -y docker-engine

Start service if it's not running:

service docker start

Grant access to docker service for non-root user

I don't like to use apps that require me to use root account. Docker even advice not to do so – service is running as root and you should add docker group and user to it to grant access to service socket:

groupadd docker
gpasswd -a ${USER} docker
service docker restart

Now logout, login again and and you should be able to use docker command:

docker version
docker info
docker run hello-world

Have fun 🙂

Source:
https://docs.docker.com/linux/
https://docs.docker.com/engine/installation/

Use www.horizon.tv with Pipelight/Silverlight on Linux/Ubuntu

From few days I have access to UPC’s www.horizon.tv platform – until now it was useless on Linux. But there is Pipelight that will use Wine to emulate Silverlight on Linux and it’s working pretty well – you’re just few commands away from achieving that:

# stop browser
killall firefox
# remove old version if you have it
sudo apt-get remove pipelight

Now configure repos and install packages:

sudo apt-add-repository ppa:pipelight/stable
sudo apt-get update
sudo apt-get install --install-recommends pipelight-multi
sudo pipelight-plugin --update

Enable plugin (run it with sudo for system wide installation):

pipelight-plugin --enable silverlight

Start Firefox and test if plugin is working here: http://bubblemark.com/silverlight2.html

Now enter www.horizon.tv and try it yourself.

P.S.
It works only on Firefox because Chrome do not support NPAPI plugins anymore 🙁

Source:
http://www.webupd8.org/2013/08/pipelight-use-silverlight-in-your-linux.html