How to Make a Development Site Accessible Both Internally and Externally on Windows Running Apache

Create a new vhost and add Listen directive.

# -----------------
Listen 8181
# You can also add client-site.com.clients.com to your hosts file.
# client-site.com.clients.com -> 192.168.1.134
# Make it run on 2 ports at the same time.
<VirtualHost *:80 *:8181>
DocumentRoot C:/projects/clients/client-site.com/htdocs
ServerName client-site.com.clients.com
<Directory C:/projects/clients/client-site.com/htdocs>
allow from all
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
</Directory>
</VirtualHost>
# -----------------

Add firewall rule to allow connections to and from port 8181 for all private and public networks.

Add a port forward at the router level from port 8181 to your IP:8181

Restart or reload apache

I am assuming that you have created C:/projects/clients/client-site.com/htdocs

Bonus: if you’re running WordPress as well you can change links pointing to the external IP address on the fly.
Do replace all occurrences of 1.2.3.4 with your real ip and this snippet to wp-config.

if ($_SERVER['SERVER_PORT'] == 8181) {
define('WP_HOME', 'http://1.2.3.4:8181');
define('WP_SITEURL', 'http://1.2.3.4:8181');
//ob_start( 'orbisius_adjust_links' );
// at godaddy links were forced to be SSL and they are everywhere
// and the current siteground hosting may not have ssl (or it might)
// we'll make them non-https
function orbisius_adjust_links( $string ) {
// correct secure links to point to the non-ssl site (e.g. in menu)
// Since it was moved away from GoDaddy there is no ssl.
$string = str_replace( 'https://olddevlinks.net', 'http://1.2.3.4:8181', $string );
return $string;
}
}

One Important Decision to Consider About Your Phone/Fax Numbers When Starting a Business

When I first started my business (Orbisius which started as WebWeb.ca) I made the conscious decision not to get a phone number from a local provider (with the exception of my cell phone provider) because that would lock me in on a contract and I wouldn’t be fully location independent.

The numbers I have are:
1 US
2 Canadian phone numbers – Toronto & Niagara area code
1 Fax number (which I no longer use)

Back in 2005-2006 Skype started offering US phone numbers so I picked one and I kept using it to this day.
The quality is good but it lacks some important business features like sending the voicemail to an email and downloading it.

For my Canadian numbers I decided to use http://voip.ms

Voip.ms is a very powerful service but requires technical knowledge and patience to figure out how to best use it but it’s worth it.
They send you the voicemails as an attachment (in .wav format, yep I know mp3 would’ve been better).
There are ring groups and some other rules that you can define when to receive the phone call and when to go to voicemail. I am problably using 5% of the service but it works for me.
When somebody calls it rings on my computer.

I made one mistake before I ordered my Niagara phone number: I should’ve at least Googled the number as it turned that it belonged to a funeral home (!) so I kept getting calls/faxes which was pretty annoying.

Fax
About the fax service I used PamFax with a Toronto area code.
I used the service for 2-3 years and cancelled it because I wasn’t using it that much.

I am sure there are other providers. Let me know your experience or lessons you’ve learned.

Good luck with your business.
Slavi

How to Enable log_warnings in MySQL 5.x

If we log_warnings to greater than 1 it should start logging more verbosely.

show variables like '%warn%';
set global log_warnings = 2;

Related

  • http://dba.stackexchange.com/questions/19285/log-warnings-doesnt-seem-to-work-for-aborted-connections-in-mysql-5-1
  • http://dba.stackexchange.com/questions/19285/log-warnings-doesnt-seem-to-work-for-aborted-connections-in-mysql-5-1
  • http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_log_warnings

 

 

cancel 1and1 Extended PHP Support php4 nag

How to Cancel 1and1’s Extended PHP Support (php 4)

How to Cancel 1and1’s Extended PHP Support (php 4)

About 10 days ago I received a notification that I had to do some changes in my 1and1 control panel.
I was being lazy but started exchanging emails with the support.
At the end I had to go in the control panel and change the php versions to my sites.
I picked php 5.4 for now instead of going straight to php 5.5 or php 5.6

cancel 1and1 Extended PHP Support php4 nag

Steps
1) 1and1 Control Panel | Hosting | Manage Webspace | PHP Settings select your

cancel 1and1 Extended PHP Support php4 select domain

2) Then go to http://cancel.1and1.com/ and look for “1&1 PHP4 Extended Support” which should be at the end.

