Showing posts with label Linux Server. Show all posts
Showing posts with label Linux Server. Show all posts

Thursday, 1 March 2018

Useful docker commands for cleaning up containers, images and volumes

List of useful docker commands for cleaning up containers, images and volumes:

docker stop $(docker ps -aq // Stop all containers
docker rm $(docker ps -aq) // Remove all containers
docker rmi $(docker images -q) // Remove all images
docker volume ls // List all volumes
docker volume ls -q -f dangling=true // List all dangling volumes
docker volume rm `docker volume ls -q -f dangling=true` // remove all dangling volumes

Wednesday, 30 December 2015

To copy the local files to Remote Linux Server (Amazon EC2 Instance)

To copy the local files to Remote Linux Server (Amazon EC2 Instance) :

First, generate and dowmnload the ec2-instance-key-pair.pem file form AWS EC2 to your computer.
To do that follow the instruction here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

Then run the below command by locating the .pem file and name of file to copy and location of directory into and AWS server:

scp -i /c/KeyFolderPath/ec2-instance-key-pair.pem /c/Users/YourFolderPath/instantclient-basic-linux.x64-11.2.0.4.0.zip ec2-username@ec2-198-51-100-1.compute-1.amazonaws.com:/home/destination_folder_path

To find more information here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

Thursday, 14 May 2015

Deleting all large size files from all directories using Bash in Linux

If you are looking to delete all the files in Linux Web Server by specifing File Name and File Size,
then follow steps below:

1. Login into your server Terminal via root login.
2. Create a new bash file called clean_up.sh in one of the location
e.g. /home/my_script/

3. Then Copy and the below code and Paste into that file and Save it.
clear
echo ' -------------------------------------------------------------------------'
echo '  Cleaning all large size error_log files from all directories.'
echo ' -------------------------------------------------------------------------'

filename="error_log"
filesize="50000"

echo " Deleting all files (including subfolders) having Filename:'$filename', Size: greater than $filesize Kb only."
echo ' '
echo ' Listing all the files which are greater than 50MB'
find / -type f -size +50M -exec du -h {} \; | sort -n

echo ' Deleting all the "error_log" files which are greater than 50MB'
#find -name "error_log" -size +30000k #-delete
find -name "$filename" -size +"$filesize"k -delete

echo ' Listing again all the files which are greater than 50MB'
find / -type f -size +50M -exec du -h {} \; | sort -n

4. Then go to your specified directory where you want to Search and Delete the files by specifying the File Name and File Size as below;

5. Then run the below command
sh  /home/my_script/clean_up.sh

Friday, 2 January 2015

Options to run multi-versions PHP within on WHM Cpanel

If you are looking for solution to run multi-version of PHP by domain in WHM Cpanel, I have found people using tools called ntPHPSelector.

WHM Cpanel doesn't have such native feature, however, I have found their team were keen to build an extension for it in future. Hopefully, it will be available soon, fingures cross!! find more here..

Currently, there are few WHM providers which does support Multiple PHP Versions as below:
  • Virtualmin since 3.99 can do that
  • PLesk since 11.5 can do that
  • Direct Admin can do that
  • cPanel cannot do that unless you move to CloudLinux paying an additional license


Now, let jump to the wayout for now;

1. First check whether the suPHP Handler is enabled or not by going to WHM > Configure PHP and suEXEC
PHP 5 Handler => suphp

If not active, run the below command
/usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1


2. Run the following commond once you logged in as root into the server (Via SSH or you can use puTTY), which may take few mintues so wait until instillation completes.
cd /usr/local/src
wget -N http://nixtree.com/download/free/ntphpselector_manage.sh
sh ntphpselector_manage.sh install

3. Go to the domain Cpanel and find the ntPHPSelector under the Software and Services to run the different version of PHP.


If you find anything, please keep on post...

Tuesday, 7 October 2014

Issue on installing WHMCS on server due to IonCube Loaders

If you are having problem on installing the WHMCS on your server having same issue as below;

....install/install.php requires the ionCube PHP Loader 
ioncube_loader_lin_5.4.so to be installed by the website operator. If 
you are the website operator please use the ionCube Loader Wizard to 
assist with installation.

Please follow the below steps;

Installing IonCube Loaders with cPanel & WHM
It can be done one of two ways:

1. Using EasyApache via WHM >> EasyApache, IonCube Loaders can be selected under the Exhaustive Options List prior to compiling.

2. As the user `root` via SSH, you can run the below command to install IonCube Loaders without having to recompile Apache:
/scripts/phpextensionmgr install IonCubeLoader 


Thursday, 21 August 2014

Apache does not start when using Virtual Host on BITNAMI WAMP Stack

Updated on 19.12.2014

If you are using the Bitnami WAMP Stack, be careful while you setup the virtual host for your site (on local machine, Amazon EC2 or other Cloud).

First Steps:
  1. Open the /wampstack/apache2/conf/httpd.conf
  2. Search for [ conf/extra/httpd-vhosts.conf ] and uncomment that line (normally it should be line > 492 under the # Virtual hosts )
 Also, you may need to change port to 8080 or to 80 depends on your system requirement.

-------------------------------------------------------------------------------------------------------

If you are using the Bitnami WAMP Stack, be careful while you setup the virtual host for your site (on local machine, Amazon EC2 or other Cloud).

Firstly, wamp_intall_folder/apache2/conf/extra/http-vhosts.conf doesn't work anymore if you using Bitnami WAMP Stack. Instead, it uses wamp_intall_folder/apache2/conf/bitnami/bitnami-apps-vhosts.conf

1. Then, add the following content to setup of the Virtual host.
< VirtualHost *:80 >
 ServerName dev.testapp
 DocumentRoot "wamp_intall_folder/apache2/htdocs/testapp"
 
 Include "wamp_intall_folder/apps/testapp/conf/httpd-app.conf"
< /VirtualHost >


And, rest of configruation is exactly same for both.

OR Alternatevly,
you can configure same thing in a slightly different way, they rather Include the vhost.conf file and setup separately for each application.

I. First, create new folder on apps/ folder, in this case I am creating testapp/:
  wamp_intall_folder/apps/testapp

II. Then, create conf/ inside the above testapp/ folder.
  wamp_intall_folder/apps/testapp/conf


III. Then, create httpd-vhosts.conf file inside the above /conf folder;
  wamp_intall_folder/apps/testapp/conf/httpd-vhosts.conf

Then, add the below content on httpd-vhosts.conf file

< VirtualHost *:80 >
 ServerName dev.testapp
 DocumentRoot "wamp_intall_folder/apache2/htdocs/testapp"
 
 Include "wamp_intall_folder/apps/testapp/conf/httpd-app.conf"
< /VirtualHost >

IV. Further, create httpd-app.conf file inside the above /conf folder with the below content.
  wamp_intall_folder/apps/testapp/conf

 Then, add the below content on httpd-app.conf file

 < Directory "wamp_intall_folder/apache2/htdocs/testapp" >
  Options Indexes MultiViews
  AllowOverride All
  
  < IfVersion < 2.3 >
   Order allow,deny
   Allow from all
  < /IfVersion >
  
  < IfVersion >= 2.3 >
   Require all granted
  < /IfVersion >
  
 < /Directory >
 
On above steps 3 & 4, the wamp_intall_folder/apache2/htdocs/testapp is the folder where your actual project or app folder where all the php files are placed.

V. Now, lets go to the wamp_intall_folder/apache2/conf/bitnami/bitnami-apps-vhosts.conf file and add the below line
# Bitnami applications installed in a Virtual Host
Include "wamp_intall_folder/apps/testapp/conf/httpd-vhosts.conf"

2. One more step,  open the hosts file from the C:\Windows\System32\drivers\etc\hosts, in case of lixux or EC2 Server, it can be different location, please check before you add the below line.
Add the below line and save the file.
 127.0.0.1       dev.testapp

3. Finally, you have to restart the Apache server, if you browse by
http://dev.testapp/

Enjoy!

If anything, please let me know.

Friday, 8 August 2014

How to enable the Remote MySQL connection on the Web Server (Cpanel)

If you are having problem to connect MySQL from Remote System, please check the following things on the Webserver Control Panel or Cpanel before connecting it.

1. Is there any local firewall running on the server, do you have the connecting servers listed in 
WHM -> SQL Services »Additional MySQL Access Hosts _and_ cPanel -> Remote MySQL?

2. If so, you've to also add a rule to CSF to allow MySQL connections. For that, go to 
WHM -> Plugins -> Configserver CSF Firewall -> Firewall Allow IPs.   

And, after that, you'll see that there is a line:
 tcp|in|d=3306|s=88.xxx.xxx.xx (your connecting computer's IP address)

which only allows incoming MySQL connections from your IP Address.