WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Aug 29 2013

Hostgator SSH .bashrc and .bash_profile

So, recently, I need to run some php code from the command line and it kept throwing an error, one I recognized as related to PHP version, which I found extremely strange since all my sites are running either PHP 5.3.x or 5.4.x. This poses a problem because when you run php from the command line, regardless of what you have in your .htaccess file, Hostgator defaults to PHP 5.2.x. Don't believe me, try it.

Create this file (test.php) and place it at your root (~/).

<?php
echo 'Hello! ' . phpversion() . "\n";

Then type this in your SSH command line.

php test.php

It should output:
Hostgator SSH

So I created a php alias, which worked well from the command line!

alias php='/opt/php53/bin/php'
alias wp='~/.wp-cli/bin/wp'
alias cdp='cd /home/tsmith/public_html'

However, when I ran a bash file, the error appeared again! Then upon dealing with it a bit more, I added the alias to .bashrc; however, .bashrc does not auto-load when a shell opens (just in case you didn't know!). And default .bash_profile does not exist, so I had to create .bash_profile. To do this from the command line type: nano .bash_profile into the command line.

nano .bash_profile

Hostgator SSH .bash_profile

This will bring up a place to write into the file. Then add the following, which will autoload .bashrc, to the file.

[[ -s ~/.bashrc ]] && source ~/.bashrc

Hostgator SSH .bash_profile

Enter Ctrl+X to exit and save. Type Y. Press Enter.
Hostgator SSH .bash_profile

Then you will be back to the SSH command prompt. Now everything should work!

Written by Travis Smith · Categorized: WordPress

StudioPress Premium WordPress Themes     WP Engine Managed WordPress Hosting

What can I do for you!?

Custom Development

We develop plugins by determining both business/functional and technical requirements, following WordPress development best practices, and using agile methodology to ensure you get the best solution.

Consulting

Have questions? Need a reliable developer to consult? Please contact us today!

Customized Theme

We can customize your theme or child theme, or create a child theme for you based on your needs while enhancing the performance of every individual attribute.

Customized Plugin

We can customize your plugins, extend plugins (e.g., Gravity Forms, Jetpack, Soliloquy) based on your needs ensuring security, performance, and positive business impact.

Contact Us

About Travis Smith

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

Comments

  1. iMadalin says

    October 17, 2013 at 5:10 am

    100% stay away of php 5.2.x branch and I advise even on running away of 5.3.x

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in