quinta-feira, 7 de março de 2019

Using PHP 5.6 and PHP 7.0 on the same machine

Firstly, I'm using Linux Mint Debian Edition 3 (LMDE 3).

I installed this version of LMDE and the default PHP version is the 7.0, however I have legacy systems developed in PHP 5. So, I had to install the oldest version and I did this without uninstall the version 7.

See the steps!

I only managed to take these first steps as root, be careful!

root@lucio:~# apt install ca-certificates apt-transport-https
root@lucio:~# wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
root@lucio:~# echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

Now, you can use your login. 

root@lucio:~# exit


Install the PHP 5.6

lucio@lucio:~$ sudo apt update
lucio@lucio:~$ sudo apt install php5.6

Make sure that all necessary packages are installed.

lucio@lucio:~$ sudo apt install php5.6-cli php5.6-common php5.6-curl php5.6-mbstring php5.6-mysql php5.6-xml


You can see the versions like that:

lucio@lucio:~$ sudo update-alternatives --config php
There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php7.0   70        auto mode
  1            /usr/bin/php5.6   56        manual mode
  2            /usr/bin/php7.0   70        manual mode

Press <enter> to keep the current choice[*], or type selection number: 

But if you change the version by this method, this will not affect apache, it will only affect the PHP client.

Switching between the versions

Now, I'm going to show how to switch between the versions.


First make sure that all PHP versions will be disable.

lucio@lucio:~$ sudo a2dismod php5.6 php7.0

Activate the desired version. 

lucio@lucio:~$ sudo a2enmod php5.6

And finally restart the apache service.

lucio@lucio:~$ sudo systemctl restart apache2





quarta-feira, 20 de fevereiro de 2019

Debian 9 and MongoDB

Debian 9 and MongoDB


This week I upgraded my Mint running under Debian 9.3 (LMDE 3).  

See:

lucio@lucio:~$ cat /etc/debian_version 
9.3


So, I installed Mongo using the default repository. My current version of python 3 is 3.5.3, and I do not want to update python because I'm afraid to break my project - maybe I have to upgrade the pip packages if I did.


Ok... I tried updating python and using it with Mongo 4.0, but the numpy didn't work...and maybe many others too. So, I gave up.


Installing Mongo

lucio@lucio:~$ sudo apt install mongodb



So, this are the versions of my installations.

lucio@lucio:~/desenv/project$ python3 -V
Python 3.5.3

lucio@lucio:~$ mongod --version
db version v3.2.11
git version: 009580ad490190ba33d1c6253ebd8d91808923e4
OpenSSL version: OpenSSL 1.0.2q  20 Nov 2018
allocator: tcmalloc
modules: none
build environment:
    distarch: x86_64
    target_arch: x86_64


It worked fine!

Restoring backups

It's easy restoring backups in Mongo, just use mongorestore - mongorestore <backup path>.

lucio@lucio:~$ mongorestore desenv/project/dump/20190207/



--- 

Installing Mongo 4.0


I will record here the step by step to install Mongo 4.0 in Debian 9.

Make sure you have the curl installed. If not, install it.

lucio@lucio:~$ sudo apt install curl

Install the key of mongodb repository.

lucio@lucio:~$ curl https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -

Create the file mongodb-org-4.0.list:

lucio@lucio:~$ sudo vim /etc/apt/sources.list.d/mongodb-org-4.0.list

This will open a new blank file. Paste in the following:

deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main

Save and close the file, then update your package cache:

lucio@lucio:~$ sudo apt update

Install the mongodb-org package to install the server and some supporting tools:

lucio@lucio:~$ sudo apt install mongodb-org

Finally, enable and start the mongod service to get your MongoDB database running:

lucio@lucio:~$ sudo systemctl enable mongod
lucio@lucio:~$ sudo systemctl start mongod

Check if Mongo is running:

lucio@lucio:~$ sudo systemctl status mongod

That's all!!!



segunda-feira, 18 de fevereiro de 2019

Creating and updating root password in Mysql


# Creating the first root password

If you have just installed mysql-server and have not set the root password, you will create the password like this:

$ sudo mysqladmin -uroot password 'password' 


# Updating the root password

For updating the root password, you can do like this:

$ sudo mysqladmin -u root -p'oldpassword' password 'newpassword'