Sunday, August 30, 2020

thumbnail

Install PHP 7.4 & OCI8 on Centos 7

Install PHP 7.4 & OCI8 on Centos 7

If you are planning to use PHP to connect to an Oracle database, then the best possible option is to use OCI8, a PHP extension for Oracle.

I will show you how to install PHP 7.4 with OCI8 support on your Centos 7 (This may be applicable on other Linux distributions also).

Watch this video to understand how to enable OCI8 support for PHP:

Add EPEL & REMI Repositories

Run the commands below to add required repositories:

 yum -y install epel-release
 yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm 

Set Config Manager for PHP 7.4

Enable REMI for PHP 7.4 using the commands below:

 yum -y install yum-utils
 yum-config-manager --enable remi-php74 

Install PHP 7.4

Install PHP 7.4 and required on CentOS 7.

 yum install php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json 

Install OCI8

 yum install php-oci8 

Then edit the php.ini file as follows:

 vi /etc/php.ini 

Then add this line to the file:

 extension=oci8.so 

Save the file and quit.

Then to check if PHP 7.4 is installed correct, issue this command:

 php -v 

Here you'll see some errors. We have to install Oracle Instant Client packages to solve these errors.

Install Oracle Instant Client

To download latest Oracle Instant Client packages Click here

As of now latest version is 19.8.

You need to download for your the following 2 files for Centos 7:

oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm

oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm

Make sure they are in your present working directory, then install with the following commands:

 yum install oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpm
 yum install oracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm 

Now create links to Oracle Instant Client

 sh -c "echo /usr/lib/oracle/19.8/client64/lib/ > /etc/ld.so.conf.d/oracle-instantclient.conf"
ldconfig 

Then issue the following command to verify PHP is installed correctly:

 php -v 

Now the previous errors should have gone!

Restart Apache:

 systemctl restart httpd 

That's all!

Thursday, December 13, 2018

thumbnail

Install and Configure Docker with Portainer on Ubuntu


About


Docker is an open-source application build and deployment tool. It is based on the idea of that you can package your code with dependencies into a deployable unit called a container.

Portainer is an open-source management UI for Docker, including Docker Swarm environment. Portainer makes it easier for you to manage your Docker containers, it allows you to manage containers, images, networks, and volumes from the web-based Portainer dashboard.

Here I will show you how to install and configure docker with portainer on an ubuntu machine.


Update the apt package index:
 apt-get update 

Install packages to allow apt to use a repository over HTTPS:
 sudo apt-get install \
 apt-transport-https \
 ca-certificates \
 curl \
 software-properties-common 

Add Docker’s official GPG key:
 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 

Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.
 apt-key fingerprint 0EBFCD88 
 pub   4096R/0EBFCD88 2017-02-22
 Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
 uid                  Docker Release (CE deb) 
 sub   4096R/F273FCD8 2017-02-22 

Use the following command to set up the stable repository.
 add-apt-repository \
 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
 $(lsb_release -cs) \
 stable" 

Update the apt package index.
 apt-get update 

Install the latest version of Docker CE, or go to the next step to install a specific version:
 apt-get install docker-ce 

Verify that Docker CE is installed correctly by running the hello-world image.
 docker run hello-world 
 Unable to find image 'hello-world:latest' locally
 latest: Pulling from library/hello-world
 d1725b59e92d: Pull complete 
 Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
 Status: Downloaded newer image for hello-world:latest 

 Hello from Docker!
 This message shows that your installation appears to be working correctly. 

After installing Docker, run the following command to pull the latest Portainer image:
 docker pull portainer/portainer 
 Using default tag: latest
 latest: Pulling from portainer/portainer
 d1e017099d17: Pull complete 
 8f8668d9390b: Pull complete 
 Digest: sha256:339b6486297050179418c886272f3262794b54513008a7f8e747c5e8f330338d
 Status: Downloaded newer image for portainer/portainer:latest 

We can see the downloaded the image using docker images command,
 docker images 
REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
portainer/portainer   latest              a01958db7424        28 hours ago        72.2MB
hello-world           latest              4ab4c602aa5e        3 months ago        1.84kB

We have now Portainer in our local Ubuntu system. Let us start the container using command:
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer

output will be something like below:
a85edbd40ffaa0392542a27ddbfd6ec8c52270fe69a41e6b4c7d1bf98c4164f2 

Great, successfully launched the Portainer container. Now let access Portainer webUI using http://localhost:9000/ or http://IP_Address:9000/ URL.
You will be presented with a screen that asks to set a password for the admin user.

Create new password and hit 'Create user' button to create the admin user password.
Next screen ask us which docker environment we want to manage with docker. As we are using portainer to manage local docker environment select Local option and click Connect button.

Once connected, you will be presented with a dashboard like below.

Click on local and it will bring you to local docker environment.

Click on the App Templates button on the left. This will show some ready-made available templates such as Nginx, Httpd, MySQl, redis, Jenkins and few more.

