Showing posts with label Web Development. Show all posts
Showing posts with label Web Development. Show all posts

Monday, September 23, 2013

Drupal: Getting started for programmers.

Well if you are a programmer and understand how software works and know how to quickly code up HTML/CSS/JS/PHP and you are thinking to move to Drupal, then mate you are where I was a week back.

There are tons of tutorials on the web from very basic to advanced, but its too much to go through and completely unorganized. Here I will give you links (mostly video) to understand important parts of drupal as quickly as possible and just get started with making our own website with the looks and features you want.

Some Important parts of Drupal.

What is Drupal?





Views : http://www.mustardseedmedia.com/podcast/episode9  
 https://learndrupal.stanford.edu/video/drupal-6-views-introduction





How to customize a Website's look and feel :







By now you know basics, I suggest you should now get started to do some theming. If you need to dig dipper and need advanced tutorials:



Best of luck.





Thursday, September 12, 2013

Quick start with AWS: Create a new instance, install LAMP and Drupal.

Step-by-step guide to getting started with a new AWS (Amazon web services) account and hosting a Drupal powered website.

Estimated time to complete 40 minutes. For more info or help on any of the sub-steps, please do a quick Google search.


1. Create a new AWS account.
2. Launch a new instance :
 > make sure the volume, i.e the disk is of type ebs, increase the size if  you want.
 > use a AMI, i.e the OS from the list.
 > Generate a key value pair. Download the .pem file.
 > In the security group enable TCP port 80 (for HTTP) and 22 for SSH.

3. Generate an elastic IP
4. Associate the IP with the generated instance.
5. Create a monitoring alarm for the instance for high CPU.

6. Copy the .pem in some secure location.

7. Set up SSH to the instance, by configuring the ~/.ssh/config file.

Host ANY_NAME_YOU_WANT_TO_CALL_THE_INSTANCE.
HostName: ec2-xxxxxxx.compute-1.amazonaws.com
User: ec2-user
IdentityFile "~/.ssh/ec2.pem"

>chmod 700 ~/.ssh/config
>ssh Hostname <--- as="" config="" file.="" in="" p="" ssh="" the="" used="">

// Set up all utilities: Fedora


sudo yum -y update
sudo yum -y install httpd mysql mysql-server php php-cli php-gd php-intl php-mbstring php-mysql php-pdo php-pear php-xml php-xmlrpc 

// Check apache version for apache1

httpd -v

// for apache2
apache2 -v

// check php version 

echo '' | php


Make sure services automatically start on a reboot:
sudo chkconfig httpd on
sudo chkconfig mysqld on
sudo service httpd start
sudo service mysqld start 
 
Edit your httpd.conf:
sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.old
sudo vi /etc/httpd/conf/httpd.conf
 
find and under that change AllowOverride None to AllowOverride All
Press Ctrl + C and type :wq to save and quit.
Restart apache for changes to take effect:
sudo service httpd restart 


Set your mysql root password
sudo mysqladmin -u root password 'change-password' 
 
Mysql security:
sudo mysql -u root -p
mysql> DROP DATABASE test; 
mysql> DELETE FROM mysql.user WHERE user = ''; 
mysql> FLUSH PRIVILEGES; 
 
Create the database that drupal will use:
mysql> CREATE DATABASE drupal;
 
Press Ctrl + C to exit mysql.
Now your server is ready for drupal. I'm going to use drush to install:
pear is a php tool which allows reuse of php code and patches etc.
drush is a tool used to manage all of drupal.
sudo pear upgrade
sudo pear channel-discover pear.drush.org
sudo pear install drush/drush 
 
