Browsing the web host category

GoDaddy Cron Job PHP include files

As a follow-up to figuring out how to get Cron Jobs to actually run in GoDaddy with a PHP script, I ran into another error:

I have a PHP Cron job that worked on HostGator, but it didn’t work on GoDaddy.  After I figured out the correct command to use, I noticed that it wasn’t actually connecting to the database.

At first, I didn’t notice this because I typically “include” files instead of “require” them.  I read somewhere that it takes up less processing power; so I figure once I know the location of the file, I can just “include” it (instead of “require” it).  Unfortunately, changing hosts caused an unforeseen inssue!  So that was the first mistake…

Going to the URL (in the browser), everything worked (i.e. it would connect to the database).  However that when running the Cron job, it didn’t work.  I found this out by printing out (in the email) the current working directory ( cwd(); ).  On the web server, it was as expected:

 /home/<username>/public_html/<sitename>/file.php

However the Cron job runs it from the root!

/home/<username>

Usually I just reference a configuration file with “include(“../path/relative/to/here”).  But that didn’t work!  The solution was to explicitly state the entire path of the file you want to include.

However then I ran into another problem:

I typically have code that detects the URL to determine if I’m in a sandbox or production environment.  GoDaddy’s Cron job, the PHP function $_SERVER[‘SCRIPT_FILENAME’] doesn’t return anything, so you can’t use that to determine which environment you’re in.  For now, I think I’ll have to just have 2 version of the file and comment/uncomment out the appropriate database connection to serve the correct data source.

By the way: if you thought this blog post was helpful, check out the book I wrote on PHP, geared toward intermediate web developers.

Read the article

GoDaddy PHP Cron Job (shared server)

I recently wrote about writing a (PHP) Cron Job on Host Gator.  Now I had to do one for GoDaddy.  I’m on a shared server (not sure if that makes a difference?).

I’m using CPanel with PHP version 7.1… and at the time of writing, GoDaddy’s documentation only has CPanel for a lower PHP version.  I called tech support, but they only pointed me in the right direction…

Here’s the right syntax:

/usr/bin/php-cli /home/<username>/public_html/<site>/file.php

I reluctantly turned on sending emails; good thing I did, because I found out there was an error.

BIG GOTCHA: you can’t have a period in the directory name; as in, if you’re working in “/username/public_html/yoursite.com/cronjob.php” that won’t work – it doesn’t like the “yoursite.com” part.  Remove that so it’s just “/username/public_html/yoursitecom/cronjob.php” (or some variation that doesn’t have the period).  The script wasn’t even running, and I didn’t realize this until I turned on the email notifications.

Once I did turn on the notifications, I was getting this error:

Failed loading /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so:  /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ioncube_loader_lin_5.4.so: cannot open shared object file: No such file or directory

Failed loading /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ZendGuardLoader.so:  /opt/php54/lib/php/extensions/no-debug-non-zts-20100525/ZendGuardLoader.so: cannot open shared object file: No such file or directory
Content-type: text/html; charset=UTF-8

Thanks to Stack Overflow – https://stackoverflow.com/questions/40109716/cronjob-not-starting-in-godaddy-shared-hosting) for pointing out that you need the “-cli” in the command to avoid that error.

UPDATE: there’s another “gotcha” in GoDaddy’s PHP Cron Job usage; I wrote about it here.

By the way: if you thought this blog post was helpful, check out the book I wrote on PHP, geared toward intermediate web developers.

Read the article

SSL Tips

I wanted to use SSL for my site, but ran into some problems.  Two tips:

  • A CDN that you use has to also be hosted via SSL.  That shouldn’t be a problem, so just make sure that you explicitly specify it
  • You can run your site through https://www.whynopadlock.com to see additional errors that may be causing it.

Read the article

Windows MAMP openssl extension not working

I’m on a Windows machine, trying to run a local web server using MAMP.  Trying to use Composer, I got the error “[Composer\Exception\NoSslException] – The open ssl extension is required for SSL/TLS protection but is not available…”

Several searches said that I had to update the php.ini file.  But there’s a handful of them!