Tuesday, December 11, 2018

thumbnail

Install WordPress with EasyEngine 3.8 on Ubuntu 18.04 and Enable PHP 7.2


About


Easy Engine = Easy wordpress on Nginx
The above equation tells everything about easy engine. However I will make it a little bit clearer, easy engine is a shell script in Linux that makes it easy for installation and management of WordPress sites on Nginx (pronounced as engine-x). Nginx is a fast, lightweight, and open source web server that doubles up as a reverse proxy and load balancer. It is gaining popularity amongst most production servers.
Here I will show you how to host a wordpress site with easy engine and how to enable PHP v7.2 on easy engine. I am running all command as root user.

Step 1:


Install easyengine on your machine:
 apt update wget -qO ee rt.cx/ee && bash ee 

After the installation, we need to apply the bash auto-completion for EasyEngine ee command.
Run the following command.
 source /etc/bash_completion.d/ee_auto.rc 

Now easy engine is installed and we can create and manage our sites using the "ee" command.

Step 2:


Creating a simple html site with easy engine:
 ee site create  

Installing WordPress with Basic Configuration:
 ee site create  --wp 

When it is completed you will get details of your wordpress site including WordPress admin user and password.
You will get the details like document root, log file locations and database details by running the following command:
 ee site info  

EasyEngine provides automatic WordPress cache settings for the following software:
--wpfc: Nginx Cache

--w3tc: W3 Total Cache

--wpsc: WP Super Cache

--wpredis: WP Redis Cache

Install WordPress with Cache Settings:
ee site create  --wpfc

Install WordPress with PHP 7.0:
ee site create  --wpfc --php7

To install Wordpress with PHP 7.0, WordPress Cache, and SSL:
ee site create  --wpfc --php7 --letsencrypt

Step 3:


If you want to setup SSL on an existing site:
ee site update  --letsencrypt

If you get any error in this step refer step 5.
In case you want to change the wordpress admin password use the below command:
ee site update --password

Step 4:


Additional SSL Configuration
cd /var/www/your_domain/nginx
vi ssl.conf

Add the 'ssl_ciphers' configuration:
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:AES256+EDH';

Restart the EasyEngine stack:
ee stack restart

Step 5:


If step 3 works well with your setup please avoid this step.
Adding SSL normally:
git clone https ://github.com/letsencrypt/letsencrypt && cd letsencrypt
./letsencrypt-auto -d 

Enabling PHP 7.2 on EasyEngine:


Add php7.2 repository:
add-apt-repository ppa:ondrej/php
apt update

Install php7.2-fpm and other necessary packages:
apt install php7.2-common php7.2-cli php7.2-zip php7.2-opcache php7.2-mysql php7.2-mbstring php7.2-json php7.2-intl php7.2-gd php7.2-fpm php7.2-curl php7.2-bz2 php7.2-bcmath php7.2-imap php7.2-recode php7.2-soap php7.2-xml php7.2-imagick php7.2-memcache php7.2-memcached php7.2-igbinary php7.2-msgpack php7.2-redis

Copy the php7.2-fpm pool configuration from php7.0-fpm:
cp -f /etc/php/7.0/fpm/pool.d/www.conf /etc/php/7.2/fpm/pool.d/www.conf

Edit the listening port of php7.2-fpm
vi /etc/php/7.2/fpm/pool.d/www.conf

Change the line
 listen = 127.0.0.1:9070 
to
 listen = 127.0.0.1:9090 

Restart php-fpm service:
service php7.2-fpm restart

Then to use php7.2-fpm, replace globally php7.0-fpm with php7.2-fpm
vi /etc/nginx/conf.d/upstream.conf

Replace the line
 server 127.0.0.1:9070; 
by
 server 127.0.0.1:9090; 

Then reload nginx:
service nginx restart

Then make a php72 configuration file in nginx folder:
cp /etc/nginx/common/php7.conf /etc/nginx/common/php72.conf

Replace the line
 fastcgi_pass php7; 
by
 fastcgi_pass php72; 

Replace the line
 include common/php7.conf; 
by
 include common/php72.conf; 
in the site configuration file.
Reload nginx:
service nginx restart

Sunday, October 28, 2018

thumbnail

S3cmd : Command Line S3 Client and Backup for Linux


Amazon S3 is a reasonably priced data storage service. Ideal for off-site file backups, file archiving, web hosting and other data storage needs. It is generally more reliable than your regular web hosting for storing your files and images.


S3cmd is a free command line tool and client for uploading, retrieving and managing data in Amazon S3 and other cloud storage service providers that use the S3 protocol, such as Google Cloud Storage or DreamHost DreamObjects. It is best suited for power users who are familiar with command line programs. It is also ideal for batch scripts and automated backup to S3, triggered from cron, etc. This article will help you to install s3cmd on CentOS/RHEL.


I will show simple steps to enable s3cmd on your host system through which you can upload your backup files to amazon s3 bucket.


Install s3cmd

yum install s3cmd

