Find us on facebook

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

Jun 29, 2015

Setting up a cron in AWS Linux/Ubuntu


  1. Login to server using SSH (Windows users PuTTY)
  2. sudo crontab -l
  3. sudo crontab -e
  4. Linux : Open vim editor and allow to enter commands
  5. Ubuntu : For the first time it asks which editor to use (nano is easy)
  6. Enter following commands and save the file

MAILTO=yyy@gmail.com
*/5 * * * * /usr/bin/wget http://yyy.com/mail201506/index.php >/dev/null

>/dev/null
Send all the normal output to a place called "/dev/null" which is basically like a black hole. It accepts anything you dump there, but you will never see it again.

May 31, 2015

Install Node.js on Ubuntu AND Linux

Ubuntu

sudo apt-get update

Then use apt-get to install Node.js build dependencies:
sudo apt-get install -y build-essential openssl libssl-dev pkg-config

Move to /usr/src directory - the usual place to hold software sources.
cd /usr/src

pick the latest compressed source archive from Node.js website at http://nodejs.org/download/.
sudo wget http://nodejs.org/dist/v0.12.4/node-v0.12.4.tar.gz

Uncompress the source files and move into that directory.
sudo tar zxf node-v0.12.4.tar.gz
cd node-v0.12.4

Prepare compiler commands, by executing the configure script:
sudo ./configure

It will read the properties of the system to prepare compiler flags. Ie. it could be a system architecture (32/64bit, CPU specific flags etc). With it, Now ready to actually compile the source now. To do that, just type:
sudo make

To make this available system-wide:
sudo make install

Linux

Update software repository to the latest versions:
sudo yum -y update

Install "Development Tools". It's a group of tools for compiling software from sources.
sudo yum -y groupinstall "Development Tools"

Move to /usr/src directory - the usual place to hold software sources.
cd /usr/src

pick the latest compressed source archive from Node.js website at http://nodejs.org/download/.
sudo wget http://nodejs.org/dist/v0.12.4/node-v0.12.4.tar.gz

Uncompress the source files and move into that directory.
sudo tar zxf node-v0.12.4.tar.gz
cd node-v0.12.4

Prepare compiler commands, by executing the configure script:
sudo ./configure

It will read the properties of the system to prepare compiler flags. Ie. it could be a system architecture (32/64bit, CPU specific flags etc). With it, Now ready to actually compile the source now. To do that, just type:
sudo make

To make this available system-wide:
sudo make install

Connecting to EC2 Instance with Filezilla

Go to Edit->Settings

Go to SFTP and Add key file
Click OK. An go to File ->Site manager

Give Host. Select protocol as SFTP. If Ubuntu then user ubuntu. If linux then user ec2-user.

Then click connect.

Done! :)

Install and start the LAMP web server on Amazon Linux And Ubuntu

Linux

Install updates
[ec2-user ~]$ sudo yum update -y

you can install the Apache web server, MySQL, and PHP software packages. Use the yum install command to install multiple software packages and all related dependencies at the same time.
[ec2-user ~]$ sudo yum install -y httpd24 php56 mysql55-server php56-mysqlnd

Start Apache
[ec2-user ~]$ sudo service httpd start

Start apache at each system boot
[ec2-user ~]$ sudo chkconfig httpd on

Check httpd is on
[ec2-user ~]$ chkconfig --list httpd

Modify ownership and permissions for document root

Add a www group to your instance, and you give that group ownership of the /var/www directory and add write permissions for the group. Any members of that group will then be able to add, delete, and modify files for the web server.

[ec2-user ~]$ sudo groupadd www

[ec2-user ~]$ sudo usermod -a -G www ec2-user (Add user to www group)

[ec2-user ~]$ exit (logout)

[ec2-user ~]$ groups (Verify membership in www group)

[ec2-user ~]$ sudo chown -R root:www /var/www (Change the group ownership of /var/www and its contents to the www group.)

Change the directory permissions of /var/www and its subdirectories to add group write permissions and to set the group ID on future subdirectories.
[ec2-user ~]$ sudo chmod 2775 /var/www
[ec2-user ~]$ find /var/www -type d -exec sudo chmod 2775 {} +

Recursively change the file permissions of /var/www and its subdirectories to add group write permissions.
[ec2-user ~]$ find /var/www -type f -exec sudo chmod 0664 {} +

[ec2-user ~]$ sudo service mysqld start (Start mysql server)

[ec2-user ~]$ sudo mysql_secure_installation (Run mysql_secure_installation, here u can set password for mysql etc...)

[ec2-user ~]$ sudo chkconfig mysqld on (Start mysql at every boot)


Ubuntu

Install updates
$ sudo apt-get update

Install the LAMP stack:
$ sudo apt-get install lamp-server^

During installation this asks for mysql root password. Type it and press enter button. Then retype password will be asked. Type and hit enter.


Start Apache server
$ sudo service apache2 start

Go to your Domain name for your instance. You will see Apache2 Ubuntu default page.

Modify ownership and permissions for document root (Same steps should apply as linux)

That's all.

Connect to your EC2 instance with Putty.

Open puttygen (PuTTy Key Gen)

Go to conversions->Import key->Select the key pair  .pem file you downloaded while launching instance.


Click on Save private key. It will save a .ppk file

Then open pageant click on Add key and select saved .ppk file It will ask for passphrase. Enter it and click OK.


Then close it.


Then open Putty 

Add your instance's EIP, Port 22,


Go To Data. For Ubuntu username is ubuntu. For Linux username is ec2-user


Go to auth under SSH and browse your .ppk file for key pair


Finally Go to session and click Save. And Click Open to connect to the ubuntu instance with SSH.



That's All. Now you have connected to your instance with SSH.