The solution: create (or update) the php.ini file where the php.exe file is located – for me: C:\MAMP\bin\php\php7.0.9 (where there was already a “php.ini-development” and “php.ini-production”

 

UPDATE:

I had to COPY the file from C:\MAMP\conf\php7.0.9\php.ini into C:\MAMP\bin\php\php7.0.9\php.ini .  When I tried to copy one of the existing “php.ini-production” (with the change made), it didn’t work.  There must be something different in that other php.ini file.

Read the article

Sublime FTP Multiple disconnection errors, giving up

With Sublime Text, the FTP plug-in, I was getting this error:

“Multiple disconnection errors, giving up”.

 

I was able to use a regular FTP client…

Solution: just close and re-open Sublime Text!

Read the article

Google Domains – domain hosting, not web hosting

Awhile ago I wrote about how I use GoDaddy to buy domains .  This is for “new” domains – as you can get a good deal (with a coupon).  However when you go to renew a domain, I couldn’t find any coupons, so I would have had to pay full price.

Google Domains is a service that I wasn’t familiar with. I was able to transfer in my domains there at a price cheaper than a “renewal” at GoDaddy, AND Google gives free private registration (something you have to pay for on GoDaddy).

There was an option for Google to “detect and import current domain settings” which worked.  However when I went into the DNS configuration, the name servers listed were pointed to “Google [default] name servers” and NOT my “custom” name servers from the web host I was using.

I contacted Google Domains (via email) and they were VERY responsive.  There were a few back-and-forths, the customer service was excellent.

The solution is that under the Google “Custom Resource Records” (again, in the DNS configuration section), the “Type A” had the IP address of my host – even though the custom name servers were not specified (and was using Google’s). I pointed out that to avoid additional customer confusion, they might want to also import those settings (not sure if they will or not?  They said they’ll pass it along to the appropriate team for consideration).  But it was through this “Custom Resource Records” that Google knew where my website was hosted.

Side note: in one of the email exchanges I had with Google tech support, they used the term “domain hosting” – which I had never heard before. I assumed it was the same as “web hosting” and got excited.  Turns out that they just meant “registrar” – and I’d have to stay with my current host (which, I am happy with).

Read the article

Classic ASP Errors turned off, only showing 500 Internal Server Error

We got a new web server at work, and the “errors” were not showing up in my ASP pages. I simply get a “500 Internal Server Error”. Before, it would give me some sort of debugging information (for example, a line number). I asked the webmasters to turn it back on, providing an article from StackOverflow as a suggestion of how to do it.

Here’s how they turned it on:

IIS –>ERROR MESSAGES –> EDIT FEATURE SET–> CHECK DETAIL ERRORS.
IIS –> ASP –>COMPILATION –>DEBUGGING PROPERTIES SET ENABLE SERVER SIDE DEBUGGING = FALSE SEND ERROR TO BROWSER.

Note: Previously server side debugging was on and it was not displaying error details on remote side. It started showing error details after setting ENABLE SERVER SIDE DEBUGGING = FALSE.

Read the article

error with encrypting over SSL

I’m making an ecommerce site.  In all of the books and sites and articles I read, they all say to NOT store credit card information on your server.  You have to be all sorts of compliant and know what your doing, etc.  I know what I’m doing, but I have no interest in becoming “compliant” and having additional responsbility when something goes wrong.

I’m using www.braintreepayments.com to process the credit cards.  First of all, their customer service is great – always very helpful, I highly recommend them.  They’re storing the credit card information on their server, so everything is good.

However I need to store additional, sensitive information not just credit cards.  Going back to the compliance issue, I’m able to store it in a “custom customer field” as specified in my braintree settings.

But I don’t want to just store this data as “plain text,” – what if something happens? (I’m paranoid like that, in a good way though).  So the solution is to encrypt the data, store it on their server, and then decrypt the data back when displaying it on the webpage.

The solution I found, for PHP, was to use an algorithm called “blowfish” (just Google it).  Note, when you’re encrypting text, you should have a “salt” – extra characters to make sure it’s really secure (you can Google that yourself, too).

I encrypted my text via blowfish and tried to store it on the braintree server.  Didn’t work.  I e-mailed their support and was told the solution (they’re so helpful!).

Blowfish apparently encrypts data in binary.  The output, when printed on a page, looks like special characters of a Wing Dings font.  Binary data couldn’t be stored in the braintree database.  They suggested I use the PHP function:
base64_encode to encrypt the data first (and then base64_dncode after to decrypt it).  That worked!

Read the article

Buying Domains with GoDaddy

I like to buy my domains through GoDaddy.  I’ve heard that the CEO wrongfully kills elephants or something, so there are people that don’t want to use this service because of that.  Not that I promote killing elephants, but that won’t stop me from using GoDaddy.

The hosting isn’t great – it’s a bit slow.  Especially when they have their GoDaddy televised /streaming promotions.  I remember reading that you should only use a company for their primary service.  By this it’s meant: GoDaddy is known for buying domains; not for their hosting.  So you should use them for buying your domain… but not hosting.

One thing I’m not a fan of, which I completely understand why they do this, is that they try to get unsuspecting users to buy stuff they don’t need.  Extra storage or e-mail accounts.  You don’t need this!

GoDaddy has excellent customer support (as, I’ve had to call them a few times).  So I do recommend using GoDaddy to buy domains. However:

– always use a coupon!  Just google “GoDaddy Coupons”.  You can usually get a percentage or dollar amount off
– don’t buy stuff you don’t need – resist the urge
– the real reason for this post: I found a trick!!…

Just now I went to renew 5 domains for 2 years each.  I tried to use a “percent off” coupon, but it didn’t take.  I noticed on the site that it said I was already getting the best price possible for a “multi year discount”.  So I changed my order to be 1 year for each domain (instead of 2).  Then I applied the (33% off!) coupon.  Then I re-upped each domain for 2 years.

I got 33% off (about $40) on my order (of about $130).  Maybe I typed in the coupon wrong the first time, but I’ll definitely keep this in mind when I buy (or, renew) my next GoDaddy purchase.

 

Read the article