Friday, 16 August 2013

Amazon EC2 (Amazon Elastic Compute Cloud)



To see AWS free tier

750 hours Linux/UNIX or RHEL EC2 Micro Instance is free

To check AWS EC2 pricing

Creating New Instances
Login to AWS management console
We can create instances from
EC2 Dashboard > instances

Launch Instance > Create new instances

Choose an AMI (Amazon Machine Image ) for instance


Select the  Instance Type: (T1 micro)
Create the key pair. These key pair are required to login to the EC2 instance

Continue the next steps and create the instance.
  

Need to add rules in Security Groups. There will be a default security group in AWS or there is option to add new security group

We need to add the inbound rules to enable access to the different ports.
ie – the port numbers 21,22, 80,3306 etc.

By default there will no static IP configured in EC2. The server will be only accessible using the public DNS name
for eg :  ec2-23-20-98-110.compute-1.amazonaws.com

IF we want to configure a static IP there is option to add ELASTIC IP in AWS.  This is required at the time of pointing the domain name to EC2 server.



Login to the server

We require the key pair to login to EC2. Download the key pair to your local computer and authenticate with the key.

The default user of EC2 instance will be “ec2-user
login method
# ssh -i /home/domain.pem  ec2-24-25-97-150.compute-1.amazonaws.com
(domain.pem   is key pair name)


Reset the root password using sudo
# sudo passwd root
Enter new password.

By default there will be no software installed in the server. We need to install the softwares manually.  Ie we need to install Apache, PHP, MySQL, FTP manually.

We have an option to use Amazon RDS(Amazon Relational Database Service) for databases
http://aws.amazon.com/rds/

# su -
enter the password to switch to root user and install the required software.
 

 

Sunday, 14 July 2013

PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in Unknown on line 0


When you try to find some configuration values used while compiling php or checking the php.ini location, you might get the following error.

php -i | grep config

PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in Unknown on line 0
Configure Command => './configure' '--prefix=/usr/local/php53' '--with-layout=GNU' '--enable-libxml' '--with-libxml-dir=/usr/local' '--with-apxs=/usr/local/sbin/apxs' '--with-regex=php' '--with-zend-vm=CALL' '--disable-ipv6' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=i386-portbld-freebsd7.2' '--with-curl' '--enable-ftp' '--with-gd' '--enable-mbstring' '--with-mcrypt' '--with-mysql' '--with-mysqli' '--with-openssl' '--enable-pcntl' '--with-pcre-regex' '--enable-soap' '--with-zlib' '--enable-cgi' '--enable-ctype' '--enable-dom' '--enable-xml' '--enable-simplexml'
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in Unknown on line 0

To fix this error, add date.timezone in php.ini

php -i | grep php.ini # to find the location of php.ini

Then, 

echo 'date.timezone = "America/New_York"' >> /path/to/php.ini

Friday, 5 July 2013

Setup Local YUM Server in Centos

Yellowdog updater, Modified (Yum) is a software package manager that installs, updates and removes packages on RPM-based Linux distributions. Yum uses an online repository by default, but you can also configure it to use a local repository of packages.
Mount the contents of your CentOS 6.3 DVD in the /mnt directory or wherever you want. In the Terminal window, type the following command:

[root@ns2 Packages]# mount /dev/cdrom /mnt/
mount: block device /dev/sr0 is write-protected, mounting read-only

Install vsftpd package, so that we can use this as a FTP server to share our repository in the client systems.
Change to the directory where you mounted CentOS DVD. In our example we have mounted the CentOS DVD in /mnt directory.

    # cd /mnt/Packages
    # rpm -ivh vsftpd-2.2.2-11.el6.i686.rpm

Start the FTP Service:

    # service vsftpd start

Install createrepo package if it is not installed. This is package is used to create our local repository.

[root@ns2 Packages]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
error: Failed dependencies:
    deltarpm is needed by createrepo-0.9.8-4.el6.noarch
    python-deltarpm is needed by createrepo-0.9.8-4.el6.noarch

It shows us the dependency problem. Let us the install missing dependencies first:

[root@ns2 Packages]# rpm -ivh deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:deltarpm               ########################################### [100%]
[root@ns2 Packages]# rpm -ivh python-deltarpm-3.5-0.5.20090913git.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:python-deltarpm        ########################################### [100%]

Now install the createrepo package:
[root@ns2 Packages]# rpm -ivh createrepo-0.9.8-4.el6.noarch.rpm
Preparing...                ########################################### [100%]
   1:createrepo             ########################################### [100%]


Create a folder called localyumserver (You can use your own) in /var/ftp/pub directory to save all the packages from the CentOS DVD. Copy all the files in the Packages folder from the DVD to /var/ftp/pub/localyumserver folder:

[root@ns2 Packages]# mkdir /var/ftp/pub/localyumserver
[root@ns2 Packages]# cp -ar *.* /var/ftp/pub/localyumserver/

After all packages are copied, create a repo file called localyumserver.repo in /etc/yum.repos.d/ directory.

[root@ns2 Packages]# vi /etc/yum.repos.d/localyumserver.repo

and Type the following entries and save the file

[localyumserver]
name="local yum repository"
baseurl=file:///var/ftp/pub/localyumserver
gpgcheck=0
enabled=1

Where,
[localyumserver] ==> Name of the Local Repository.
comment ==> Information about the Repository.
baseurl ==> Path of the Repository (i.e where we had copied the contents from CentOS DVD)
gpgcheck ==> Authentication of the Repository, which is disabled in our case.

Now it is time to create our repository. Enter the following command in the Terminal:

[root@ns2 Packages]# createrepo -v /var/ftp/pub/localyumserver

Delete or rename all the other repo files except the newly created repo file i.e in our example it is localyumserver.repo.

Next update the repository:

        * yum clean all
        * yum update

Client side configuration:

Create a repo file in your client system as mentioned above in the /etc/yum.repos.d/ directory and remove or rename the existing repositories. Then modify the baseurl as mentioned below:

[localyumserver]
name="local yum repository"
baseurl=ftp://<IP>/pub/localyumserver
gpgcheck=0
enabled=1