Category Archives: Linux

Install berkeley db from source code

Follow the below steps to install BerkeleyDB.

Downloading Berkeley DB

wget http://download.oracle.com/berkeley-db/db-5.2.28.tar.gz

Extracting files from the downloaded package:

tar zxvf db-5.2.28.tar.gz

cd db-5.2.28/build_unix

Create installation path

mkdir /etc/berkeleydb

Configuring Berkeley DB

../dist/configure --prefix=/etc/berkeleydb

Compile and install the code

make

make install

NginX PHP-FPM CentOS

This article assume that Nginx is installed in your server and its up and running.Lest install NginX

Update the repository

yum update -y

Install the EPEL repository

yum install epel-release -y

Install Dependencies

yum install -y git gcc gcc-c++ libxml2-devel pkgconfig openssl-devel bzip2-devel curl-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel autoconf bison re2c libicu-devel libxslt-devel libxslt

Get The PHP Source

curl -O -L https://github.com/php/php-src/archive/php-7.1.18.tar.gz
tar -xvf php-7.1.18.tar.gz
cd php-src-php-7.1.18/
Compile Source Code 

./buildconf --force

./configure --prefix=/etc/php --with-config-file-path=/etc/php/etc --with-config-file-scan-dir=/etc/php/etc/conf.d --enable-bcmath --with-bz2 --with-curl --enable-filter --enable-fpm --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-intl --enable-mbstring --with-mcrypt --enable-mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --disable-phpdbg --disable-phpdbg-webhelper --enable-opcache --with-openssl --enable-simplexml --with-sqlite3 --enable-xmlreader --enable-xmlwriter --enable-zip --with-zlib --enable-soap --with-xsl

make
make install

Add PHP to $PATH

echo 'pathmunge /etc/php/bin' > /etc/profile.d/php.sh

Copy php.ini

cp php.ini-development /etc/php/lib/php.ini

Add module opcache

vi /etc/php/etc/conf.d/modules.ini

and add 'zend_extension=opcache.so'

PHP FPM SET UP

mkdir /etc/php/etc/conf.d

cp sapi/fpm/www.conf /etc/php/etc/php-fpm.d/www.conf

cp sapi/fpm/php-fpm.conf /etc/php/etc/php-fpm.conf

Update PHP FPM configuration

vi /etc/php/etc/php-fpm.d/www.conf

user = nobody
group = nobody

listen.owner = nginx
listen.group = nginx

listen = /var/run/php-fpm/php-fpm.sock

Create a symlink for php-fpm to the standard path

ln -s /etc/php/sbin/php-fpm /usr/sbin/php-fpm

Create a systemctl file add the following:

vi /usr/lib/systemd/system/php-fpm.service

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/run/php-fpm/php-fpm.pid
ExecStart=/usr/sbin/php-fpm --nodaemonize --fpm-config /etc/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

Create a run directory for php-fpm:

mkdir /run/php-fpm

Start php-fpm and Restart NginX

systemctl start php-fpm

service nginx restart

Create index.php

mv /etc/nginx/html/index.html /etc/nginx/html/index.php

Update nginx.con file with the followinf content

root /etc/nginx/html;
index index.php index.html index.htm;

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Load URL

http://127.0.0.1/

 

Install NginX CentOS From Source

Update the repository

yum update -y

Install the EPEL repository

yum install epel-release -y

Install dependencies from yum

yum install -y zlib zlib-devel pcre prce-devel openssl openssl-devel

Get the Nginx packages to install

cd /usr/src
wget https://nginx.org/download/nginx-1.14.0.tar.gz
tar xvf nginx-1.14.0.tar.gz
cd nginx-1.14.0

Create user nginx

useradd -d /etc/nginx/ -s /sbin/nologin nginx

Configure

./configure --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module --without-http_scgi_module --without-http_uwsgi_module --with-http_realip_module

Compile and Install

make
make install

Verify NginX is installed

nginx -v

Add systemd service file

vi /etc/systemd/system/nginx.service

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Enable and start service

systemctl enable nginx
systemctl start nginx

Check nginx is processing your request

