Upgrade Php Centos 7

This is solution for CentOS 6.x and 7.x:

yum install epel-release

then install Remi repo, for Centos 6.x:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-6.rpm

and for Centos 7.x:

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
or for webstatic
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

check which PHP packages installed:

yum list installed php*

remove current PHP:

yum remove php*

install same packages as were installed for 7.0 using PHP 7.2, for example:

yum install --enablerepo=remi-php72 php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
or for webstatic
yum install php72w php72w-cli php72w-common php72w-gd php72w-intl php72w-mbstring php72w-mcrypt php72w-mysql php72w-pdo php72w-pear php72w-process php72w-xml

check version of PHP installed:

php -v

You don’t need to PHP 7.0 and 7.2 coexist on Your server. If You got a problem using PHP 7.2 You can always reinstall older PHP 7.0. If not sure it will work for You on production server, try it on virtual machine first. But it worked for me on many production servers. PHP is not critical OS component, so server will never fail if PHP changed. It’s just Your web app which may fail when change to 7.2, but as I wrote it’s unlikely and You may reinstall older version if it happens.

I forgot about php.ini. If You want to keep Your php.ini customizations in another PHP version, make a copy of php.ini before running yum remove php*. After PHP reinstall diff saved_php.ini php.ini and look what is need to be merged.

Useful Linux commands

from here

# 1. redo last command but as root
sudo !!

# 2. open an editor to run a command
ctrl+x+e

# 3. create a super fast ram disk
mkdir -p /mnt/ram
mount -t tmpfs tmpfs /mnt/ram -o size=8192M

# 4. don't add command to history (note the leading space)
 ls -l

# 5. fix a really long command that you messed up
fc

# 6. tunnel with ssh (local port 3337 -> remote host's 127.0.0.1 on port 6379)
ssh -L 3337:127.0.0.1:6379 root@emkc.org -N

# 7. quickly create folders
mkdir -p folder/{sub1,sub2}/{sub1,sub2,sub3}

# 8. intercept stdout and log to file
cat file | tee -a log | cat > /dev/null

# bonus: exit terminal but leave all processes running
disown -a && exit

# A. Delete all emails from bash
cat /dev/null > /var/spool/mail/root

# 11. Show PID program over port 5432
netstat -vanp tcp | grep 5432

# 12. Show PID program over port 5432
lsof -i tcp:5432

# 13. Stop postgres database on mac.sarch data folder
su postgres
/Library/PostgreSQL/9.5/bin/pg_ctl -D  /Library/PostgreSQL/9.5/data stop

How To Install pgAdmin 4 on CentOS 7 / RHEL 7 & Fedora 29 / Fedora 28

Install pgAdmin 4

Once you have PostgreSQL repository configured on your system, run the following command to install pgAdmin 4.

### RHEL / CentOS ###

yum -y install pgadmin4

### Fedora ###

dnf -y install pgadmin4

Configure pgAdmin 4

We would need to do a few configuration changes prior to accessing the pgAdmin 4.

Copy the pgAdmin 4 sample configuration.

cp /etc/httpd/conf.d/pgadmin4.conf.sample /etc/httpd/conf.d/pgadmin4.conf

Create a pgAdmin log and data directories.

mkdir /var/log/pgadmin4/
mkdir /var/lib/pgadmin4/

Create/Edit config_local.py file.

vim /usr/lib/python2.7/site-packages/pgadmin4-web/config_local.py

Add the following settings. A

LOG_FILE = '/var/log/pgadmin4/pgadmin4.log'
SQLITE_PATH = '/var/lib/pgadmin4/pgadmin4.db'
SESSION_DB_PATH = '/var/lib/pgadmin4/sessions'
STORAGE_DIR = '/var/lib/pgadmin4/storage'

after the existing one:

import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))

Change permissions of directories so that Apache can write data into it. B

