viernes, 3 de junio de 2016

Switching bettween PHP7.0 and PHP5.6 Ubuntu 14.04.4

Installing php5 and apache2 support:

root@dv1:#apt-get install apache2 apache2-mpm-prefork apache2-utils apache2.2-bin libapache2-mod-php5 php-pear php5-cgi php5-cli php5-common php5-curl php5-dev php5-gd php5-imagick php5-interbase php5-mcrypt php5-memcache php5-memcached php5-mysql php5-odbc php5-pgsql php5-sqlite php5-sybase php5-xcache php5-json -y


Restarting apache2:

root@dv1:#service apache2 stop
root@dv1:#service apache2 start


Checking apache2 and php5 support:

root@dv1:#vi /var/www/html/info.php

add follow lines:

<?php
phpinfo()
?>

Save file  (ESC + : + wq)



Testing apache2 service and php5 support:

 Open a browser and ... ...

http://localhost/info.php







Installing php7 and apache2 support:


root@dv1:#apt-get install python-software-properties
root@dv1:#add-apt-repository ppa:ondrej/php
root@dv1:#apt-get update


root@dv1:#apt-get install php7.0-common libapache2-mod-php7.0 php7.0-cgi php7.0-cli php7.0-dev php7.0-curl php7.0-gd php7.0-interbase php7.0-mcrypt php7.0-readline php7.0-odbc php7.0-xmlrpc php7.0-xsl php7.0 php7.0-json php-all-dev php7.0-sybase php7.0-sqlite3 php7.0-mysql php7.0-opcache php7.0-bz2 php7.0-bcmath php7.0-mbstring php7.0-soap php7.0-xml php7.0-zip



Restarting apache2:

root@dv1:#service apache2 stop
root@dv1:#service apache2 start


Testing apache2 service and php7 support:

 Open a browser and ... ...

http://localhost/info.php







Now ......

Switching bettween PHP7 and PHP5:



From php5.6 to php7.0:

# For php in web apps
root@dv1:#a2dismod php5
root@dv1:#a2enmod php7.0
root@dv1:#service apache2 restart

# For php-cli in the command line

root@dv1:#ln -sfn /usr/bin/php7.0 /etc/alternatives/php

Or from php7.0 to php5.6:

# For php in web apps
root@dv1:#a2dismod php7.0
root@dv1:#a2enmod php5.6
root@dv1:#service apache2 restart

# For php-cli in the command line
root@dv1:#ln -sfn /usr/bin/php5.6 /etc/alternatives/php



Done !!! enjoy !!

jueves, 2 de junio de 2016

How to enable bind mount inside lxc container



Replay the error:

root@lxc1:# mount -t cifs //1.1.1.1/test  /mnt/test  -o username=user,password=pass


mount error 13 = Permission denied 


root@lxc1:# dmesg

[2911493.990084] type=1400 audit(1464884158.208:53): apparmor="DENIED" operation="mount" info="failed type match" error=-13 profile="lxc-container-default" name="/mnt/test" pid=7891 comm="mount.cifs" fstype="cifs" srcname="//1.1.1.1/test" flags="rw"


Solution:


root@lxc1:# vi /etc/apparmor.d/lxc/lxc-default

and add:

mount options=(rw, bind),
 
 
 
Save and restart apparmor:

root@lxc1:# /etc/init.d/apparmor restart