On commandline

curl localhost

Browser

Make sure port 80 is enabled.

firewall-cmd --zone=public --add-port=80/tcp --permanent && firewall-cmd --reload

Findout the ip

ip addr

Load the site using the URL and it should display ‘Welcome to nginx!’ message.

http://127.0.0.1/

 

Install OpenSSL CentOS Linux

OpenSSL – Supports the HTTPS protocol. Required by the NGINX SSL module and others.

Run the following commands to install openssl

cd /tmp/
wget http://www.openssl.org/source/openssl-1.0.2o.tar.gz
tar -zxf openssl-1.0.2o.tar.gz
cd openssl-1.0.2o
./Configure linux-x86_64 --prefix=/usr 
make
make install

You can verify the installation by issuing the following command.

openssl -version

Install NginX CentOS 7

Add Nginx Repository

To add the CentOS 7 EPEL repository, open terminal and use the following command:

sudo yum install epel-release

Install Nginx

Now that the Nginx repository is installed on your server, install Nginx using the following yum command:

sudo yum install nginx -y

Start Nginx

Nginx does not start on its own. To get Nginx running, type:

sudo systemctl start nginx

If you are running a firewall, run the following commands to allow HTTP and HTTPS traffic:

sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --reload

You can do a spot check right away to verify that everything went as planned by visiting your server’s public IP address in your web browser (see the note under the next heading to find out what your public IP address is if you do not have this information already):

http://server_domain_name_or_IP/

Before continuing, you will probably want to enable Nginx to start when your system boots. To do so, enter the following command:

sudo systemctl enable nginx

Install Redis CentOS 7 Linux

Run the following commands to install redis

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
make test
make install

Create a directory where to store your Redis config files and your data:

mkdir /etc/redis
mkdir /var/redis

Copy the init script that you’ll find in the Redis distribution under the utils directory into /etc/init.d. We suggest calling it with the name of the port where you are running this instance of Redis. For example:

cp utils/redis_init_script /etc/init.d/redis_6379

Copy the template configuration file you’ll find in the root directory of the Redis distribution into /etc/redis/ using the port number as name, for instance:

cp redis.conf /etc/redis/6379.conf

Create a directory inside /var/redis that will work as data and working directory for this Redis instance

mkdir /var/redis/6379

Edit the configuration file, making sure to perform the following changes:

vi /etc/redis/6379.conf

Set daemonize to yes (by default it is set to no).
Set the pidfile to /var/run/redis_6379.pid (modify the port if needed).
Change the port accordingly. In our example it is not needed as the default port is already 6379.
Set your preferred loglevel.
Set the logfile to /var/log/redis_6379.log
Set the dir to /var/redis/6379 (very important step!)

Finally add the new Redis init script to all the default runlevels using the following command

chkconfig --add redis_6379

Start Redis instance.

/etc/init.d/redis_6379 start

Check if Redis is working

redis-cli ping

Install Magento 2 Commandline Linux CentOS

Follow the below steps to install Magento 2 with sample-data.

Make sure that httpd / Nginx,PHP,MySQL and Composer are installed in the server by issuing the following commands

httpd -v / nginx -v
php -v
composer -v
mysql

Change the directory to documet root

cd /var/www/html/

Download Magento and issue the following commands

sudo git clone https://github.com/magento/magento2.git

cd magento2

sudo git checkout tags/2.2.1 -b 2.2.1

chown -R httpd:www /var/www/html/magento2/

sudo chmod -R 775 /var/www/html/magento2/

chmod 777 var/ generated/ app/etc/ pub/

composer install

composer update

composer config repositories.0 composer https://repo.magento.com

php bin/magento setup:install --base-url=http://127.0.0.1/magento2/ --backend-frontname=admin \
--db-host=127.0.0.1 --db-name=mage2 --db-user=root --db-password=Root@123 \
--admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com \
--admin-user=admin --admin-password=admin17 --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1

php bin/magento sampledata:deploy

php bin/magento setup:upgrade

php bin/magento setup:static-content:deploy

Now check the site http://127.0.0.1/magento2/ .