Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday, April 16, 2013

[PHP] Installing PHP, Apache, Laravel locally on Windows 7

This guide is only for note taking purposes. Whenever I set up something for the first time, I feel like writing about it. I don't know why that is, but don't worry about it and let's begin.

Installing PHP 5.4 and Apache 2.4:
  • Download Apache 2.4 from apachelounge.com
  • Download PHP 5.4 from the php.net
  • Extract Php files into a directory. You can choose c:\php if you want.
  • I think Apache 2.4 comes in a zip. So just extract the contents into a directory of choice. I use c:\apache
Configuring PHP and Apache

  • In command line, install Apache as a service by running this in cmd: httpd -k install
  • Navigate to Apache's configuration directory and open httpd.conf in a text editor
  • Add the following lines

# PHP Stuff #####################################
#
LoadModule php5_module "c:/php/php5apache2_4.dll"
AddHandler application/x-httpd-php .php


# configure the path to php.ini
PHPIniDir "C:/php"


  • Change the listening port if necessary. You may want IIS to be on 80 and Apache on 8080. Or vice versa
  • Start apache!!!
Install Laravel
  • Download Laravel 4. Search on google. And follow the tutorial on the Tut+ site
  • If you're migrating and seeding the database, you need to add $this->call('TableNameTableSeeder') make the following class:


class TableNameTableSeeder extends Seeder {

    public function run()
    {
        DB::table('tablename')->delete();
        User::create(array(
                'id' => 1,
                'username' => 'firstuser',
                'password' => Hash::make('first_password'),
                'created_at' => new DateTime,
                'updated_at' => new DateTime
        ));   
    }
}


Monday, November 19, 2012

[PHP/MySQL] Amazon EC2, Elastic Beanstalk, RDS setup

Basic setup of using these three services in.....haaaarrrmony. I'm using WinXP.

Index:
1. Setup EC2 instance
2. Setup Elastic Beanstalk with GIT (Tested with PHP projects)
3. Setup RDS to be used with MySQL Workbench

1. EC2 Instance
   Just follow the instructions and CREATE and DOWNLOAD your key/pair. Creating your instance is the only time you can assign a key/pair to it, let alone download it. Take note of the security group you are using for it. Also, go find your internet IP and add it to the selected security group.

2. Elastic Beanstalk
   This is basically your web host that you deploy to. Download GIT and the CLI Package (http://aws.amazon.com/code/6752709412171743). Find GIT on Google and the CLI Package in the Elastic Beanstalk documentation. Install GIT and run the CLI Package according to the instructions in the archive. 

Configuring Beanstalk for file uploading/deploying:
Go to your working folder in command line.
First, type eb init
Follow the instructions and you can find the your credentials here: https://aws-portal.amazon.com/gp/aws/securityCredentials
After you're done, enter the command: eb start

Now, you should be able to run git commands. Usually, this is the sequence I use:
1. git add .    (adds all files/folders/sub-folders)
2. git commit -m "<your message>"
3. git aws.push

3. RDS
1. Choose/create a database instance you would like to work with.
2. Go to the DB Security Groups section.
3. Add a new connection type of EC2 Security Group and choose the same one used in your EC2 Instance. You may also want to add a new CIDR/IP address using an IP finder.
-- MySQL Workbench
4. Setup a New Server Instance
5. Select Remote Host and input the address of your EC2 instance.
6. Select SSH type of connection
7. For SSH user, put ec2-user if using Amazon or ubuntu if using Linux
8. SSH password is not required.
9. Use the key/pair generated earlier
10. Enter the rest with the DB Instance info.

After all that, you should be good to go. Cheers