chown -R apache:apache /var/lib/pgadmin4/*
chown -R apache:apache /var/log/pgadmin4/*

Run the following command to create a user account for the pgAdmin 4 web interface. C

python /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py

Output:

NOTE: Configuring authentication for SERVER mode.

Enter the email address and password to use for the initial pgAdmin user account:

Email address: admin@itzgeek.local
Password: xxxxxxxxx
Retype password: xxxxxxxxx
pgAdmin 4 - Application Initialisation
======================================

Restart the Apache web service.

systemctl restart httpd

My https configuration file for Apache

For CentOS 7:

<VirtualHost *:80>
        ServerName pg.saic.it
        Redirect permanent / https://pg.saic.it/pgadmin4/
</VirtualHost>
<VirtualHost *:443>
        ServerName pg.saic.it
        LoadModule wsgi_module modules/mod_wsgi.so
        SSLEngine on
        SSLCertificateFile /etc/ssl/certs/pg.saic.it.crt
        SSLCertificateKeyFile /etc/ssl/certs/pg.saic.it.key
        SSLCACertificateFile /etc/ssl/certs/saic.sslforfree.ca
        WSGIDaemonProcess pgadmin processes=1 threads=25
        WSGIScriptAlias /pgadmin4 /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi

        <Directory /usr/lib/python2.7/site-packages/pgadmin4-web/>
                WSGIProcessGroup pgadmin
                WSGIApplicationGroup %{GLOBAL}
                <IfModule mod_authz_core.c>
                        # Apache 2.4
                        Require all granted
                </IfModule>
                <IfModule !mod_authz_core.c>
                        # Apache 2.2
                        Order Deny,Allow
                        Deny from All
                        Allow from 127.0.0.1
                        Allow from ::1
                </IfModule>
        </Directory>
</VirtualHost>                

if you have this error in your Apache log file : Fatal Python error: PyEval_AcquireThread: NULL new thread state

is because mod_python have to removed from the modules

After the installation when you do an update the steps are: A, B, C

 

Use Let’s Encrypt for ssl certificate

From this web site follow the instructions to update your server web environment:

$ yum -y install yum-utils
$ yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
yum install certbot python2-certbot-apache

then run this for the website sample.lu

 certbot certonly --apache -d pennellificioeurope.it -d www.pennellificioeurope.it

or

certbot run -a webroot -i apache -w /path_to_web -d solci.eu -d www.solci.eu

this the result

Saving debug log to /var/log/letsencrypt/letsencrypt.log

Plugins selected: Authenticator webroot, Installer apache

Enter email address (used for urgent renewal and security notices) (Enter ‘c’ to

cancel): postmaster@saic.it

Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Please read the Terms of Service at

https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must

agree in order to register with the ACME server at

https://acme-v02.api.letsencrypt.org/directory

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

(A)gree/(C)ancel: A

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Would you be willing to share your email address with the Electronic Frontier

Foundation, a founding partner of the Let’s Encrypt project and the non-profit

organization that develops Certbot? We’d like to send you email about our work

encrypting the web, EFF news, campaigns, and ways to support digital freedom.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

(Y)es/(N)o: Y

Starting new HTTPS connection (1): supporters.eff.org

Obtaining a new certificate

Performing the following challenges:

http-01 challenge for sample.lu

http-01 challenge for www.sample.lu

Using the webroot path /var/www/sample.lu/web for all unmatched domains.

Waiting for verification…

Cleaning up challenges

Resetting dropped connection: acme-v02.api.letsencrypt.org

Deploying Certificate to VirtualHost /etc/httpd/conf/sites-enabled/100-sample.lu.vhost

Deploying Certificate to VirtualHost /etc/httpd/conf/sites-enabled/100-sample.lu.vhost

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

1: No redirect – Make no further changes to the webserver configuration.

2: Redirect – Make all requests redirect to secure HTTPS access. Choose this for

new sites, or if you’re confident your site works on HTTPS. You can undo this

change by editing your web server’s configuration.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Select the appropriate number [1-2] then [enter] (press ‘c’ to cancel): 2

Redirecting vhost in /etc/httpd/conf/sites-enabled/100-sample.lu.vhost to ssl vhost in /etc/httpd/conf/sites-enabled/100-sample.lu.vhost

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Congratulations! You have successfully enabled https://sample.lu and

https://www.sample.lu

You should test your configuration at:

https://www.ssllabs.com/ssltest/analyze.html?d=sample.lu

https://www.ssllabs.com/ssltest/analyze.html?d=www.sample.lu

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

IMPORTANT NOTES:

– Congratulations! Your certificate and chain have been saved at:

   /etc/letsencrypt/live/sample.lu/fullchain.pem

   Your key file has been saved at:

   /etc/letsencrypt/live/sample.lu/privkey.pem

   Your cert will expire on 2019-06-11. To obtain a new or tweaked

   version of this certificate in the future, simply run certbot again

   with the “certonly” option. To non-interactively renew *all* of

   your certificates, run 

sudo certbot renew –dry-run

for test

sudo certbot renew

for prod

or

/opt/certbot/certbot-auto renew -i apache -a webroot

single domain CORRECT to USE

certbot --apache certonly -n -d domain.com

remember to deactivate cloudfare dns proxy CDN and to deactivate any apache tomcat redirection before to run the renew.

– Your account credentials have been saved in your Certbot

   configuration directory at /etc/letsencrypt. You should make a

   secure backup of this folder now. This configuration directory will

   also contain certificates and private keys obtained by Certbot so

   making regular backups of this folder is ideal.

– If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let’s Encrypt:   https://letsencrypt.org/donate

   Donating to EFF:                    https://eff.org/donate-le

To renew seafile.saic.it do : 

mv /etc/httpd/conf.d/seafile.conf /etc/httpd/conf.d/seafile.conf.tmp

service httpd restart

/opt/certbot/certbot-auto renew -i apache -a webroot

service httpd restart

mv /etc/httpd/conf.d/seafile.conf.tmp /etc/httpd/conf.d/seafile.conf

To update an existing domain with adding a new subdomain

--expand tells Certbot to update an existing certificate with a new certificate that contains all of the old domains and one or more additional new domains. With the --expand option, use the -d option to specify all existing domains and one or more new domains.

Example:

certbot --expand -d existing.com,example.com,newdomain.com

If you prefer, you can specify the domains individually like this:

certbot --expand -d existing.com -d example.com -d newdomain.com

TO DELETE THE CERTIFICATE:

1. Verifica l’elenco dei certificati gestiti da Certbot

Esegui il comando seguente per visualizzare tutti i certificati attualmente gestiti da Certbot:

certbot certificates

Troverai una lista dei certificati attivi, con informazioni come il dominio principale, eventuali domini aggiuntivi, e il percorso del file di configurazione.

2. Identifica il certificato da rimuovere

Annota il nome del dominio o il cert name associato al certificato che desideri rimuovere.

3. Elimina il certificato

Per rimuovere il certificato e la sua configurazione dai rinnovi automatici, usa il comando:

certbot delete --cert-name nome-certificato

Sostituisci nome-certificato con il valore del Cert Name trovato nel passo precedente.

 

 

from here 

certbot docs

Linux Access to shared Windows Folder command

mount -t cifs //192.168.51.21/SWIFT-production/ /mnt/SWIFT-production -o user=foras,domain=farad.local

to give all permission

mount -t cifs //192.168.51.21/SWIFT-production/ /mnt/SWIFT-production -o user=foras,domain=farad.local,rw,file_mode=0777,dir_mode=0777

remove user tomcat from group root : gpasswd -d tomcat root

unmount with force a folder : umount -f -l /mnt/SWIFT-production/