10 Years $10 – New campaign by Packt Publishing

10 Years $10 - Packt Publishing

July 2014 marks 10 years since Packt Publishing embarked on their mission to deliver learning and information services to IT professionals. To celebrate this huge milestone, they are offering ALL of eBooks and Videos at just $10 each for 10 days until July 5th. Visit this link to learn more

If you’ve already tried a Packt title in the past, you’ll know this is a great opportunity to explore what’s new and maintain your personal and professional development. You can get ANY eBook or Video for $10 in this offer – browse all their categories at the bottom of this page.

All eBooks and Videos are $10 – Visit this link to learn more

URL Rewriting in CodeIgniter

CodeIgniter Logo

As mentioned on EllisLab website, CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. At the same time, there are few simple things which may stall beginners with this framework.

I faced a problem with URL rewriting in CodeIgniter experiment and with the help of community found a solution as well so posting it as a blog post for everyone’s help so that you don’t need to find the whole internet for this simple solution 🙂

Problem 1) Removing index.php file from codeigniter URL and adding .html suffix to it:
1. Create an .htaccess file in the root directory of CodeIgniter installation
2. Make sure to double check .htaccess extension as notepad might turn it as txt file when saved in default mode so select “All Files” option while saving it as .htaccess file
3. Add the following rules to .htaccess file to have URL rewriting option ready to remove index.php file from URL:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

4. Then find the following line in your application/config/config.php file:

$config['index_page'] = 'index.php';

5. Set the variable empty as below:

$config['index_page'] = '';

6. If it still doesn’t work, find the following line in your application/config/config.php file: and try to replace following variable with these parameters. For me, AUTO option worked after having above steps:
(‘AUTO’, ‘PATH_INFO’, ‘QUERY_STRING’, ‘REQUEST_URI’, and ‘ORIG_PATH_INFO’)

$config['uri_protocol'] = 'AUTO';

7. To add .html suffix, find following line in your application/config/config.php file and add .html as default suffix:

$config['url_suffix'] = '.html';

That’s all. Here you go 🙂 – good luck!

Simple Linux and MySQL Commands for everyday use

For last few days, I was working on Linux operating system. I liked it but after some time, I figured out that to use it effectively, I should be handy with the simple Linux and MySQL commands. To keep it for archive and easy access purpose, I am writing a blog post so that I and beginners like me can take benefit of these easy to use commands 🙂

To start the Apache server, as root type:

/sbin/service httpd start

To stop the Apache server, as root type:

/sbin/service httpd stop

To restart the Apache server, as root type:

/sbin/service httpd restart

Start/Stop/Restart MySQL server:

/etc/init.d/mysqladmin start
/etc/init.d/mysqladmin stop
/etc/init.d/mysqladmin restart

Note: Redhat Linux also supports service commands as below to start, stop and restart mysql service:
Start MySQL:

# service mysqld start

Stop MySQL:

# service mysqld stop

Re-start MySQL:

# service mysqld restart

Set MySQL server Password:

$ mysqladmin -u root password NEWPASSWORD

Update MySQL server Password:

$ mysqladmin -u root -p'oldpassword' password newpass

Change ownership to grant files writing permission to a specific user/owner:
chown [-R] newowner filenames

Connecting to MySQL server:

mysql -u root -p -h localhost

System will prompt you for password which you can enter and pass this screen.

To create a database structure:

CREATE DATABASE bookstore;
USE bookstore;

To create a database table:

CREATE TABLE TABLE_NAME(
COL_NAME1 CHAR(20) PRIMARY KEY,
COL_NAME2 VARCHAR(50),
COL_NAME3 INT,
COL_NAME4 INT,
COL_NAME5 CHAR(4),
COL_NAME6 TEXT
);

See the created database table structure:

DESCRIBE TABLE_NAME;

Entering data in database table:

INSERT INTO TABLE_NAME
(COL_NAME1, COL_NAME2, COL_NAME3, COL_NAME4)
VALUES('value1', 'value2', 'value3', 'value4');

Retrieve table data:

SELECT title
FROM TABLE_NAME;

Update table data:

UPDATE TABLE_NAME
SET COL_NAME1= 'value1'
WHERE COL_NAME2= 'value2';

Delete table records:

DELETE FROM TABLE_NAME
WHERE COL_NAME1 = 'value1';

Credit: http://www.redhat.com/magazine/007may05/features/mysql/

Migrate to WordPress from BlogEngine

BlogEngine is a very popular, useful and open source blog management tool based on ASP.NET but with the evolution of PHP more and more tools are coming up fast like WordPress. I have used BlogEngine personally in past but with the evolution of WordPress, things have been changed completely.

Ease of writing plugins and designing themes in WordPress has made it a very popular, easy to use and rich blog publishing tool. Not only for blogs but for many website, WordPress is being used widely.

In this changing time, if you are still on BlogEngine and want to move to a more flexible blog publishing tool then here are the steps to migrate from BlogEngine to WordPress:

  1. Make sure to take files and database backup of your old BlogEngine site and new WordPress site (if already setup) – it might be helpful as if you fall in some trouble to restore everything.
  2. Login to BlogEngine site and export your blog data from blogengine_site>settings>import/export
  3. Download BlogMLimporter plugin and install in your new WordPress site (you can find this plugin at http://wordpress.org/extend/plugins/blogml-importer/)
  4. Go to WordPress_site/Tools/Import/BlogML and select XML file to import
  5. All done – now check your WordPress site.

If everything is followed right, you would see and like your new WordPress site ready with your old data. This way, you won’t loose anything from your past and can utilize your past contents to remain high on SEO too. Enjoy!

Disclaimer: Steps mentioned in this post are for self guidance only and author doesn’t take any responsibility of data loss or any other kind of loss due to this post.

How to change default server port 8080 to 80 in JBOSS?

So here is another day of troubleshooting. I am completely new to JBoss and wanted to change the default port of JBoss which was 8080. Here are some of the steps which I followed and got success.

To run JBoss on port 80, please change all instances of 8080 to 80 in the following files:

1. server.xml in \server\default\deploy\jbossweb.sar

<!-- A HTTP/1.1 Connector on port 8080 -->
      <Connector protocol="HTTP/1.1" port="80" address="${jboss.bind.address}"
               connectionTimeout="20000" redirectPort="8443" />

2. jboss-service.xml in \server\default\deploy\http-invoker.sar\META-INF
3. bindings-jboss-beans.xml in \server\default\conf\bindingservice.beans\META-INF

<property name="port">80</property>
...
<xsl:when test="(name() = 'port' and . = '80')">

Things to remember:

  1. Ensure that new port number is not already occupied by some other service.
  2. JBoss is very close to Tomcat and many of its properties works the same way.

JBoss Server not running except localhost?

Last week, I started work on one of our new mobile application built using JBoss server. It was a totally new experience for me but as soon as we launched the server and app, we noticed an strange issue that it was working fine on localhost but not able to access the same link from external server.

When I did more study in this, I noticed that if we start JBoss server using run.bat from command prompt without using any special parameter, it will automatically bind to localhost (127.0.0.1), means we will be able to access the server only from that machine. To bind it to other (or all) IP, we should start JBoss server from the command prompt with a -b argument.

E.g.: run.bat -b

If you want to bind to a specific IP, say 192.168.1.1, use run.bat -b 192.168.1.1
If you want to bind it to all the IPs, including localhost use, run.bat -b 0.0.0.0

I thought to share this tip with everyone because it took a good two days of mine to understand and resolve the issue. Hope, it would help someone faster and me too next time as a reference post 🙂