Next use drush to download the latest drupal version and then move it to the web root directory (Make sure to substitute the the name of the latest distribution for "drupal-7.x")
cd /var/www/html/
sudo drush dl
sudo mv drupal-7.x/* ./
sudo mv drupal-7.x/.htaccess ./
sudo rm -r drupal-7.x 
 
Create the files directory and the settings.php file
sudo mkdir sites/default/files
sudo chmod 777 sites/default/files/
sudo cp sites/default/default.settings.php sites/default/settings.php
sudo chmod 777 sites/default/settings.php 

Open your site in a browser and complete drupal install process, your site can be reached at the public DNS listed in your AWS console when you select an instance and should look something like ec2-00-00-000-00.compute-1.amazonaws.com.

After that go back to your terminal and set the permissions on the settings.php file.
sudo chmod 644 sites/default/settings.php 
That's it, you should now have the latest version of drupal up and running on your ec2 instance.


Running Appache as a different user:

If php needs to create log files while running under appache, apache should be run under a proper user:

Depending on your OS, this might be 'www-data', 'nobody', 'http', or any variation. If your website is the only website running, this is easy to change by changing the user Apache runs under. If you have Debian, like I tend to, you can edit the file /etc/apache2/envvars (as root), and change the value for APACHE_RUN_USER. Depending on your OS, this variable might be set in a different configuration file, so if you can't find it in /etc/apache2/envvars, try to search for the variable declaration by using:

More info: 
http://stackoverflow.com/questions/5165183/apache-permissions-php-file-create-mkdir-fail

This might cause PHP to loose access to session variables:


open(/var/lib/php/session/sess_isu2r2bqudeosqvpoo8a67oj02, O_RDWR) failed: Permission denied (13) in Unknown on line 0
you have to check file permission change mode this /var/lib/php/session/

Giving permissions to file so that apache works (apache runs as www-data)

Keep the owner as yourself for the folder:
chown -R eve contoso.com
Make group as the apache group. 
 chgrp -R www-data contoso.com
Change permission for the folder.
 chmod -R 750 contoso.com
 Make the folder permissions sticky, such that new files created insider the folder also has the same permissions.
 chmod g+s contoso.com ; needs to be run as sudo, 'g' is for group, 's' is for sticky
Make a apache writeble folder.
chmod g+w uploads

SetUp Mysql User:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
 GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';  (*.* == db.table)

FLUSH PRIVILEGES;


Install AWS SDK for PHP:

Via Composer:
   > In the project file create a file named: composer.json and add the aws dependency as:
    {
       "require": {
          "aws/aws-sdk-php": "2.*"
       }
   }

> Install composer and move it to make it a utility.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Now Install the dependencies via composer by running the below in the project root directory:
composer install
More info: https://getcomposer.org/doc/00-intro.md
This will create a folder 'vendor' with all the libraries, use composer autoloader to load all libs.
require '/path/to/sdk/vendor/autoload.php';
include the AWS namespaces by
use Aws\someserices\xyz

AWS setting up credentials profile:

 Use a cred file in the home dir to store access keys:
            http://docs.aws.amazon.com/aws-sdk-php/guide/latest/credentials.html#credential-profiles

 AWS email service:

Sending emails via SES:
     Creating a email client:
                   http://docs.aws.amazon.com/aws-sdk-php/guide/latest/service-ses.html
   
      Things that can be included in an email via sendEmail() function:

           http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.Ses.SesClient.html#_sendEmail


Tuesday, August 13, 2013

Best Chat Widget for websites or blogs.


Autopilot is a revolutionary technology and this has completely changed the face of aviation industry both civil and military alike.  Having a live chat widget on your website or blog is like having an Autopilot with much more benefits.

You can let your visitors discuss contents of your blog or website, let them find like-minded people to possibly form long lasting relations. I personally, am delighted, when I find such a service on a website or a blog, it helps me meet strangers  who are so much like me that they feel like my extension. I can keep chatting with these strangers as I go about reading or browsing the website. I would love to see a day when almost all the websites have such a widget.

 For websites or blogs owners too, such a tool is a boon. It lets your users drive interaction on your website (Autopilot?), users can answer some one-off queries of other users, new users can be helped by the existing users and help in discovery of content on the website. Also the tone of discussions gives a site owner a very good insights on the likings of her user base and help guide site improvements and features.

Confaber: A live chat widget for my blog.

I have started using this tool Confaber, which is free of cost and provides a pretty extensive set of capabilities. I love the way it seamlessly allows people to send private messages to each other (which it calls 1-O-1 chats)  in addition to the normal blog wide chat. I was delighted to see that it allows me to draw pictures right from the chat box and add it to the discussion (sadly this feature is not present in 1-O-1 chats). I hope my users will also like this.