cancel 1and1 Extended PHP Support php4

Password Protect (Basic Authentication) with Nginx

This code allows me to password protect a site and only allow it to be accessed either by supplying the correct password defined in your.pwd OR if it is called by PayPal. that’s the code I had to use for on the staging environment on one of my products (MiniAds).

location / {
satisfy any;
allow 192.168.1.0/32;
# PayPal servers ; 2014-10-21
allow 66.211.170.66;
allow 216.113.188.202;
allow 216.113.188.203;
allow 216.113.188.204;
deny  all;
auth_basic  "Restricted";
auth_basic_user_file  /var/www/pwd/your.pwd;
index  index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}

test
nginx -t

Rreload configuration
nginx -s reload

 

Related: https://www.paypal-community.com/t5/Merchant-services-Archive/IPN-server-s-ip-s/td-p/126274

How to Delete a WordPress User Using PHP

From time to time when you’re developing plugins/themes you may need to delete some test user accounts. Here is a way to do it.

You can either create an MU Plugin (by creating a file in mu-plugins/some-code.php) or adding it in functions.php in your current (child) theme.

Then go to the admin area. I was receiving errors (function doesn’t exist) when I wasn’t in the admin area.

You have to be careful with this code.

add_action('admin_init', 'abc_quick_del', 10);
// !!!
function abc_quick_del() {
$user = get_user_by( 'login', 'some_username');
if (!empty($user-&gt;ID)) {
echo "Deleting user ID: " . $user-&gt;ID . "&lt;br/&gt;\n";
wp_delete_user( $user-&gt;ID );
} else {
echo "Account not found.";
}
}

 

 

How to Properly Redirect to a New Site using .htaccess

From time to we need to redirect an old site to redirect to a new site.

The good thing about the redirect snippet below is that that it will also append the parameters sent to the old site to the new one.
That is very important especially if you’re running ads or have links that have tracking parameters e.g. oldsite.com/?utm_source=orbisius.com

RewriteEngine On
RewriteCond %{HTTP_HOST} ^youroldsite.com$
RewriteRule ^/?(.+) http://yournewsite.com$1 [R=301,QSA,L]

 

How to Configure php Mail’s Function on Windows with Mandrill

Normally, php mail’s function doesn’t *work* on Windows because there is no sendmail server running by default.

Some people got it working using Fake Sendmail and Stunnel  & an external service such as Gmail/Yahoo, and others using msmtp.

I didn’t want my gmail or other credentials saved on the computer or a too complicated solution that may be hard to troubleshoot so I decided to use the Mandrill service to send emails from my development machine.

So the steps are the following

  1. Download Fake Sendmail
  2. Extract the archive contents in c:\usr\lib
    Important Note: if you’re running Windows 7 or 8 (not sure for Vista) you need to set XP Compatibility Mode. To do that right click on Sendmail.exe and click on properties and then enable XP compatibility mode (shown below).
  3. Edit php.ini (shown below)
  4. Signup for Mandril
  5. Create an API key (which will be your password) by going to Settings
  6. Configure Fake Sendmail (shown below)
  7. Restart Web Server or restart computer if that’s easier.

Enable XP Compatibility Mode on Fake Sendmail

Enable XP Compatibility Mode on Fake Sendmail

php.ini configuration (partial)


Fake Sendmail Configuration (Windows)
Make sure you edit the following.

  • default_domain=YOUR_DOMAIN_GOES_HERE
  • auth_username=YOUR_MANDRIL_EMAIL_GOES_HERE
  • auth_password=YOUR_MANDRIL_API_KEY_GOES_HERE

Note: if you’re configuring your own copy of the config file make sure you don’t use encryption i.e. smtp_ssl=none (as shown in the snippet). I’ve had no problems using the command line scripts, however, the php script would hang if Fake Sendmail used encryption.

Resources

  • http://glob.com.au/sendmail/
  • http://msmtp.sourceforge.net/
  • http://help.mandrill.com/entries/23744737-Where-do-I-find-my-SMTP-credentials-
  • http://help.mandrill.com/entries/21738467-Using-Mandrill-s-SMTP-integration-with-Web-Frameworks
  • http://www.php4every1.com/tutorials/enable-e-mail-in-php-on-windows/
  • http://wiki.uniformserver.com/index.php/Installing_Fake_Sendmail_for_Windows
  • http://stackoverflow.com/questions/21337859/sendmail-wamp-php