Configure LAMP Server for Drupal 7 and Migrate Development Site - No GUI, command line only

To start with, I created a tarball with bz2 compression of the dev site. Make sure to explicitly include .htaccess because the tar command, like the ls command does not include filenames with "." as the first character. Navigate to the root of your site and execute the following (-c create | -v verbose (lists files as it goes) | -j bz2 compression | -f file):

tar -cvjf nameofsite_date_of_copy.tar.bz2 * .htaccess

Also, you will need the mysqldump

mysqldump -u user -p db-name > db-name.out

more about mysqldump

Next I connected to the dev site via FTP and pulled down the tarball and the sql dump. With that on hand, I can now connect to the VPN and get the files and database setup. FTP the files up and get started extracting the tarball.

tar -xvjf nameofsite_date_of_copy.tar.bz2

Then, we must first create the database:
Login to mysql as root.

mysql -u root -p -h localhost

Most of the time, this will suffice:

mysql -u root -p

At the mysql prompt "mysql >" create the database

mysql> create database yourdbname;

At the mysql prompt "mysql >" create the user

mysql> GRANT ALL ON yourdbname.* TO new-user-name@localhost IDENTIFIED BY 'TheNewPasswordHere';

You can additionally supply remote access permission:
( the following would allow access from )

mysql> GRANT ALL ON yourdbname.* TO new-user-name@ IDENTIFIED BY 'TheNewPasswordHere';
mysql> quit;

Now with the database created and user in place, import the db from the sql dump

mysql -u username -p -h localhost DATA-BASE-NAME < db-name-out.sql

more about mysqldump import

At this point, the files and database are good to go. When I tried to view the index page, I saw nothing. After simple hello world index.php and phpinfo(), I figured out that Drupal 7 requires PHP 5.2+ and 5.3 is even better. The phpinfo() showed PHP 5.1 so it was time to upgrade the PHP version. With CentOS this wasn't too hard.

The article here explains upgrading to php 5.3 very well.

Once PHP was updated and httpd restarted, I saw the homepage. Seemed great until I clicked any link and Clean URLs were not working. Having a little experience in fixing this problem, I knew to look in the .htaccess file. Evertyhing looked good so now I wanted to check if mod_rewrite was installed.

In /etc/httpd/conf/httpd.conf , check that it is being loaded by verifying this line in the file:
If you are unfamiliar with viewing/editing files within SSH, look here or just google "vi editor commands".

LoadModule rewrite_module modules/

If commented out (#), remove the # and then restart httpd

service httpd restart

To list all of the services which are running, checking to see if the rewrite_module is included in the list of modules:

apachectl -M

On some systems, it may be

apache2ctl -M

more about mod_rewrite isntallation

The module was listed for me, so I headed to Drupal to run the Clean URL test (/?q=admin/config/search/clean-urls) and it failed. It ended up that AllowOverride was set to None for the /var/www/html directory in httpd.conf so I changed it to AllowOverride All and voila, the clean url test passed and the Drupal 7 site has been migrated to a fresh LAMP server.