Tuesday, August 20, 2013

add swap to ec2 ubuntu

You can add a 1 GB swap to your instance with these commands:
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
sudo swapon /swapfile
To enable it by default after reboot, add this line to /etc/fstab:
/swapfile swap swap defaults 0 0

Thursday, August 8, 2013

Ubuntu Apache: how to hide server version and operation system from users?

1, find the file: conf.d/security
root@cmnew:/etc/apache2# less /etc/apache2/conf.d/security

2, change two parts;
ServerTokens Prod
ServerSignature Off

2, restart apache
root@cmnew:/etc/apache2# /etc/init.d/apache2 restart



Tuesday, August 6, 2013

get linux disk space data

freespace:
[root@ip-10-99-41-92 cloudwatch]# df --local --block-size=1M / | grep / |  tr -s ' ' | cut -d ' ' -f 4
6949







usedpercent
[root@ip-10-99-41-92 cloudwatch]# df --local /  | grep /  | tr -s ' ' | cut -d ' ' -f 5 | grep -o "[0-9]*"
13

[root@ip-10-99-41-92 cloudwatch]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda1             8256952   1057996   7115100  13% /
tmpfs                   304240         0    304240   0% /dev/shm

Wednesday, June 5, 2013

gem install rmagick failed

[root@Redmine config]# yum install ImageMagick-devel

gem install json "ERROR: Failed to build gem native extension."

[root@Redmine config]# yum install ruby-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.einstein.yu.edu
 * extras: mirrors.einstein.yu.edu
 * updates: centos.aol.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ruby-devel.i686 0:1.8.7.352-10.el6_4 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                   Arch                Version                            Repository              Size
===============================================================================================================
Installing:
 ruby-devel                i686                1.8.7.352-10.el6_4                 updates                313 k

Transaction Summary
===============================================================================================================
Install       1 Package(s)

Total download size: 313 k
Installed size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
ruby-devel-1.8.7.352-10.el6_4.i686.rpm                                                  | 313 kB     00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : ruby-devel-1.8.7.352-10.el6_4.i686                                                          1/1
  Verifying  : ruby-devel-1.8.7.352-10.el6_4.i686                                                          1/1

Installed:
  ruby-devel.i686 0:1.8.7.352-10.el6_4

Complete!
[root@Redmine config]# gem install json -v '1.8.0'
Building native extensions.  This could take a while...
Successfully installed json-1.8.0
Installing ri documentation for json-1.8.0
/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
Done installing documentation for json after 1 seconds
1 gem installed
[root@Redmine config]#