Configure s3cmd Environment

In order to configure s3cmd we would require Access Key and Secret Key of your S3 Amazon account. Get these security keys from aws securityCredentials page. If will prompt to login to your amazon account.

After getting key files, use below commands to configure s3cmd:

export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
s3cmd --configure

Uses of s3cmd Command Line

1. List All S3 Bucket

s3cmd ls

2. Creating New Bucket

s3cmd mb s3://bucketname

3. Uploading file in Bucket

s3cmd put /path/to/file s3://bucketname/

4. Uploading directory in Bucket

s3cmd put -r /path/to/directory s3://bucketname/

5. Syncing file/folder in Bucket

s3cmd sync -r File_or_folder s3://Buckt_name/

6. Listing data of S3 Bucket

s3cmd ls s3://bucketname/

7. Download file from S3 Bucket

s3cmd get s3://bucketname/path/to/file

8. Remove Data of S3 Bucket

s3cmd del s3://bucketname/path/to/file_or_folder

9. Remove S3 Bucket

(Before removing bucket make sure it is empty)
s3cmd rb s3://bucketname
thumbnail

Install LAMP on Ubuntu 16.04


I am starting with the idea that you are already on your Ubuntu machine/VPS.

1. Acquire root privilages:
 sudo -i
2. Update system:
 apt update && apt upgrade 
3. Install Apache 2
 apt install apache2 
4. The KeepAlive setting allows Apache to utilize server-side memory, reducing latency for users on the hosted site. KeepAlive will make a website faster if the host has enough memory to support it. This is done by allowing Apache to reuse connections, instead of opening a new connection for every request.
 vi /etc/apache2/apache2.conf 
Make the changes as below (or you can edit it as per your needs):
 KeepAlive On
 MaxKeepAliveRequests 50
 KeepAliveTimeout 5
5.The default multi-processing module (MPM) is the prefork module. Mpm_prefork is the module that is compatible with most systems. Since the LAMP stack requires PHP, it may be best to stick with the default.
 vi /etc/apache2/mods-available/mpm_prefork.conf 
 <ifmodule mpm_prefork_module="">
 StartServers            4
 MinSpareServers         3
 MaxSpareServers         40
 MaxRequestWorkers       200
 MaxConnectionsPerChild  10000
 </ifmodule>
6. Disable the event module and enable prefork:
 a2dismod mpm_event 
 a2enmod mpm_prefork 
7. Restart Apache
 systemctl restart apache2 
8. Create a copy of the default Apache configuration file for the site:
 cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf 
9. Edit the new example.com.conf configuration file by uncommenting ServerName and replacing example.com with your site’s IP or Fully Qualified Domain Name (FQDN). Enter the document root path and log directories.
 vi /etc/apache2/sites-available/example.com.conf 
 <virtualhost>

 ServerName example.com
 ServerAlias www.example.com
 ServerAdmin webmaster@localhost
 DocumentRoot /var/www/html/example.com/public_html

 <directory /var/www/html/example.com/public_html>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Require all granted
 </directory>

 ErrorLog /var/www/html/example.com/logs/error.log
 CustomLog /var/www/html/example.com/logs/access.log combined

 </virtualhost>
10. Create the directories:
 mkdir -p /var/www/html/example.com/{public_html,logs} 
11. Link virtual host file from the sites-available directory to the sites-enabled directory:
 a2ensite example.com.conf 
12. Disable the default virtual host to minimize security risks:
 a2dissite 000-default.conf 
13. Reload Apache:
 systemctl reload apache2 
14. Install the mysql-server
 apt install mysql-server 
14. Log into MySQL:
 mysql -u root –p 
15. Create a database and a user with permissions for it.
 CREATE DATABASE dbname;
 GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password'; 
16. Exit MySQL
 quit 
17. Install PHP, the PHP Extension and Application Repository, Apache support, and MySQL support:
 apt install php7.0 libapache2-mod-php7.0 php7.0-mysql 
Optionally, install additional cURL, JSON, and CGI support:
 apt install php7.0-curl php7.0-json php7.0-cgi 
18. Edit the php configuration file
 vi /etc/php/7.0/apache2/php.ini 
 max_input_time = 30
 error_reporting = E_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR                 
 error_log = /var/log/php/error.log
19. Create the log directory for PHP and give ownership to the Apache system user:
 mkdir /var/log/php
 chown www-data /var/log/php 
20. Restart Apache:
 systemctl restart apache2 
Now Let's check if the installed LAMP server working properly
21. Paste the following code into a new file in the documentroot,(/var/www/html/example.com/public_html)
 vi /var/www/html/example.com/public_html/info.php 
 <?php
 phpinfo();
 ?>
22. Restart apache2
 systemctl restart apache2 
23. Edit the /etc/hosts file on local machine and enter the server's IP address and domain name.
 vi /etc/hosts 
 ip address       example.com 
Navigate to example.com/info.php from local machine.

Search This Blog

Powered by Blogger.