August 2025
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

Categories

August 2025
M T W T F S S
 123
45678910
11121314151617
18192021222324
25262728293031

CentOS 7 Change Network Interface Name From Eno* To Eth0

CentOS 7 Change Network Interface Name From Eno* To Eth0

After you installed CentOS 7.0 or RHEL 7.0 system, you maybe notice that the default name of network interface was changed from “Eth*” to “Eno*”. How do I change network interface name to “Eth0? in CentOS 7.0? This post will show you the ways to change network interface.
CentOS 7 Change Network Interface Name
Step1# issue the ifconfig command to check the current network interface information, type:
# yum install net-tools

[root@localhost Desktop]$sudo ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.42.129 netmask 255.255.255.0 broadcast 192.168.42.255
inet6 fe80::20c:29ff:fec7:25ae prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:c7:25:ae txqueuelen 1000 (Ethernet)
RX packets 200948 bytes 253071365 (241.3 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 56043 bytes 3420351 (3.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Step2# edit “/etc/sysconfig/grub” configuration file using “vim” command:
before:

[root@localhost Desktop]$sudo vim /etc/sysconfig/grub
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT=”console”
GRUB_CMDLINE_LINUX=”rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet”
GRUB_DISABLE_RECOVERY=”true”
then searching for “GRUB_CMDLINE_LINUX” line and appending the following content “net.ifnames=0 biosdevname=0“, just like the below:
1
GRUB_CMDLINE_LINUX=”rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet net.ifnames=0 biosdevname=0″
Step3# Using “grub2-mkconfig” command to re-generate a new grub configuration file, type:

[root@localhost Desktop]$sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file …
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Warning: Please don’t use old title `CentOS Linux, with Linux 3.10.0-123.el7.x86_64′ for GRUB_DEFAULT, use `Advanced options for CentOS Linux CentOS Linux, with Linux 3.10.0-123.el7.x86_64′ (for versions before 2.00) or `gnulinux-advanced-dbedd8fa-5d86-4ea0-8551-8444a48cd44f nulinux-3.10.0-123.el7.x86_64-advanced-dbedd8fa-5d86-4ea0-8551-8444a48cd44f’ (for 2.00 or later)
Found linux image: /boot/vmlinuz-0-rescue-3303e35a730a41e3b4e99b544acea205
Found initrd image: /boot/initramfs-0-rescue-3303e35a730a41e3b4e99b544acea205.img
done
Step4# Rename “Eno” network file using ”mv” command, type:

$sudo mv /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/sysconfig/network-scripts/ifcfg-eth0

Step5# Edit “/etc/sysconfig/network-scripts/ifcfg-eth0 ” configuration file and set the value of “Name” field to “eth0?.

# vim /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=eth0
UUID=5ae10208-855b-41af-99e7-0673d3792d15
ONBOOT=yes
HWADDR=00:0C:29:C7:25:AE
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
?
Step6# reboot system, after rebooting system, using “ifconfig” command check network interface information again.

[root@localhost Desktop]# ifconfig
eth0: flags=4163 UP,BROADCAST,RUNNING,MULTICAST mtu 1500
inet 192.168.42.129 netmask 255.255.255.0 broadcast 192.168.42.255
inet6 fe80::20c:29ff:fec7:25ae prefixlen 64 scopeid 0x20
ether 00:0c:29:c7:25:ae txqueuelen 1000 (Ethernet)
RX packets 49 bytes 5285 (5.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 76 bytes 8540 (8.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
done….

Linux | Emptying the buffers cache and Swap

Emptying the buffers cache
If you ever want to empty it you can use this chain of commands.

$ free && sync && echo 3 > /proc/sys/vm/drop_caches && free

total used free shared buffers cached
Mem: 1018916 980832 38084 0 46924 355764
-/+ buffers/cache: 578144 440772
Swap: 2064376 128 2064248
total used free shared buffers cached
Mem: 1018916 685008 333908 0 224 108252
-/+ buffers/cache: 576532 442384
Swap: 2064376 128 2064248
You can signal the Linux Kernel to drop various aspects of cached items by changing the numeric argument to the above command.

To free pagecache:
$ echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
$ echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
$ echo 3 > /proc/sys/vm/drop_caches
The above are meant to be run as root. If you’re trying to do them using sudo then you’ll need to change the syntax slightly to something like these:

$ sudo sh -c ‘echo 1 >/proc/sys/vm/drop_caches’
$ sudo sh -c ‘echo 2 >/proc/sys/vm/drop_caches’
$ sudo sh -c ‘echo 3 >/proc/sys/vm/drop_caches’
NOTE: There’s a more esoteric version of the above command if you’re into that:

$ echo “echo 1 > /proc/sys/vm/drop_caches” | sudo sh
Why the change in syntax? The /bin/echo program is running as root, because of sudo, but the shell that’s redirecting echo’s output to the root-only file is still running as you. Your current shell does the redirection before sudo starts.

Seeing what’s in the buffers and cache
Take a look at linux-ftools if you’d like to analyze the contents of the buffers & cache. Specifically if you’d like to see what files are currently being cached.

fincore
With this tool you can see what files are being cached within a give directory.

fincore [options] files…

–pages=false Do not print pages
–summarize When comparing multiple files, print a summary report
–only-cached Only print stats for files that are actually in cache.
For example, /var/lib/mysql/blogindex:

root@xxxxxx:/var/lib/mysql/blogindex# fincore –pages=false –summarize –only-cached *
stats for CLUSTER_LOG_2010_05_21.MYI: file size=93840384 , total pages=22910 , cached pages=1 , cached size=4096, cached perc=0.004365
stats for CLUSTER_LOG_2010_05_22.MYI: file size=417792 , total pages=102 , cached pages=1 , cached size=4096, cached perc=0.980392
stats for CLUSTER_LOG_2010_05_23.MYI: file size=826368 , total pages=201 , cached pages=1 , cached size=4096, cached perc=0.497512
stats for CLUSTER_LOG_2010_05_24.MYI: file size=192512 , total pages=47 , cached pages=1 , cached size=4096, cached perc=2.127660
stats for CLUSTER_LOG_2010_06_03.MYI: file size=345088 , total pages=84 , cached pages=43 , cached size=176128, cached perc=51.190476
stats for CLUSTER_LOG_2010_06_04.MYD: file size=1478552 , total pages=360 , cached pages=97 , cached size=397312, cached perc=26.944444
stats for CLUSTER_LOG_2010_06_04.MYI: file size=205824 , total pages=50 , cached pages=29 , cached size=118784, cached perc=58.000000
stats for COMMENT_CONTENT_2010_06_03.MYI: file size=100051968 , total pages=24426 , cached pages=10253 , cached size=41996288, cached perc=41.975764
stats for COMMENT_CONTENT_2010_06_04.MYD: file size=716369644 , total pages=174894 , cached pages=79821 , cached size=326946816, cached perc=45.639645
stats for COMMENT_CONTENT_2010_06_04.MYI: file size=56832000 , total pages=13875 , cached pages=5365 , cached size=21975040, cached perc=38.666667
stats for FEED_CONTENT_2010_06_03.MYI: file size=1001518080 , total pages=244511 , cached pages=98975 , cached size=405401600, cached perc=40.478751
stats for FEED_CONTENT_2010_06_04.MYD: file size=9206385684 , total pages=2247652 , cached pages=1018661 , cached size=4172435456, cached perc=45.321117
stats for FEED_CONTENT_2010_06_04.MYI: file size=638005248 , total pages=155763 , cached pages=52912 , cached size=216727552, cached perc=33.969556
stats for FEED_CONTENT_2010_06_04.frm: file size=9840 , total pages=2 , cached pages=3 , cached size=12288, cached perc=150.000000
stats for PERMALINK_CONTENT_2010_06_03.MYI: file size=1035290624 , total pages=252756 , cached pages=108563 , cached size=444674048, cached perc=42.951700
stats for PERMALINK_CONTENT_2010_06_04.MYD: file size=55619712720 , total pages=13579031 , cached pages=6590322 , cached size=26993958912, cached perc=48.533080
stats for PERMALINK_CONTENT_2010_06_04.MYI: file size=659397632 , total pages=160985 , cached pages=54304 , cached size=222429184, cached perc=33.732335
stats for PERMALINK_CONTENT_2010_06_04.frm: file size=10156 , total pages=2 , cached pages=3 , cached size=12288, cached perc=150.000000

total cached size: 32847278080
With the above output you can see that there are several *.MYD, *.MYI, and *.frm files that are currently being cached.

Swap
If you want to clear out your swap you can use the following commands.

$ free
total used free shared buffers cached
Mem: 7987492 7298164 689328 0 30416 457936
-/+ buffers/cache: 6809812 1177680
Swap: 5963772 609452 5354320
Then use this command to disable swap:

$ swapoff -a
You can confirm that it’s now empty:

$ free
total used free shared buffers cached
Mem: 7987492 7777912 209580 0 39332 489864
-/+ buffers/cache: 7248716 738776
Swap: 0 0 0
And to re-enable it:

$ swapon -a
And now reconfirm with free:

$ free
total used free shared buffers cached
Mem: 7987492 7785572 201920 0 41556 491508
-/+ buffers/cache: 7252508 734984
Swap: 5963772 0 5963772

Configuring SSL and Gitlab through an Apache Reverse Proxy

Configuring SSL and Gitlab through an Apache Reverse Proxy

I’ve recently started to use Gitlab as an alternative to a Github paid account for projects I don’t wish to make public. I wanted to install Gitlab on a server which is used for a few other applications which all use Apache, while Gitlab is really easy to install it installs nginx by default and expects to run on port 80. Normally in this situation I would configure Nginx to point to a non standard port, proxy through apache on the same server and terminate the SSL at apache, however there are some quirks in Gitlab which make this difficult; in this post I’ll describe how to proxy Gitlab through apache using SSL.

The Problem

While Gitlab can be manually installed to work with apache this makes upgrades / changes difficult, it comes with a very nice Chef based installer but it assumes it’s the only thing installed, if a simple HTTPS proxy is configured (terminating the SLL at Apache) then Gitlab will still mix in some non SSL URLs as it thinks it’s still using an unencrypted connection, while not a huge risk this is untidy and annoyed me.

The Solution

The solution is to configure Gitlab to use SSL too and enable an SSL proxy in Apache, this involves defining options in two files:

gitlab.rb

external_url 'https://<url>:4443'
nginx['ssl_certificate'] = "/etc/ssl/localcerts/<certname>.crt"
nginx['ssl_certificate_key'] = "/etc/ssl/localcerts/<keyname>.key"

After which don’t forget to run

 sudo gitlab-ctl reconfigure 

to push the changes into the nginx config

Apache vhost

<VirtualHost <ip>:443>

        ServerName <server url>
        SSLEngine on
        SSLCertificateFile /etc/ssl/localcerts/<certname>.crt
        SSLCertificateKeyFile /etc/ssl/localcerts/<keyname>.key
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    SSLProxyEngine on
    ProxyRequests Off
    ProxyPass / https://<url>:4443/
    ProxyPassReverse / https://<url>/

    Header edit Location ^http://<url>/ https://<url>/
    RequestHeader set X-Forwarded-Proto "https"


Proxying from Apache HTTPS to some backend server that only speaks HTTP

Here’s a use case: You want to run an application server that only speaks HTTP, but securely, over HTTPS. The problem is that the application server won’t know that it’s being accessed via HTTPS, so any URLs and redirects it generates might point to HTTP. Here’s an example virtual host entry that takes care of that by rewriting the header.

You need Apache, mod_proxy and mod_headers.

<VirtualHost *:443>
  ServerName foo.bar.example.com

  SSLEngine on
  SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
  Header edit Location "^http:(.*)$" "https:$1"

  PassengerEnabled off
  ProxyPass / http://127.0.0.1:3000/
  ProxyPassReverse / http://127.0.0.1:3000/

  DocumentRoot /var/www/foo/bar
  <Directory /var/www/foo/bar>
    AllowOverride none
    Options -MultiViews
  </Directory>
</VirtualHost>

The magical line is the one with “Header edit…”. This makes sure any request your app server would have sent to HTTP are rewritten to HTTPS.

302 Redirects behind SSL-terminating proxies
Problem

You have a web site all with SSL. There is a reverse proxy or load balancer that acts as SSL termination point. Behind that reverse proxy you have an Apache web server running plain http.

Your application uses 302 redirects to announce new URLs or whatever the reason is for doing so. Since the web server does not know that https URLs should be announced, the response header is wrong and looks like following:

Location http://www.example.com/your-fancy-url

The browser interprets that location header and send a request to this non-SSL URL instead of https:///www.example.com/your-fancy-url

If your reverse proxy does not know how to handle this, a connection will time-out. How to circumvent this if you have access to the web server but not to the reverse proxy or load balancer? What to do if your load balancer (such as Blue Coat devices) are closed down appliances that are not able to rewrite response headers?

Search engines do obviously not know the answer or I simply did not asked the right question.

Solution

Since Apache version 2.2.4 mod_headers is able to rewrite response headers. Just add the following to your httpd.conf

Header edit Location ^http://(.*)$ https://$1
This configuration statement will solve your problem. Redirects triggered by your back end web servers will be re-rewritten to comply with your SSL terminating reverse proxy/load balancer.

centos 6.8 NOTES RHEL6.8 NOTES

###########################
### RHEL/CentOS install ###
###########################

### Link for netinstall ##
http://ftp.astral.ro/distros/centos/6.8/os/x86_64/

###########
### yum ###
###########

yum update        # update toate pachetele si dependintele lor
yum search nume_pachet    # cauta un anume pachet, pot fi mai multe pachete trecute
yum info nume_pachet    # afiseaza detalii despre un anume pachet
yum list nume_pache        # afiseaza informatii despre un anumit pachet, instalat sau nu
yum list nume_pachet\*     # afiseaza informatii despre toate pachetele care incep cu un nume
yum list all        # afiseaza toate pachetele disponibile
yum list installed “*nume_pachet*”  # afiseaza pachetele instalate care contine un nume
yum list installed | grep reponame  # afiseaza pachetele instalate dintr-un repo
yum list available    # afiseaza pachetele disponibile in functie de repo-urile instalate
yum repolist        # afiseaza repo-urile instalate
yum gruplist        # afiseaza
yum install nume_pachet\* # instaleaza toate pachetele care incep cu un nume
yum downgrade nume_pachet
yum provides “*/nume_pachet” # afiseaza fisierele care le detine un pachet
yum -v grouplist kde\*  # listeaza toate pachetele ce tin de KDE
yum groupinstall “KDE Software Compilation” # instaleaza toate pachetele ce tin de KDE
yum groupinstall kde-desktop
yum install @kde-desktop  # @ pentru a instala un grup
yum remove nume_pachet
yum groupremove “KDE Software Compilation”
yum groupremove kde-desktop
yum remove @kde-desktop
yum history list
yum history list nume_pachet
yum repolist all  # list all repositories set up on your system
yum –exclude=packagename\* …

################
### yum.conf ###
################

### skip updating packages ###
yum -x nume_pachet update
yum –exclude=nume_pachet update

sudo vim /etc/yum.conf  # permanent
_______
[main]
exclude=nume_pachet1* nume_pachet2*
_______
yum –disableexcludes=all update  # disable exclude to check for an update

### Remove Old Kernels ###
# Package-cleanup set count as how many old kernels you want left #
package-cleanup –oldkernels –count=2

# Make Amount of Installed Kernels Permanent #
vim /etc/yum.conf # and set installonly_limit:
installonly_limit=2

### Removing dependencies ###
sudo vim /etc/yum.conf
______________________________
[main]
clean_requirements_on_remove=1
______________________________

###########
### RPM ###
###########

rpm -ivh package-2.7.9-5.el6.2.i686.rpm  # Install an RPM Package
-i : install a package
-v : verbose for a nicer display
-h: print hash marks as the package archive is unpacked

rpm -qpR package-5.2.2-1.noarch.rpm   # check dependencies of RPM Package before Installing
-q : Query a package
-p : List capabilities this package provides.
-R: List capabilities on which this package depends..

rpm -ivh –nodeps package-5.2.2-1.noarch.rpm  # Install a RPM Package Without Dependencies
–nodeps (Do not check dependencies)

rpm -q package   # check an Installed RPM Package
rpm -ql package  # List all files of an installed RPM package

rpm -qa –last  # List Recently Installed RPM Packages
rpm -qa        # List All Installed RPM Packages

rpm -Uvh package-3.5.0-2.el6.centos.i686.rpm  # Upgrade a RPM Package

rpm -evv package  # Remove a RPM Package
rpm -ev –nodeps package  # Remove an RPM Package Without Dependencies
-e (erase)

rpm -qi package  # Query a Information of Installed RPM Package
-qi (query info)

rpm -qf /usr/bin/package  # Query a file that belongs which RPM Package
-qf (query file)

rpm -qip package-1.3.3-1.noarch.rpm  # Information of RPM Package Before Installing
-qip (query info package)

rpm -qdf /usr/bin/vmstat  # Query documentation of Installed RPM Package
-qdf (query document file)

rpm -Vp package-1.3.3-1.noarch.rpm  # Verify a RPM Package
-Vp (verify package)
rpm -Va  # Verify all RPM Packages

rpm -qa gpg-pubkey*  # List all Imported RPM GPG keys

######################
### YUM & RPM tips ###
######################

#Query packages not from CentOS #
rpm -qa –qf ‘%{NAME} %{VENDOR}\n’ | grep -v CentOS

# Reset File Permissions #
rpm –setperms <packagename>

# View the Changelog of a package #
rpm -q –changelog <packagename> | less

# quickly list documentation relating to a package #
rpm -qd <packagename>

# Query Package Install Order and Dates #
rpm -qa –last > ~/RPMS_by_Install_Date

# Query Available Packages from a Repo #
yum –disablerepo “*” –enablerepo “rpmforge” list available

# Enable or Disable a Repo from the Command Line #
yum-config-manager –enable c6-media
yum-config-manager –disable c6-media

# Show all installed GPG keys #
rpm -q gpg-pubkey –qf ‘%{name}-%{version}-%{release} –> %{summary}\n’

### package-cleanup ###
package-cleanup –orphans
package-cleanup –leaves
package-cleanup –dupes
package-cleanup –problems
package-cleanup –oldkernel

### Fonts config ###
vim ~/.fonts.conf
__________________________________________
<?xml version=’1.0′?>
<!DOCTYPE fontconfig SYSTEM ‘fonts.dtd’>
<fontconfig>
<match target=”font”>
<edit mode=”assign” name=”rgba”>
<const>rgb</const>
</edit>
</match>
<match target=”font”>
<edit mode=”assign” name=”hinting”>
<bool>true</bool>
</edit>
</match>
<match target=”font”>
<edit mode=”assign” name=”hintstyle”>
<const>hintslight</const>
</edit>
</match>
<match target=”font”>
<edit mode=”assign” name=”antialias”>
<bool>true</bool>
</edit>
</match>
<match target=”font”>
<edit mode=”assign” name=”lcdfilter”>
<const>lcddefault</const>
</edit>
</match>
</fontconfig>
__________________________________________

### Add an user to SUDOERS ###
su –
visudo
sergiu        ALL=(ALL)    ALL

Or add the user to wheel group and enable wheel from visudo

#############
### Repos ###
#############
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

# Multimedia #
rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
sudo wget http://li.nux.ro/download/nux/misc/nux-misc.repo -P /etc/yum.repos.d/
sudo yum –enablerepo=nux-dextop-testing install xbmc

# nVidia driver #
rpm -Uvh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm
http://elrepo.org/linux/extras/el6/x86_64/RPMS/   # extras
http://elrepo.org/linux/testing/el6/x86_64/RPMS/  # testing
sudo yum install kmod-nvidia
sudo yum install nvidia-x11-drv

# Last kernel & lts kernel #
http://elrepo.org/linux/kernel/el6/x86_64/RPMS/   # kernel
sudo yum remove kernel-headers kernel-firmware
sudo yum –enablerepo=elrepo-kernel install kernel-ml kernel-ml-devel kernel-ml-headers kernel-ml-firmware  # for last kernel
sudo yum –enablerepo=elrepo-kernel install kernel-lt kernel-lt-devel kernel-lt-headers kernel-lt-firmware  # for lts kernel

# Others #
rpm -Uvh http://download1.rpmfusion.org/free/el/updates/6/x86_64/rpmfusion-free-release-6-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/6/x86_64/rpmfusion-nonfree-release-6-0.1.noarch.rpm    # (not needed if nux-dextop is installed)

### Install Google Chrome ###
wget http://chrome.richardlloyd.org.uk/install_chrome.sh
chmod u+x install_chrome.sh
./install_chrome.sh
sudo grep chrome /var/log/audit/audit.log | audit2allow -M mypol
sudo semodule -i mypol.pp

### Install Chromium ###
cd /etc/yum.repos.d
wget http://people.centos.org/hughesjr/chromium/6/chromium-el6.repo
yum install chromium
sudo setsebool -P mmap_low_allowed 1

### Install lastest Firefox ###
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum –enablerepo=remi install firefox

### Others ###
yum install bash-completion
yum install nautilus-open-terminal
yum install flash-plugin
yum install gconf-editor
yum install gnome-utils
yum install file-roller
yum install ntfsprogs

### Apps ###
yum install pidgin pidgin-plugin-pack skype
yum install geany filezilla transmission mc
yum install radiotray tv-maxe xbmc clementine

### xscrennsaver ###
yum remove gnome-screensaver
yum install xscreensaver
xscreensaver -nosplash  # open Startup Applications and add Xscreensaver to startup

### Change the hostname ###
hostname   # to check your hostname
sudo hostname RedHat
vim /etc/sysconfig/network

### Dropbox ###
vim /etc/sysconfig/dropbox  # DROPBOX_USERS=”sergiu”
echo ‘-b /usr/libexec/dropbox/’ > /etc/prelink.conf.d/dropbox.conf
yum –enablerepo rpmforge reinstall dropbox

### Install LibreOffice 4.1.2 ###
wget http://download.documentfoundation.org/libreoffice/stable/4.1.2/rpm/x86_64/LibreOffice_4.1.2_Linux_x86-64_rpm.tar.gz
tar -xvf LibreOffice_4.1.2*
cd LibreOffice_4.1.2*
yum localinstall RPMS/*.rpm RPMS/desktop-integration/libreoffice4.1-freedesktop-menus-4.1.2*.noarch.rpm

### Install vbox additions ###
yum install gcc kernel-devel kernel-headers dkms make bzip2
KERN_DIR=/usr/src/kernels/`uname -r`
export KERN_DIR
cd /media/VirtualBoxGuestAdditions
./VBoxLinuxAdditions.run

### Remove boot splash screen ###
vim /etc/grub.conf  # remove ‘rhgb’ and ‘quiet’

### Remove Desktop icons ###
yum install gconf-editor
apps > nautilus > desktop

### Multimedia support ###
sudo yum install gstreamer gstreamer-plugins-base gstreamer-plugins-good gstreamer-plugins-bad-free
sudo yum install gstreamer-plugins-bad gstreamer-plugins-ugly gstreamer-ffmpeg

### Save alsamixer settings ###
sudo alsactl store
ls -Z /etc/asound.*  # to see SElinux label

sudo vim /etc/pulse/daemon.conf
_______________________________
enable-remixing = yes
enable-lfe-remixing = yes
default-sample-format = s32le
default-sample-rate = 48000
default-sample-channels = 6
default-fragments = 8
default-fragment-size-msec = 5
________________________________

pulseaudio -k  # restart pulseaudio

### Disable window move with alt + left mouse button ###
# conf-editor
# /apps/metacity/general
# “mouse_button_modifier” option change <Alt> to <Super>

####################################
### CentOS Protection & Security ###
####################################
# Securing and Hardening Red Hat Linux Production Systems
http://www.puschitz.com/SecuringLinux.shtml
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/index.html

### SElinux ###
Two important documentations about Selinux can be found here:
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/index.html
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Confined_Services/index.html

# You can view current status of SELinux mode from the command line using these:
system-config-selinux
getenforce  # if you get back a 1 selinux is turned on if you get back a 0 its turned off
sestatus

# If it is disabled, enable SELinux using the following command.
setenforce enforcing  # changes do not persist through a system reboot
To make changes persistent through a system reboot, edit the ‘SELINUX=’ line in  /etc/selinux/config for either ‘enforcing’, ‘permissive’, or ‘disabled’. For example: ‘SELINUX=permissive’

# SElinux logs (/var/log/audit/audit.log) #
yum install setroubleshoot
setroubleshootd
sealert -a /var/log/audit/audit.log  # if you only have a console available and no X-Window System
sealert -b  # if you have gui

# SElinux re-labelling #
touch /.autorelabel
sudo reboot

### Password Protect Grub and Single-User Mode ###
# It is highly important to protect your bootloader.
# There is a magic kernel parameter called init=/bin/sh. This makes any user/login restrictions totally useless. Then mount -o remount,rw /

grub-crypt
vim /etc/grub.conf
______________________________________________
default=0
timeout=2
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
password –encrypted $6$w1lrwrXOMm5ueR4M$…..
______________________________________________

vim /etc/sysconfig/init
_______________________
PROMPT=no

SINGLE=/sbin/sulogin
_______________________

### Modifying fstab ###

vim /etc/fstab
____________________________________________________________________
/dev/sda1    /boot    ext4    defaults,nosuid,noexec,nodev    1 2
/dev/sda2    swap    swap    defaults            0 0
/dev/sda3    /    ext4    defaults            1 1
/dev/sda4    /home    ext4    defaults,nosuid,nodev        1 2

# Others partitions
/tmp    ext4    defaults,nosuid,noexec,nodev    1 2
/var/tmp ext4    defaults,nosuid,noexec,nodev    1 2
/var    ext4    defaults,nosuid            1 2
/var/www ext4    defaults,nosuid,nodev        1 2
/dev/shm    tmpfs        defaults            0 0
devpts        /dev/pts devpts    gid=5,mode=620            0 0
sysfs        /sys    sysfs    defaults            0 0
proc        /proc    proc    defaults            0 0

____________________________________________________________________
# Note that some packages (building nvidia-dkms for example) may require exec on /var

# Keep /boot as read-only #
# Note that you need to reset the change to read-write if you need to upgrade the kernel in future
/dev/sda1    /boot    ext4    defaults,nosuid,noexec,nodev,ro    1 2

### Disable Control -Alt -Delete keys on the console mode ###
vim /etc/init/control-alt-delete.conf
______________________________
# start on control-alt-delete
# exec /sbin/shutdown -r now “Control -Alt -Delete pressed”
______________________________

### Umask restrictions  ###
# Set a umask of 077 for maximum security, which makes new files not readable by users other than the owner.
perl -npe ‘s/umask\s+0\d2/umask 077/g’ -i /etc/bashrc
perl -npe ‘s/umask\s+0\d2/umask 077/g’ -i /etc/csh.cshrc

### Find users with empty passwords ###
awk -F: ‘($2 == “”) {print}’ /etc/shadow    # Shouldn’t see anything amiss here
awk -F: ‘($3 == “0”) {print}’ /etc/passwd   # Only the root user has uid 0. No other user should ever have uid 0

### Disable USB mass storage ###
echo “Disabling USB Mass Storage”
echo “blacklist usb-storage” > /etc/modprobe.d/blacklist-usbstorage

### Disable USB stick to detect ###
vim /etc/modprobe.d/no-usb
_____________________________
install usb-storage /bin/true
_____________________________

### Narrowing rights ###
chmod 700 /root               # before 0550 dr-xr-x—
chmod 700 /var/log/audit        # before 0750 drwxr-x—
chmod 740 /etc/rc.d/init.d/iptables    # before 0755 -rwxr-xr-x
chmod -R 700 /etc/skel            # before 0755 drwxr-xr-x
chmod 640 /etc/security/access.conf    # before 0644 -rw-r–r–
chmod 600 /etc/sysctl.conf        # before 0644 -rw-r–r–

########################
### Network Security ###
########################

### Sysctl ###
vim /etc/sysctl.conf
_______________________________________________
### ipv4 Security options ###

# Disable IP Source Routing #
# Source Routing is used to specify a path or route through the network from source to destination.
# This feature can be used by network people for diagnosing problems.
# However, if an intruder was able to send a source routed packet into the network, then he could intercept the replies and your server might not know that it’s not communicating with a trusted server.
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0

# Disable ICMP Redirect Acceptance #
# ICMP redirects are used by routers to tell the server that there is a better path to other networks than the one chosen by the server.
# However, an intruder could potentially use ICMP redirect packets to alter the hosts’s routing table by causing traffic to use a path you didn’t intend.
net.ipv4.conf.all.accept_redirects = 0

# Enable IP Spoofing Protection #
# IP spoofing is a technique where an intruder sends out packets which claim to be from another host by manipulating the source address.
# IP spoofing is very often used for denial of service attacks.
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1

# Enable Ignoring to ICMP Requests #
net.ipv4.icmp_echo_ignore_all = 1

# Enable Ignoring Broadcasts Request #
net.ipv4.icmp_echo_ignore_broadcasts = 1

# Enable Bad Error Message Protection #
net.ipv4.icmp_ignore_bogus_error_responses = 1

# Enable Logging of Spoofed Packets, Source Routed Packets, Redirect Packets #
net.ipv4.conf.all.log_martians = 1

# This help a little wtih SYN flood attacks. This suppliments a good firewall ruleset #
net.ipv4.tcp_syncookies = 1

# This is a server, not a router. Disable packet forwarding #
net.ipv4.ip_forward = 0

# Others ipv4 security options #
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.tcp_max_syn_backlog = 1280
net.ipv4.tcp_timestamps = 0

### ipv6 Security options ###
net.ipv6.conf.all.disable_ipv6 = 1

### Memory/Swap Use ###
vm.swappiness = 1
vm.vfs_cache_pressure = 50
_______________________________________________

sysctl -p

### IPTables ###
sudo vim /etc/sysconfig/iptables
____________________________________________________________________________
#Drop anything we aren’t explicitly allowing. All outbound traffic is okay
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT – [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp –icmp-type echo-reply -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp –icmp-type destination-unreachable -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp –icmp-type time-exceeded -j ACCEPT
# Accept Pings
-A RH-Firewall-1-INPUT -p icmp –icmp-type echo-request -j ACCEPT
# Log anything on eth0 claiming it’s from a local or non-routable network
# If you’re using one of these local networks, remove it from the list below
-A INPUT -i eth0 -s 10.0.0.0/8 -j LOG –log-prefix “IP DROP SPOOF A: ”
-A INPUT -i eth0 -s 172.16.0.0/12 -j LOG –log-prefix “IP DROP SPOOF B: ”
-A INPUT -i eth0 -s 192.168.0.0/16 -j LOG –log-prefix “IP DROP SPOOF C: ”
-A INPUT -i eth0 -s 224.0.0.0/4 -j LOG –log-prefix “IP DROP MULTICAST D: ”
-A INPUT -i eth0 -s 240.0.0.0/5 -j LOG –log-prefix “IP DROP SPOOF E: ”
-A INPUT -i eth0 -d 127.0.0.0/8 -j LOG –log-prefix “IP DROP LOOPBACK: ”
# Accept any established connections
-A RH-Firewall-1-INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
# Accept ssh traffic. Restrict this to known ips if possible.
#-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
#Log and drop everything else
-A RH-Firewall-1-INPUT -j LOG
-A RH-Firewall-1-INPUT -j DROP
COMMIT
______________________________________________________________________________

### Detecting Listening Network Ports ###
netstat -tulpn

### Services configuration ###
chkconfig –list        # list all known services
chkconfig –list | grep 3:on    # list running services
chkconfig [service] on/off    # turn on / off service

for i in atd blk-availability bluetooth mdmonitor lvm2-monitor iscsi iscsid nfslock rpcbind rpcgssd rpcidmapd livesys livesys-late pcscd openct postfix fcoe ip6tables; do service $i stop; chkconfig $i off; done

##############
### Others ###
##############

### Wake-on-lan ###
echo ‘/usr/sbin/ethtool -s eth0 wol g’ >> /etc/rc.d/rc.local
or
vim /etc/sysconfig/network-scripts/ifcfg-eth0
_____________________
DEVICE=eth0
TYPE=EThernet
ONBOOT=yes
ETHTOOL_OPTS=”wol g”
______________________
chkconfig network on

Wake up the computer from internet
This involves enabling port forwarding of UDP port 9 to the destination computer in the router’s administration webpage.
To fully benefit from WOL you should configure a dynamic DNS service.
Just make sure to use your dynamic DNS provided address and the destination computer’s MAC.

### Wine & wine fonts ###
rpm -ev –nodeps wine-tahoma-fonts.noarch

sudo setsebool -P wine_mmap_zero_ignore 1
sudo grep wine-preloader /var/log/audit/audit.log | audit2allow -M mypol
sudo semodule -i mypol.pp

wget http://files.polosatus.ru/winefontssmoothing_en.sh
bash winefontssmoothing_en.sh

# Wine bottles #
env WINEPREFIX=~/.wine/CounterStrike wine CounterStrike1.6.exe

### dd ###
# format a USB #
dd if=/dev/zero of=/dev/sdX
# see the progress of dd #
ps -A | grep dd
sudo kill -USR1 {nr of PID}

### mc ###
gnome-terminal –geometry=239×68 -e “mc -S featured.ini”

### GIT HUB ###
ssh-keygen -t rsa -C “contact.sergiuniculescu@gmail.com”
vim ~/.ssh/id_rsa.pub  # copy key and paste it to github.com

git config –global user.name “Sergiu Niculescu”
git config –global user.email contact.sergiuniculescu@gmail.com

### Kernel compile ###
yum install gcc ncurses ncurses-devel
yum update
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3…
tar -jxvf linux-3*
cd linux-3*
make menuconfig   # allows you to select the already running kernel’s configuration file (resides in /boot/), and accepts the defaults for all options that were introduced between the old and the new version of the kernel
make oldconfig    # automatically finds the configuration file in /boot/ and asks you questions for all the new configuration options
make
make modules_install install

### Find commands ###
find /home -iname name    # Files Using Name and Ignoring Case
find / -type d -name directory_name  # Find Directories Using Name
find / -perm /u=r  # Find all Read Only files
find / -perm /a=x  # Find all Executable files
find . -type f -perm 0777 -print  # Find all the files whose permissions are 777
find / -type f -perm 0777 -print -exec chmod 644 {} \;  # Find all 777 permission files and use chmod command to set permissions to 644
find / -type d -perm 777 -print -exec chmod 755 {} \;   # Find Directories with 777 Permissions and Chmod to 755
find . -type f -name “tecmint.txt” -exec rm -f {} \;    # To find a single file called tecmint.txt and remove it
find . -type f -name “*.mp3” -exec rm -f {} \;        # Find and remove Multiple File with extension “.mp3”
find /tmp -type f -empty    # To file all empty files under certain path
find /tmp -type d -empty    # To file all empty directories under certain path
find /tmp -type f -name “.*”    # File all Hidden Files
find / \( -perm -4000 -o -perm -2000 \) -print     # Identify unwanted SUID and SGID Binaries
find / -path -prune -o -type f -perm +6000 -ls   # Identify unwanted SUID and SGID Binaries
find /dir -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print   # Identify world writable files
find /dir -xdev \( -nouser -o -nogroup \) -print   # Identify orphaned files and folders

### Netstat commands ###
netstat -a | more    # Listing all the LISTENING Ports of TCP and UDP connections
netstat -at        # Listing only TCP (Transmission Control Protocol) port connections
netstat -au        # Listing only UDP (User Datagram Protocol ) port connections
netstat -l        # Listing all active listening ports connections
netstat -lt        # Listing all active listening TCP ports
netstat -lu        # Listing all active listening UDP ports
netstat -lx        # Listing all active UNIX listening ports
netstat -s        # Showing Statistics by Protocol
netstat -r        # Display Kernel IP routing table

### Change the MAC address of Network Interface ###
ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF

### Mount an ISO Image ###
mount -t iso9660 -o loop /home/tecmint/Fedora-18-i386-DVD.iso /mnt/iso/
sudo umount /mnt/iso

### Mount a partition with read-write permission ###
mount -o remount,rw /

### Clone the boot partition ###
sudo dd if=/dev/sdb1 of=/dev/sdc1 bs=4096 conv=notrunc,noerror
dd if=/dev/sdb of=mbr.img bs=512 count=1
dd if=mbr.img of=/dev/sdc bs=446 count=1  # If you only want to restore the boot loader
dd if=mbr.img of=/dev/sdc bs=1 skip=446 count=64  # To restore only the partition table

### rsync ###
rsync -a –progress rsync://ftp.astral.ro/distros/centos/6.8/os/x86_64/ /opt/mirror/centos

system-config-kickstart  #  A graphical interface for making kickstart files

#############
### Games ###
#############

### UrbanTerror ###
tar -xjvf UrbanTerror42.tar.gz
cd UrbanTerror42
chmod u+x UrTUpdater_Ded.x86_64 Quake3-UrT.x86_64
./UrTUpdater_Ded.x86_64
./Quake3-UrT.x86_64

Access authorization in Apache 2.4

In Apache 2.4 the authorization configuration setup has changed from previous versions. Satisfy, Order, Deny and Allow have all been deprecated and replaced with new Require directives.

Below we’ve compiled some examples to guide you through the transition.

If you are upgrading a server using the legacy authorization directives you can make them work quickly by enabling (it should be activated by default) mod_access_compat in Apache:

sudo a2enmod access_compat

1. Apache Documentation

The documentation from Apache: Upgrading to 2.4 from 2.2 provides the following basic examples. The old configuration settings are on the left, and the new ones for Apache 2.4 on the right:

All requests are denied:

Order deny,allow Deny from allRequire all denied

All requests are allowed:

Order allow,deny Allow from allRequire all granted

Only hosts in the example.org domain are allowed access:

Order Deny,Allow Deny from all Allow from example.orgRequire host example.org

But this only scratches the surface of what’s now available.

2. RequireAll and RequireAny

The most interesting new features are the RequireAll, RequireAny and RequireNone authorization containers. They promise to be both more powerful and more human-readable than the old syntax.

By default all Require directives are handled as though contained within a <RequireAny>container directive. In other words, if any of the specified authorization methods succeed, then authorization is granted.

Here is real world example where a website limits access by requiring a Basic Authentication login for certain directories:

AuthType Basic AuthName "Password Protected" AuthUserFile <path_to_your_htpasswd_file> SetEnvIf REQUEST_URI "^/(admin|secure)/" PROTECTED Deny from all Satisfy any Allow from env=!PROTECTED Require valid-userSetEnvIf REQUEST_URI "^/(admin|secure)/" PROTECTED <RequireAny> <RequireAll> Require not env PROTECTED Require all granted </RequireAll> <RequireAll> AuthType Basic AuthName "Password Protected" AuthUserFile <path_to_your_htpasswd_file> Require valid-user </RequireAll> </RequireAny>

In both cases we set an environmental variable PROTECTED when the request is for a file in the /admin/or /secure/ directories. The syntax for this part hasn’t changed. If this variable is set, then a password will be required for access.

While the old syntax works, it’s not immediately clear how it works. Basically to get access the request has to meet (Satisfy) either the Allow or the Require directive.

In the new syntax this is more explicit. The request needs to pass at least one (RequireAny) of the twoRequireAll container rulesets. The first container grants all users access to non-PROTECTED directories, while the second container requires a valid login.

You can keep nesting containers until all possible options are covered.

But seeing as the outer <RequireAny> is already implied, we should be able to remove it. Actually we can remove quite a bit now that we know what we’re doing:

AuthType Basic AuthName "Password Protected" AuthUserFile <path_to_your_htpasswd_file> SetEnvIf REQUEST_URI "^/(admin|secure)/" PROTECTED <RequireAll> Require not env PROTECTED </RequireAll> Require valid-user

Note that any Require not directives must always be enclosed in a RequireAll directive. Otherwise you will see an alert logged:

[core:alert] ... negative Require directive has no effect in <RequireAny> directive

See further down the page a version of this example that does away with the ENV variable entirely by using an expr condition.

3. Require authorization providers

The Require directive comes with a number of build-in authorization providers, including some already demonstrated above. Different modules provide different methods.

The following are provided by the mod_authz_core module:

all

Replaces Allow from all and Deny from all in the old syntax:

Require all grantedRequire all denied

env

Require env safe_zone<RequireAll> Require not env PROTECTED </RequireAll>

method

This example allows only GET and HEAD requests unless you are logged in:

<RequireAny> Require method GET HEAD Require valid-user </RequireAny>

The <RequireAny> container is not necessary here, but included for clarity:

expr

Require expr %{HTTP_USER_AGENT} != 'BadBot'

The following options are provided by the mod_authz_host module:

local

Require local

ip

<RequireAll> Require ip 192.168.1.0/24 Require not ip 192.168.1.104 </RequireAll>Require ip 2001:db8:1:1::/64

host

<RequireAll> Require host example.org Require not host blocked.example.org </RequireAll>

4. Working with expressions

After a bit of messing about we were able to further simplify the previous example by removing theSetEnvIf clause and replacing it with a Require expr regular expression condition.

AuthType Basic AuthName "Password Protected" AuthUserFile <path_to_your_htpasswd_file> SetEnvIf REQUEST_URI "^/(admin|secure)/" PROTECTED <RequireAll> Require not env PROTECTED </RequireAll> Require valid-userAuthType Basic AuthName "Password Protected" AuthUserFile <path_to_your_htpasswd_file> Require expr %{REQUEST_URI} !~ m#^/(admin|secure)/# Require valid-user

The tricky part was working out how to include the forward slash / in the regular expression. The solution is instead of the default format which doesn’t allow a forward slash in the match:

Require expr %{REQUEST_URI} !~ /expr/

To use the alternative syntax:

Require expr %{REQUEST_URI} !~ m#expr#

For details on other SERVER variables and comparison operators that can be used see the link under References below.

5. Granting local access

Another real world example is granting access only to the local network.

In this case we’re defining the local network as the server itself (localhost), plus the 192.168.1.* subnet covering 192.168.1.0 – 192.168.1.255.

<Directory "/path/to/your/website"> Options FollowSymlinks AllowOverride None Order allow,deny Allow from 127.0.0.0/8 192.168.1 ::1 </Directory><Directory "/path/to/your/website"> Options FollowSymlinks AllowOverride None Require local Require ip 192.168.1 </Directory>

The local Require’ment matches requests from the local host over IPv4 or IPv6 (so including 127.0.0.1/8 and ::1). We wrap this, along with Require ip 192.168.1, in a RequireAny authorization container because we want to accept connections that match either condition.

We could also write 192.168.1.0/24 instead of just 192.168.1, but they have the same effect.

If you want to also allow connections from outside the local network, but requiring authentication, the configuration becomes:

<Directory "/path/to/your/website"> Options FollowSymlinks AllowOverride None Require local Require ip 192.168.1 Require valid-user </Directory>

So we’re now granting access from localhost and the local network without authentication, plus from all other locations, but then requiring authentication.

You can make this more secure by restricting outside access to only recognised locations:

<Directory "/path/to/your/website"> Options FollowSymlinks AllowOverride None Require local Require ip 192.168.1 <RequireAll> Require host example.org Require not host badhost.example.org Require valid-user </RequireAll> </Directory>

Now an external connection can only come from *.example.org and only in conjunction with a valid login. To specify more than one domain or ip address in addition to example.org they will need to be wrapped in yet another container:

<Directory "/path/to/your/website"> Options FollowSymlinks AllowOverride None Require local Require ip 192.168.1 <RequireAll> <RequireAny> Require host example.org example.com Require ip 8.8.8.8 </RequireAny> Require not host badhost.example.org Require valid-user </RequireAll> </Directory>

For those getting confused, RequireAll means that all the requirements in that container need to be met, while RequireAny means that only one or more of the contained requirements needs to be met:

Require (local) OR (ip 192.168.1) OR [ [ (host example.org) OR (host example.com) OR (ip 8.8.8.8) ] AND (NOT host badhost.example.com) AND (valid-user) ]

6. Public file in Private directory

Thank you to Alfredo for this question – how to have a password-protected directory (or website) but allow access to a specific file.

If you have a directory ~/private/ then you can make the entire directory secure by adding an.htaccess file ~/private/.htaccess with:

AuthType Basic AuthName "Password Required" AuthUserFile /path/to/.htpasswd Require valid-user

But what if there is a file ~/private/public.html that you want to make globally accessible? This wasn’t possible in earlier versions of Apache, but can be done now quite simply:

AuthType Basic AuthName "Password Required" AuthUserFile /path/to/.htpasswd Require expr %{REQUEST_URI} = "/private/public\.html" Require valid-user

How does it work? Remember that there is an explicit <RequireAny> wrapped around the two Requirestatements, so it reads as: either the request is for the file public.html or require a password.

AMQ7017 queue manager log not available or corrupted

Problem
Your queue manager fails to start with the following error :

AMQ7017 Log not available

Cause
The qm.ini files had been altered and the LogPath entries were removed.

After making the change to qm.ini LogPath, the queue manager failed to start because S0000001.log was not available. The log file was present and the permissions appeared to be correct, but it seemed to be corrupted.

Solution
Edit the qm.ini file and specify the correct LogPath.

If the queue manager fails to start and you suspect a corrupted log file, then do the following:

Here are the steps to follow to recover from the damaged log file(s) in /var/mqm/log/qmgrname/active. The queue manager is referred to as TESTQMGR.

cd /var/mqm/qmgrs
mv TESTQMGR TEST.OLD

NOTE:This will rename the TESTQMGR directory to be TEST.OLD, effectively backing up all your queues and objects.
dltmqm TESTQMGR

Note: This command may not completely run and it may produce error messages. This is OK. At the end of this command there are 3 places to check to make sure everything is cleaned up from TESTQMGR and if it did not then you will need to manually remove
what is left.
There should not be a directory under /var/mqm/qmgrs by the name of TESTQMGR as it should have been renamed to TEST.OLD.
In /var/mqm/log there should not be a directory name TESTQMGR. If there is a directory left there, from /var/mqm/log issue the command rm -rf TESTQMGR to remove the old logs.
In /var/mqm there is a file called mqs.ini. Within file mqs.ini there will be QueueManager: stanzas for each queue manager defined on this box. There should no longer be a stanza referring to TESTQMGR. If there is a stanza for TESTQMGR, remove it; the whole
stanza (should be 4 lines.)
crtmqm TESTQMGR
cd /var/mqm/qmgrs
cp TESTQMGR/amqalchk.fil TEST.OLD

(This is to copy the new check point file over to the backup directory where you are saving our old queue manager files.)
rm -rf TESTQMGR

(This will remove the new qmgr files you just created so you can replace them with the files from the old queue manager that you had saved.)
mv TEST.OLD TESTQMGR

(This is where you just restored the old definitions. At this point you should have a new queue manager created with new logs but you should have our old queues and channels still there.)
strmqm TESTQMGR

(Start up the queue manager. Everything should be back to normal except there will be no attempt to recover any in-flight UOWs because you have nothing in the logs.)

another path ?

Failure recovery and the queue manager

After a full system failure and recovery, the queue manager might fail to start, displaying this message:

AMQ7017 Log not available.

This typically indicates that the log file is missing or damaged, or that the log path to the queue manager is inaccessible.
To remedy the problem, create a dummy queue manager and copy its header log file and transaction log files over to the actual queue manager. This will allow you to restart the queue manager.

 

 

When start being given AMQ7017 MQ queue manager: Log not available, the following example

$ strmqm

AMQ7017: Log not available.

For this problem solving process is more complex, as an example to the queue manager QM2 about the recovery process:

1, the backup queue manager QM2 objects

# su – mqm

$ cd /var/mqm/qmgrs

$ mv QM2 QM2_OLD

2, delete the queue manager QM2

$ dltmqm QM2

MQSeries queue manager deleted.

3, delete directory directory /var/mqm/log under the QM2

$ cd /var/mqm/log

$ rm -rf QM2

4? the file does not ensure /var/mqm/mqs.ini QM2 project, if it is deleted.

$ vi /var/mqm/mqs.ini

AllQueueManagers:

DefaultPrefix=/var/mqm

ClientExitPath:

ExitsDefaultPath=/var/mqm/exits

LogDefaults:

LogPrimaryFiles=3

LogSecondaryFiles=2

LogFilePages=1024

LogType=CIRCULAR

LogBufferPages=17

LogDefaultPath=/var/mqm/log

QueueManager:

Name=QM3

Prefix=/var/mqm

Directory=QM3

5? re-create the queue manager QM2

$ crtmqm QM2

MQSeries queue manager created.

Creating or replacing default objects for QM2.

Default objects statistics : 29 created. 0 replaced. 0 failed.

Completing setup.

Setup completed.

?? /var/mqm/mqs.ini ?????

$ vi /var/mqm/mqs.ini

AllQueueManagers:

DefaultPrefix=/var/mqm

ClientExitPath:

ExitsDefaultPath=/var/mqm/exits

LogDefaults:

LogPrimaryFiles=3

LogSecondaryFiles=2

LogFilePages=1024

LogType=CIRCULAR

LogBufferPages=17

LogDefaultPath=/var/mqm/log

QueueManager:

Name=QM3

Prefix=/var/mqm

Directory=QM3

QueueManager:

Name=QM2

Prefix=/var/mqm

Directory=QM2

6? Copy the new check point before the backup file to a directory in QM2_OLD

$ cd /var/mqm/qmgrs

$ cp QM2/amqalchk.fil QM2_OLD

7 Remove the new queue manager object directory /var/mqm/qmgrs/QM2

$ rm -rf QM2

8?the object manager object data backup to restore the directory to the directory QM2 QM2_OLD

$ mv QM2_OLD QM2

9 start the queue manager QM2, problems get.

$ strmqm QM2

MQSeries queue manager ‘QM2’ started.

How to setup Pagespeed module in Nginx using rpm or yum on CentOS 7

How to setup Pagespeed module in Nginx using rpm or yum on CentOS 7

Adding Pagespeed module in Apache is very easy with package manager:

sudo yum install at # if you do not already have ‘at’ installed
sudo rpm -U mod-pagespeed-*.rpm

… but if we want to add Pagespeed module in Nginx, first thing we think of is compiling its source along with the Pagespeed module. What if Nginx is installed in our server from yum or rpm? The process we need is to repackage RPM and that is what this tutorial will show.
Prepare tools

The following procedures are tested on my Linode server running Centos 7 64-bit Linux distribution.
First we need to install the necessary tools to repackage RPM:

sudo yum install rpm-build gcc-c++ pcre-devel zlib-devel make unzip

It is recommended to not to use root user in building RPM, so we will create a new user:

useradd -m builder

* The -m is to create home directory
Select the latest version of Nginx RPM source here and download (as of this writing the latest is nginx-1.8.1-1.el7.ngx.src.rpm):

rpm -Uvh http://nginx.org/packages/centos/7/SRPMS/nginx-1.8.1-1.el7.ngx.src.rpm

Move the Nginx RPM source to the new user created “builder” home directory:

mv /root/rpmbuild /home/builder/ && chown -R builder. /home/builder/rpmbuild

Pagespeed source

Login as “builder” and go to RPM source directory:

su builder
cd ~/rpmbuild/SOURCES/

Download and extract the latest version of Pagespeed:

wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.11.33.0-beta.zip
unzip release-1.11.33.0-beta.zip
rm release-1.11.33.0-beta.zip

Inside the extracted Pagespeed source directory, download and extract its required PSOL library:

cd ngx_pagespeed-release-1.11.33.0-beta/
wget https://dl.google.com/dl/page-speed/psol/1.11.33.0.tar.gz
tar -zxvf 1.11.33.0.tar.gz
rm 1.11.33.0.tar.gz

Archive both Pagespeed and PSOL as one:

cd ..
tar -zcvf ngx_pagespeed-release-1.11.33.0-beta.tar.gz ngx_pagespeed-release-1.11.33.0-beta/
rm -r ngx_pagespeed-release-1.11.33.0-beta/
cd ~

Enable Pagespeed in Nginx spec

Open and edit “nginx.spec” file:

vi ~/rpmbuild/SPECS/nginx.spec

Search for “Source0: http://nginx.org/download/%{name}-%{version}.tar.gz” and add above it:

%define pagespeed_version 1.11.33.0-beta

Note: ‘1.11.33.0-beta” is the version of Pagespeed.
Scroll down and search “Source10: nginx.suse.logrotate” and add under it:

Source11: ngx_pagespeed-release-%{pagespeed_version}.tar.gz

Again scroll down and search “%setup -q” and add under it:

%{__tar} zxvf %{SOURCE11}
%setup -T -D -a 11

And scroll down and search “–with-cc-opt=”%{optflags} $(pcre-config –cflags)” \” and add under it (Note: there are two of these):

–add-module=%{_builddir}/%{name}-%{version}/ngx_pagespeed-release-%{pagespeed_version} \

And save the nginx.spec file.
Build and install the new Nginx with Pagespeed module

Build the Nginx RPM package:

rpmbuild -ba ~/rpmbuild/SPECS/nginx.spec

After the compilation completed you should see output message at the end something like these:

Wrote: /home/builder/rpmbuild/SRPMS/nginx-1.8.1-1.el7.centos.ngx.src.rpm
Wrote: /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm
Wrote: /home/builder/rpmbuild/RPMS/x86_64/nginx-debug-1.8.1-1.el7.centos.ngx.x86_64.rpm
Wrote: /home/builder/rpmbuild/RPMS/x86_64/nginx-debuginfo-1.8.1-1.el7.centos.ngx.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.lWzVrm
+ umask 022
+ cd /home/builder/rpmbuild/BUILD
+ cd nginx-1.8.1
+ /usr/bin/rm -rf /home/builder/rpmbuild/BUILDROOT/nginx-1.8.1-1.el7.centos.ngx.x86_64
+ exit 0

As we can see the Nginx RPM package bundled with Pagespeed is saved in ~/rpmbuild/RPMS/
Login as root in able to install the compiled Nginx RPM:

su

You can use yum or rpm to install it:

yum update /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm

… or:

rpm -Uvh /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm

If the current nginx is higher version than we have compiled (like in my case I have nginx v1.9.4), execute the following to force install the Nginx RPM we have build:

yum downgrade /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm

… or:

rpm -Uvh –oldpackage /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm

Make sure it auto-start upon reboot:

chkconfig nginx on

To check if Pagespeed is included in Nginx:

nginx -V

If you don’t want to build the RPM in your production server, you may use other machine.

In my case, I just build my RPM in my laptop using CentOS 7 64-bit Vagrant box. Just make sure they have both the same system type (OS and processor).
For PageSpeed Nginx configuration,

GlusterFS servers on RHEL 7 and Centos 7

GlusterFS servers on RHEL 7 and Centos 7

vi /etc/hosts

192.168.1.71 apache1.rmohan.com apache1
192.168.1.72 apache2.rmohan.com apache2
192.168.1.74 apache3.rmohan.com apache3

For this lab, we disabled both firewall and SELinux

vi /etc/selinux/config
egrep “^SELINUX=” /etc/sysconfig/selinux
SELINUX=disabled
systemctl is-enabled firewalld
disabled

systemctl disable firewalld
yum update
yum -y install wget openssh* net-tools ntp
ntpdate -u 0.centos.pool.ntp.org

Before proceeding with the installation, we need to enable both EPEL (Exta Packages for Enterprise Linux) and GlusterFS repositories on both the servers to resolve the external dependencies at the time of installation. If you have enabled only GlusterFS repository and not enabled EPEL repository then it is likely that you will hit the following error message while installing glusterfs-server:
–> Finished Dependency Resolution
Error: Package: glusterfs-server-3.7.11-1.el7.x86_64 (glusterfs-epel)
Requires: liburcu-cds.so.1()(64bit)
Error: Package: glusterfs-server-3.7.11-1.el7.x86_64 (glusterfs-epel)
Requires: liburcu-bp.so.1()(64bit)
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest
EPEL installation
Retrieve EPEL repository : all 3 servers
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm

Gluster installation :
Retrieve GlusterFS repository : all 3 servers
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/RHEL/glusterfs-epel.repo

Download GlusterFS packages : all 3 servers
yum -y install glusterfs-server

Now, start the service and keep it started across reboot :
[root@apache3 ~]# systemctl start glusterd && systemctl enable glusterd
Created symlink from /etc/systemd/system/multi-user.target.wants/glusterd.service to /usr/lib/systemd/system/glusterd.service.
[root@apache3 ~]#
Update “/etc/hosts” :
192.168.1.71 apache1.rmohan.com apache1
192.168.1.72 apache2.rmohan.com apache2
192.168.1.74 apache3.rmohan.com apache3

Check the 2 GlusterFS servers

[root@apache1 ~]# gluster peer probe apache2
peer probe: success.
[root@apache1 ~]# gluster peer probe apache3
peer probe: success.
[root@apache1 ~]#

[root@apache2 ~]# gluster peer probe apache3
peer probe: success. Host apache3 port 24007 already in peer list
[root@apache2 ~]# gluster peer probe apache1
peer probe: success. Host apache1 port 24007 already in peer list
[root@apache2 ~]#
[root@apache3 ~]# gluster peer probe apache1
peer probe: success. Host apache1 port 24007 already in peer list
[root@apache3 ~]# gluster peer probe apache2
peer probe: success. Host apache2 port 24007 already in peer list
[root@apache3 ~]#
Check the Peers :
root@apache1 ~]# gluster peer status
Number of Peers: 2

Hostname: apache2
Uuid: 09db776a-ab96-47a3-ad77-6bc77906566b
State: Peer in Cluster (Connected)

Hostname: apache3
Uuid: 14db2875-378d-481d-968c-552a10f2fd7e
State: Peer in Cluster (Connected)
[root@apache1 ~]#
[root@apache2 ~]# gluster peer status
Number of Peers: 2

Hostname: apache1.rmohan.com
Uuid: 16612fd4-8b94-4006-8ed7-24ac33c564e0
State: Peer in Cluster (Connected)
Other names:
apache1

Hostname: apache3
Uuid: 14db2875-378d-481d-968c-552a10f2fd7e
State: Peer in Cluster (Connected)

[root@apache3 ~]# gluster peer status
Number of Peers: 2

Hostname: apache1.rmohan.com
Uuid: 16612fd4-8b94-4006-8ed7-24ac33c564e0
State: Peer in Cluster (Connected)
Other names:
apache1

Hostname: apache2
Uuid: 09db776a-ab96-47a3-ad77-6bc77906566b
State: Peer in Cluster (Connected)
Create GlusterFS volume
We add 2 new drives from VMware ESXi (in fact, the 3 GlusterFS servers are 3 virtual machines) : do the below commands on all 3 servers
[root@apache1 ~]# for HOST in $(ls /sys/class/scsi_host) ; do echo ‘- – -‘>”/sys/class/scsi_host/$HOST/scan” ; done
[root@apache1 ~]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
??sda1 xfs be8c0a37-1ed9-4743-b4ef-03d59ba3d06d /boot
??sda2 LVM2_member YXOIJV-EPlD-dXwg-ePQX-D7av-jPdr-Grb4rp
??centos-root xfs d2c46dc9-6365-4345-9b60-021aabfd0525 /
??centos-swap swap 74c70324-6875-40e6-9d8f-591d3325c06e [SWAP]
??centos-home xfs bd8e9210-bc95-4af9-be87-a33da31f8dbb /home
sdb
sr0 iso9660 CentOS 7 x86_64 2016-04-01-13-21-01-00
[root@apache1 ~]#

[root@apache1 ~]# parted -s /dev/sdb mklabel gpt && parted -s /dev/sdb mkpart primary xfs 0% 100% && mkfs.xfs -f /dev/sdb
meta-data=/dev/sdb isize=256 agcount=4, agsize=1310720 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=5242880, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@apache1 ~]#

Create gluster and mount on all 3 nodes

[root@apache1 ~]# mkdir /gluster
[root@apache1 ~]# vi /etc/fstab
[root@apache1 ~]# grep -i gluster /etc/fstab
/dev/sdb /gluster xfs defaults 0 0
[root@apache1 ~]#

[root@apache1 ~]# mount -a
[root@apache1 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 38G 1.2G 37G 3% /
devtmpfs devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 497M 186M 312M 38% /boot
/dev/mapper/centos-home xfs 19G 33M 19G 1% /home
tmpfs tmpfs 371M 0 371M 0% /run/user/0
/dev/sdb xfs 20G 33M 20G 1% /gluster
[root@apache1 ~]#
Create a directory within the file system on the servers :
mkdir -p /gluster/briks
Create the GlusterFS volume based on those 3 replicas :

gluster volume create appgluster_vol replica 3 apache1:/gluster/briks apache2:/gluster/briks apache3:/gluster/briks

[root@apache1 ~]# gluster volume create appgluster_vol replica 3 apache1:/gluster/briks apache2:/gluster/briks apache3:/gluster/briks
volume create: appgluster_vol: success: please start the volume to access data
[root@apache1 ~]#

Then, start this volume :

[root@apache1 ~]# gluster volume start appgluster_vol
volume start: appgluster_vol: success
[root@apache1 ~]#

[root@apache1 ~]# gluster volume info

Volume Name: appgluster_vol
Type: Replicate
Volume ID: 856f1052-9d19-49ee-b0c1-1e53d32b86f4
Status: Started
Number of Bricks: 1 x 3 = 3
Transport-type: tcp
Bricks:
Brick1: apache1:/gluster/briks
Brick2: apache2:/gluster/briks
Brick3: apache3:/gluster/briks
Options Reconfigured:
performance.readdir-ahead: on
[root@apache1 ~]#
[root@apache1 ~]# gluster volume status
Status of volume: appgluster_vol
Gluster process TCP Port RDMA Port Online Pid
——————————————————————————
Brick apache1:/gluster/briks 49152 0 Y 3108
Brick apache2:/gluster/briks 49152 0 Y 2923
Brick apache3:/gluster/briks 49152 0 Y 2892
NFS Server on localhost 2049 0 Y 3128
Self-heal Daemon on localhost N/A N/A Y 3136
NFS Server on apache2 2049 0 Y 2943
Self-heal Daemon on apache2 N/A N/A Y 2951
NFS Server on apache3 2049 0 Y 2912
Self-heal Daemon on apache3 N/A N/A Y 2920

Task Status of Volume appgluster_vol
——————————————————————————
There are no active volume tasks

[root@apache1 ~]#
Client side
Both firewall and SELinux are disabled :

192.168.1.21 clusterserver2.rmohan.com clusterserver2
192.168.1.26 clusterserver3.rmohan.com clusterserver3

one the clinet side add the host file
192.168.1.21 clusterserver2.rmohan.com clusterserver2
192.168.1.26 clusterserver3.rmohan.com clusterserver3
192.168.1.71 apache1.rmohan.com apache1
192.168.1.72 apache2.rmohan.com apache2
192.168.1.74 apache3.rmohan.com apache3
[root@clusterserver3 ~]# mount.glusterfs apache1:/appgluster_vol /mnt/
[root@clusterserver3 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 50G 3.6G 47G 8% /
devtmpfs devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs tmpfs 1.9G 16K 1.9G 1% /dev/shm
tmpfs tmpfs 1.9G 17M 1.8G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/loop0 ext4 1.9G 6.1M 1.7G 1% /srv/node/swiftloopback
/dev/mapper/centos-home xfs 46G 33M 46G 1% /home
/dev/sda1 xfs 497M 213M 285M 43% /boot
tmpfs tmpfs 371M 0 371M 0% /run/user/0
apache1:/appgluster_vol fuse.glusterfs 20G 33M 20G 1% /mnt
[root@clusterserver3 ~]#

[root@clusterserver3 ~]# echo “here is a GlusterFS file” > /mnt/file
[root@apache1 ~]# cat /gluster/briks/file
here is a GlusterFS file
[root@apache2 ~]# cat /gluster/briks/file
here is a GlusterFS file
[root@apache2 ~]#

[root@apache3 ~]# cat /gluster/briks/file
here is a GlusterFS file
[root@apache3 ~]#

How to setup Pagespeed module in Nginx using rpm or yum on CentOS 7

How to setup Pagespeed module in Nginx using rpm or yum on CentOS 7

Adding Pagespeed module in Apache is very easy with package manager:

sudo yum install at # if you do not already have ‘at’ installed
sudo rpm -U mod-pagespeed-*.rpm

… but if we want to add Pagespeed module in Nginx, first thing we think of is compiling its source along with the Pagespeed module. What if Nginx is installed in our server from yum or rpm? The process we need is to repackage RPM and that is what this tutorial will show.
Prepare tools

The following procedures are tested on my Linode server running Centos 7 64-bit Linux distribution.
First we need to install the necessary tools to repackage RPM:

sudo yum install rpm-build gcc-c++ pcre-devel zlib-devel make unzip

It is recommended to not to use root user in building RPM, so we will create a new user:

useradd -m builder

* The -m is to create home directory
Select the latest version of Nginx RPM source here and download (as of this writing the latest is nginx-1.8.1-1.el7.ngx.src.rpm):

rpm -Uvh http://nginx.org/packages/centos/7/SRPMS/nginx-1.8.1-1.el7.ngx.src.rpm

Move the Nginx RPM source to the new user created “builder” home directory:

mv /root/rpmbuild /home/builder/ && chown -R builder. /home/builder/rpmbuild

Pagespeed source

Login as “builder” and go to RPM source directory:

su builder
cd ~/rpmbuild/SOURCES/

Download and extract the latest version of Pagespeed:

wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.11.33.0-beta.zip
unzip release-1.11.33.0-beta.zip
rm release-1.11.33.0-beta.zip

Inside the extracted Pagespeed source directory, download and extract its required PSOL library:

cd ngx_pagespeed-release-1.11.33.0-beta/
wget https://dl.google.com/dl/page-speed/psol/1.11.33.0.tar.gz
tar -zxvf 1.11.33.0.tar.gz
rm 1.11.33.0.tar.gz

Archive both Pagespeed and PSOL as one:

cd ..
tar -zcvf ngx_pagespeed-release-1.11.33.0-beta.tar.gz ngx_pagespeed-release-1.11.33.0-beta/
rm -r ngx_pagespeed-release-1.11.33.0-beta/
cd ~

Enable Pagespeed in Nginx spec

Open and edit “nginx.spec” file:

vi ~/rpmbuild/SPECS/nginx.spec

Search for “Source0: http://nginx.org/download/%{name}-%{version}.tar.gz” and add above it:

%define pagespeed_version 1.11.33.0-beta

Note: ‘1.11.33.0-beta” is the version of Pagespeed.
Scroll down and search “Source10: nginx.suse.logrotate” and add under it:

Source11: ngx_pagespeed-release-%{pagespeed_version}.tar.gz

Again scroll down and search “%setup -q” and add under it:

%{__tar} zxvf %{SOURCE11}
%setup -T -D -a 11

And scroll down and search “–with-cc-opt=”%{optflags} $(pcre-config –cflags)” \” and add under it (Note: there are two of these):

–add-module=%{_builddir}/%{name}-%{version}/ngx_pagespeed-release-%{pagespeed_version} \

And save the nginx.spec file.
Build and install the new Nginx with Pagespeed module

Build the Nginx RPM package:

rpmbuild -ba ~/rpmbuild/SPECS/nginx.spec

After the compilation completed you should see output message at the end something like these:

Wrote: /home/builder/rpmbuild/SRPMS/nginx-1.8.1-1.el7.centos.ngx.src.rpm
Wrote: /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm
Wrote: /home/builder/rpmbuild/RPMS/x86_64/nginx-debug-1.8.1-1.el7.centos.ngx.x86_64.rpm
Wrote: /home/builder/rpmbuild/RPMS/x86_64/nginx-debuginfo-1.8.1-1.el7.centos.ngx.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.lWzVrm
+ umask 022
+ cd /home/builder/rpmbuild/BUILD
+ cd nginx-1.8.1
+ /usr/bin/rm -rf /home/builder/rpmbuild/BUILDROOT/nginx-1.8.1-1.el7.centos.ngx.x86_64
+ exit 0

As we can see the Nginx RPM package bundled with Pagespeed is saved in ~/rpmbuild/RPMS/
Login as root in able to install the compiled Nginx RPM:

su

You can use yum or rpm to install it:

yum update /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm

… or:

rpm -Uvh /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm

If the current nginx is higher version than we have compiled (like in my case I have nginx v1.9.4), execute the following to force install the Nginx RPM we have build:

yum downgrade /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm

… or:

rpm -Uvh –oldpackage /home/builder/rpmbuild/RPMS/x86_64/nginx-1.8.1-1.el7.centos.ngx.x86_64.rpm

Make sure it auto-start upon reboot:

chkconfig nginx on

To check if Pagespeed is included in Nginx:

nginx -V

If you don’t want to build the RPM in your production server, you may use other machine.

In my case, I just build my RPM in my laptop using CentOS 7 64-bit Vagrant box. Just make sure they have both the same system type (OS and processor).
For PageSpeed Nginx configuration,

How to setup Memcache on CentOS 7 for Drupal site

How to setup Memcache on CentOS 7 for Drupal site

One way to optimize the authenticated users experience in Drupal site is to use Memcache. It works between the database and Drupal.
Typically the queries are cached in the database but with Memcache the queries sent from Drupal to database are intercepted by Memcache and it serves them from RAM and this avoid hits to the disk or database. We see often that half of the queries are served by Memcache and we are looking significant improvement in authenticated users hits.

Lets take a look how to setup Memcache on CentOS 7 for Drupal site.

Install the Memcache daemon:
yum -y install memcached

Configure Memcache daemon:
vi /etc/sysconfig/memcached

Change the following:

CACHESIZE=”256″
OPTIONS=”-l 127.0.0.1″

CACHESIZE is the RAM you allot to Memcache daemon. Start it:

systemctl start memcached.service
systemctl enable memcached.service

Confirm the Memcache service running status:

memcached-tool 127.0.0.1:11211 stats

Check the remote connectivity:

watch “echo stats | nc 127.0.0.1 11211”

To integrate PHP and Memcache we need to install php-pecl-memcache:

yum -y install php-pecl-memcache

In your Drupal site’s “settings.php” file, append the following codes:

/**
* Memcache configurations
*/
$conf[‘cache_backends’][] = ‘sites/all/modules/memcache/memcache.inc’;
$conf[‘lock_inc’] = ‘sites/all/modules/memcache/memcache-lock.inc’;
$conf[‘memcache_stampede_protection’] = TRUE;
$conf[‘cache_default_class’] = ‘MemCacheDrupal’;
// The ‘cache_form’ bin must be assigned to non-volatile storage.
$conf[‘cache_class_cache_form’] = ‘DrupalDatabaseCache’;
// Don’t bootstrap the database when serving pages from the cache.
$conf[‘page_cache_without_database’] = TRUE;
$conf[‘page_cache_invoke_hooks’] = FALSE;
// If this server has multiple Drupal installation
// assign unique key for memcache namespace purposes
$conf[‘memcache_key_prefix’] = ‘www_yoursite_com’;