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

Friday, November 14, 2014

ERROR 1153 (08S01) at line 75: Got a packet bigger than 'max_allowed_packet' bytes

These error message raise when i run the script like the below:
mysql -u root -p my_database < dump.sql
Then raised:
ERROR 1153 (08S01) at line 75: Got a packet bigger than 'max_allowed_packet' bytes
Googling and found:
vi /etc/my.cnf
add these line under [mysqld]
[mysqld]
# added to avoid err "Got a packet bigger than 'max_allowed_packet' bytes"
#
net_buffer_length=1000000 
max_allowed_packet=1000000000
#
Restart the mysql db:
service mysqld restart
Finally, i import the database with successfully:
mysql -u root -p my_database < dump.sql

Saturday, November 1, 2014

How to restore MySQL Database (MySQL won't start because InnoDB Corruption and Recovery)

Here's the information when i show the error log of MySQL:
130306 22:02:18 mysqld_safe Number of processes running now: 0
130306 22:02:18 mysqld_safe mysqld restarted
130306 22:02:18 [Note] Plugin 'FEDERATED' is disabled.
130306 22:02:18 InnoDB: The InnoDB memory heap is disabled
130306 22:02:18 InnoDB: Mutexes and rw_locks use GCC atomic builtins
130306 22:02:18 InnoDB: Compressed tables use zlib 1.2.3
130306 22:02:18 InnoDB: Using Linux native AIO
130306 22:02:18 InnoDB: Initializing buffer pool, size = 128.0M
130306 22:02:18 InnoDB: Completed initialization of buffer pool
130306 22:02:18 InnoDB: highest supported file format is Barracuda.
Googling and fix the problem:
sudo service mysqld stop
Backup your Database:
mkdir -p /opt/database/backup/
cp -r /var/lib/mysql/* /opt/database/backup/
Adding script for recovery:
vi /etc/my.cnf
then add this line
innodb_force_recovery = 4
Restart your mysql:
service mysqld restart
Dump all tables:
mysqldump -u root -p db_name > dump.sql
Drop all databases which need recovery:
mysql>DROP TABLE table_name;
Stop MySQL:
service mysqld stop
rm -rf /var/lib/mysql/ib*
Comment out recovery script:
vi /etc/my.cnf
#innodb_force_recovery
Restart your mysql:
service mysqld restart
Restore your tables of database:
mysql -u root -p db_name < dump.sql

Saturday, October 25, 2014

Migrate From Apache to Nginx (Engin X) on Ubuntu VPS

I have low end of VPS, there are has minim of spesification hardware, googling and found recommended using Nginx for web server to reduce using of memory.

1. Stop service for Apache

sudo service apache2 stop

2. Installing Nginx PHP5-FPM

sudo apt-get install nginx php5-fpm

3. Configure PHP5-FPM

need to configuring PHP5 handler by Nginx
sudo nano /etc/php5/fpm/php.ini
find (CTRL + W) cgi.fix_pathinfo word and set like the below value:
cgi.fix_pathinfo=0
will modify another PHP configuration
sudo nano /etc/php5/fpm/pool.d/www.conf
find the "listen = ", We will modify this to use a socket for communication with the web server
listen = /var/run/php5-fpm.sock
Restart the PHP-FPM
sudo service php5-fpm restart

5. Set the Vhost of Nginx

sudo nano /etc/nginx/sites-available/myvhost.conf
add this lines to configure your site, for more example script you can find at /etc/nginx/sites-available/default
server {
    listen 80;

    root /var/www;
    index index.php index.html index.htm;
}
unlink the default configuration
sudo unlink /etc/nginx/sites-enabled/default 
Start the Nginx web server
sudo nano service nginx start

6. Remove Apache

to find all dependcies of Apache you filter like this:
dpkg --get-selections | grep apache
will display:
apache2      install
apache2-doc     install
apache2-mpm-prefork    install
apache2-threaded-dev    install
apache2-utils     install
apache2.2-bin     install
apache2.2-common    install
libapache2-mod-auth-mysql   install
libapache2-mod-passenger   install
remove
sudo apt-get remove apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-auth-mysql libapache2-mod-php5
for the clear remove dependencies run this command
sudo apt-get autoremove

Saturday, October 18, 2014

Friday, October 17, 2014

`autodetect': Could not find a JavaScript runtime on Ubuntu

When i starting the rails server, got the message " `autodetect': Could not find a JavaScript runtime "
googling and fix the issue with install a package:
sudo apt-get install nodejs

Thursday, October 16, 2014

Setup VPS for Ruby On Rails on Ubuntu 12.04 LTS

In this case, i'm using RVM for installing ROR

1. Update the Ubuntu

sudo apt-get update
sudo apt-get upgrade
after done, you need to restart the server for clean.
sudo shutdown -r now

2. Install MySQL

sudo apt-get install mysql-server mysql-client libapache2-mod-auth-mysql php5-mysql
Need, install the PHP for using phpmyadmin
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

3. Install dependencies

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion libpq-dev

4. Install Curl

sudo apt-get install curl

5. Install RVM

\curl -L https://get.rvm.io | bash -s stable --ruby
source ~/.rvm/scripts/rvm
After installed RVM, close your terminal and login back to use the "rvm" command: RVM has some dependencies to need install, run this command.
rvm requirements
and if any install some recommended dependencies

6. Install Ruby

rvm list known
Will display like this:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p547]
[ruby-]2.0.0-p481
[ruby-]2.0.0[-p576]
[ruby-]2.1.2
[ruby-]2.1[.3]
[ruby-]2.1-head
ruby-head
rvm install 2.1.2
rvm use 2.1.2 --default
check the version installed Ruby and Gem
ruby -v
gem -v

7. Install Rails

gem install rails

8. Install MySQL gem

Firstly, need install mysql dev
sudo apt-get install libmysqlclient-dev
gem install mysql2

9. Install ImageMagic

sudo apt-get install imagemagick

10. Install Javascript Runtime

sudo apt-get install nodejs

11. Install Phusion Passenger

gem install passenger
View script apache installation run this script:
passenger-install-apache2-module

Saturday, May 10, 2014

Crontab skip holiday date

Here's the step for skip holiday when using crontab:

1. Create the list of holidays on text file

touch /Users/arul/holidays_2014.txt
nano /Users/arul/holidays_2014.txt
2014-01-01
2014-01-14
2014-01-30
2014-03-31
2014-04-18

2. Create shell script on file

touch /Users/arul/runner.sh
nano /Users/arul/runner.sh
TODAY=$(date "+%Y-%m-%d")
if grep -q "$TODAY" /Users/arul/holiday.txt;
then
  /usr/bin/php /Users/arul/test.php
else
  echo "Not found the date"
  exit 0
fi

3. Set the Crontab task

crontab -e
Example the crontab will run every two hours start from Monday through Friday
0 */2 * * mon-fri sh /Users/arul/runner.sh

Tuesday, March 11, 2014

SVN cannot set LC_CTYPE locale on Centos

I got the error when checking "svn status"
svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LC_CTYPE is UTF-8
svn: warning: please check that your locale name is correct
locale -a
export LC_ALL=C

Installing Subversion on Server Centos

Install the package
sudo yum install subversion mod_dav_svn
Create the directory svn
mkdir /var/www/svn
svnadmin create myrepo
chown -R apache.apache myrepo
Edit subversion configuration file
vi /etc/httpd/conf.d/subversion.conf
Add these line
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so

< Location /svn >
   DAV svn
   SVNPath /var/www/svn
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   Require valid-user
< /Location >
Adding new user
sudo htpasswd -cm /etc/svn-auth-users username
New password:
Re-type new password:
Adding password for user new_user
Restart your server
sudo service httpd restart
Finally, access your svn url:
http://ip-address/svn/myrepo

ROR `autodetect': Could not find a JavaScript runtime on Centos 6

To fix this problem, please install some packages:
sudo yum install nodejs npm

Monday, March 10, 2014

Installing mysql gem on Centos 5

Firstly, install mysql dev:
sudo yum install mysql-devel
gem install mysql2

How to cleanup the Ruby on Centos

To remove the current installed ruby, just type
sudo yum remove ruby
ruby -v

Monday, March 3, 2014

How to install Kloxo on Centos 5

If you are using Firewall, ensure port 7778 and 7777 is open, just type:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 7778 -j ACCEPT

1. Disable SELinux

sudo setenforce 0

2. Download Kloxo

mkdir /home/kloxo
cd /home/kloxo
wget http://download.lxcenter.org/download/kloxo/production/kloxo-installer.sh

3. Install Kloxo

sh ./kloxo-installer.sh --type=master

4. Access the Kloxo

After installed the Kloxo, access the url Kloxo:
http://IP_address:7778 or
https://IP_address:7777

For default login use:
username: admin
password: admin

Next you can change the password.

How to installing Ruby on Rails on Centos 5

In this case i'm using RVM for installing ROR, now let's begin
Update your packages:
sudo yum update

1. Install RVM

sudo yum install curl
curl -L get.rvm.io | bash -s stable
After installed RVM, close your terminal and login back to use the "rvm" command:
RVM has some dependencies to need install, run this command.
rvm requirements
and install some recommended dependencies:
rvmsudo yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
rvm list known
Will display like this:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1.1
[ruby-]2.1-head
ruby-head
Install the Ruby
rvm install 2.1.1
rvm use 2.1.1 --default
check the version installed Ruby and Gem
ruby -v
gem -v

2. Install Rails

gem install rails

3. Install mysql gem

First, install the mysql dev:
sudo yum install mysql-devel
gem install mysql2

3. Install Phusion Passenger

gem install passenger
yum install curl-devel httpd-devel 
passenger-install-apache2-module
Put these lines to end of file in httpd.conf, edit the file at /etc/httpd/conf/httpd.conf
LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
   < IfModule mod_passenger.c >
     PassengerRoot /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.37
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby
   < /IfModule >
Adding new virtual host:
vi /etc/httpd/conf.d/your_vhost_name.conf
Add these line, set up your public app directory:
< VirtualHost *:80 >
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public    
      < Directory /somewhere/public >
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      < /Directory >
   < /VirtualHost >
Restart your apache
service httpd restart

Sunday, March 2, 2014

How To Install Linux, Apache, MySQL, PHP on Centos 5

Firsly update packages on Centos
sudo yum update

1. Install Apache

sudo yum install httpd
sudo service httpd start

2. Install MySQL

sudo yum install mysql-server
sudo service mysqld start
You can set a root MySQL password with these command:
sudo /usr/bin/mysql_secure_installation

3. Install PHP

sudo yum install php php-mysql

   PHP Modules

You can see the libraries that are available by typing:
yum search php-
Then terminal will show list of modules:
php53-process.i386 : Modules for PHP script using system process interfaces
php53-pspell.i386 : A module for PHP applications for using pspell interfaces
php53-snmp.i386 : A module for PHP applications that query SNMP-managed devices
php53-soap.i386 : A module for PHP applications that use the SOAP protocol
php53-xml.i386 : A module for PHP applications which use XML
php53-xmlrpc.i386 : A module for PHP applications which use the XML-RPC protocol
To see more detail:
yum info name_of_module
To install the module:
yum install name_of_module
Finally, restart your apache to see the effect for the changed:
sudo service httpd restart

Remote host identification has changed : Host key verification failed

When i try to ssh my server, something is wrong, i got warning messages:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
80:54:8b:9b:39:fb:f1:23:af:0f:4d:af:eb:24:70:44.
Please contact your system administrator.
Add correct host key in /Users/arul/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/arul/.ssh/known_hosts:1
RSA host key for 192.168.10.50 has changed and you have requested strict checking.
Host key verification failed.
That messages show up, because RSA host key had change
May be it haven after installed new Operating System
To fix this, i must delete RSA host key for IP 192.168.10.50
vi ~/.ssh/known_hosts
Done, now i can remote with SSH

How to uninstall webmin on ubuntu

Just simple way:
apt-get remove webmin
Other way to uninstall webmin
/etc/webmin/uninstall.sh .

Installing Webmin on Ubuntu Server

You need add this line on your source list:
sudo vi /etc/apt/sources.list
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib
Now you need to download GPG key
wget http://www.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc
sudo apt-get update
sudo apt-get install webmin

Access webmin

Now you need to go to https://192.168.56.101:10000

Thursday, January 16, 2014

Friday, January 3, 2014

Setup a Ubuntu VPS for Ruby on Rails Application

In this section, my VPS using Ubuntu Server OS

1. Connecting to your server


Login using SSH, as the root user
ssh root@100.100.100.100  #VPS IP Address
password: {your_password}

2. Create a new User

Add a new user to instead the root user
adduser your_username
password {enter_the_password_user}

3. Update the ubuntu

Make sure the Ubuntu is up date
sudo apat-get update

4. Install nano text editor

sudo apat-get install nano

5. Install RVM (Ruby Version Manager)

Firstly, we'll install the Curl
sudo apat-get install curl
Then, install the RVM
\curl -L https://get.rvm.io | bash -s stable
After installing is done, load the RVM. You may first need to exit out out your shell session (terminal) and start up a new one
source ~/.rvm/scripts/rvm

6. Install Ruby with RVM

First, RVM will check the dependencies to install ruby
rvm requirements
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
Now we can list all the availabel versions of Ruby that are available:
rvm list known
Will show list all Ruby version like this:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p484]
[ruby-]2.0.0-p195
[ruby-]2.0.0[-p353]
[ruby-]2.1.0
[ruby-]2.1.0-head
ruby-head
Select newest Ruby version and install with rvm:
rvm install 2.1.0
rvm --default use 2.1.0
Finally, you need to check installed the Ruby on your computer
ruby -v
gem -v

7. Install Rails

sudo gem install rails
Check rails version
raisl -v