PHP on Amazon Cloud Computing (EC2)
Upcoming SlideShare
Loading in...5
×
 

PHP on Amazon Cloud Computing (EC2)

on

  • 17,695 views

This article describe installing PHP on Amazon EC2 with Amazon Linux AMI

This article describe installing PHP on Amazon EC2 with Amazon Linux AMI

Statistics

Views

Total Views
17,695
Slideshare-icon Views on SlideShare
17,570
Embed Views
125

Actions

Likes
6
Downloads
365
Comments
4

6 Embeds 125

http://www.onlinephpstudy.com 62
http://127.0.0.1 45
http://paper.li 13
http://de.twitter.com 2
https://twitter.com 2
http://onlinephpstudy.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

14 of 4 Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • @chintankotadia7 i think because you have n't write anything on the file... make sure.
    1. after command crontab -e
    2. press the INSERT key to write on the file. (Now write the command). (first line)
    3. Press enter for blank line. (this should be second line)
    4. Use ESC key for close the editing.
    5. then type :x for save changes (this will installed a new crontab)

    if nothing is changed, then message appear 'no changes made', else message is 'installing new crontab'
    Are you sure you want to
    Your message goes here
    Processing…
  • Thanks for the response.

    Currently, it says that 'no changes made to crontab'. Can you please let me know what am I doing wrong here?
    Are you sure you want to
    Your message goes here
    Processing…
  • @chintankotadia7

    :x command is used for close the operation with save changes.
    Are you sure you want to
    Your message goes here
    Processing…
  • i setup crontab step by step but i dont know what is the x command??
    plz reply.
    thanks.........
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    PHP on Amazon Cloud Computing (EC2) PHP on Amazon Cloud Computing (EC2) Document Transcript

    • Installing PHP on Amazon EC2 (Using Amazon Linux AMI) Kamal SharmaTable of ContentsRequirements .......................................................................................................................................................... 2Create and Launch Amazon Linux AMI ................................................................................................................... 2 Create Security Group ......................................................................................................................................... 2 Create Key Pairs .................................................................................................................................................. 3 Convert Key Pair to PuTTY Format ...................................................................................................................... 4 Create Instance ................................................................................................................................................... 5Controlling Instance via PuTTY ................................................................................................................................ 7Installing PHP ........................................................................................................................................................ 10Transferring Files................................................................................................................................................... 11Enable SEO Friendly URLs Support (.htaccess) ..................................................................................................... 13Running CronJobs.................................................................................................................................................. 15
    • Requirements Amazon Web Services Account WinSCP (for transfer files) PuTTY (SSH client)Create and Launch Amazon Linux AMICreate Security GroupLog in to Amazon Management Console with your username and password. Switch to EC2 Tab.On the Network & Security tab click on Security Groups to view and create Security Groups.Security Group frame is active, where all Security Group is listed.Click Create Security Group button to create new group. Popup window will open, fill the required fields.
    • New Group created with name MyTestGroup. Assign ports to security group using inbound tab. select optionfrom Create a new rule drop down.22 (SSH) – Port 22 is used for connecting SSH server.80 (HTTP) – Default port of Web server.Apply Rule ChangesCreate Key PairsOn the Key Pairs Panel, click on Create Key Pair button.Fill desired Key Pair Name.
    • Key Pair is created successfully and able to download on your local disk.Convert Key Pair to PuTTY FormatPuTTY can’t read (.PEM) files that provide by Amazon. It understands its own (.PPK) format. We can translatethe (.PEM) file format to (.PPK) file format using PuTTYgen. Open PuTTYgen; most probably locate in (c:/program files/putty/puttygen.exe) Find the (.PEM) file using Load button.
    • Key Passphrase like a password, you can leave this field blank otherwise it authenticate when you connecting to instance. Save private key on your disk.Create Instance On Amazon EC2 Console Dashboard, Launch the instance using Launch Instance button. Choose an Amazon Machine Image (AMI) from one of the tabbed lists below by clicking its Select button.
    • Pick a meaningful name for your Instance, select Key Pair and choose Amazon Linux AMI Click Continue. AMI. Edit details to choose your Security Group and Instance Type, click Edit details.Instance is launched and Public DNS is available.
    • Controlling Instance via PuTTYIn Auth section, browse your private key file for authentication. Use Public DNS as Host Name. Connection Type to SSH And Port 22
    • After connecting to server, on terminal login as ec2-userChange the user (ec2-user) to root with the following command.sudo -iIf you try to open Public DNS URL, browser throws error Unable to connect because server is not installed onAMI.First need to install Apache server with following command.yum install httpdType and Enter y to confirm installation.
    • After Apache is successfully installed, start the Apache with following command.service httpd startTest the URL (Public DNS), Apache is installed and running successfully.
    • Installing PHPInstall PHP using following command.yum install phpIf you need to install separate package such as MySQL, IMAP etc. Name Package MySQL php-mysql GD php-gd XML php-xml IMAP php-imapyum install php php-mysql php-gd php-xml php-imap
    • After install PHP, need to restart Apache to take effect, use the following command to restart Apache.service httpd restartTransferring FilesFor transferring files need SCP client such as WinSCP. Open WinSCP, use Public DNS as Host name User name as ec2-user Browse your Private Key file. And Choose File protocol - SCPAfter successful login move to root directory (Server Path)./var/www/html
    • Use drag and drop for transfer files (client to server when you trying to transfer file, WinSCP generate an client server), henerror message such as Permission denied because ec2-user don’t have permission to copy files in rootdirectory.So need to change the Permission for ec2 ec2-user. The following command need to change the permissions. chgrp (Change Group Permission – chgrp -R “user” “directory Change Permission) directory” chmod (Change File Permission – chmod permission “directory Change Permission) directory”After edit the permission, files successfully transferred.
    • Test the URL, PHP is successfully installed.Second method, transfer files without changing the group permission for ec2 ec2-user; change the server path toec2-user directory path in (httpd.conf file. httpd.conf)Enable SEO Friendly URLs Support (.htaccess)By default, Amazon not provides this option with Apache installation; need to interfere with Apache(httpd.conf) configuration.Testing the clean URL with browser, it generates an error because Apache not able to handle (.htaccess) file.First needs to edit the (httpd.conf) file in etc/httpd/conf for editable by ec2-user with the followingcommand.
    • Chgrp –R “ec2-user” “/etc/httpd/conf/httpd.conf” Chmod 0774 “/etc/httpd/conf/httpd.conf”Open the directory (/etc/httpd/conf) using WinSCP and edit the (httpd.conf) file. You need to change theAllowOverride NoneToAllowOverride allRestart the Apache withservice httpd restartApache commands
    • Start - service httpd restartStop – service httpd stopRestart – service httpd restartTest and SEO friendly URL is working.Running CronJobsCron is a time-based job scheduler in Unix based Unix-like computer operating systems.Cron Job commands:crontab -l – Listing the running cron cron.crontab -r – Removing the running cron.crontab -e – creating and editing the cron.Checking the any Cron Job is running for the user with the following command.crontab -lSample Cron Job for every one minute.Min Hour Day of Month Month of Year Day of Week Commands* * * * * php /var/www/html/mycronfile.php* * * * * php /var/www/html/mycronfile.phpCreate Cron Job using following command
    • crontab -eAfter CronTab editor open, press the insert key to write on the file. Press enter for blank line. Use ESC key to close the editing Type : x command and press enter to close and save changes.Cron Job is installed.