https://fonts.googleapis.com/css?family=Raleway

"Complex Problems, Solved Quickly"

RCH Tech Solutions
  • Home
  • About
    • Services
  • Products
    • Visitor Logic Pro
    • Engage Theme For WordPress
    • WishList Member Upsell WordPress Plugin
  • Portfolio
  • Articles
    • Apache
    • Subversion
    • PHP
    • jQuery
    • WordPress Solutions
    • Exim
  • Members Dashboard
    • License Details
    • Support
Main Menu
  • Home
  • About
    • Services
  • Products
    • Visitor Logic Pro
    • Engage Theme For WordPress
    • WishList Member Upsell WordPress Plugin
  • Portfolio
  • Articles
    • Apache
    • Subversion
    • PHP
    • jQuery
    • WordPress Solutions
    • Exim
  • Members Dashboard
    • License Details
    • Support
  • License Details
  • Support

Author Archives: Rodger Hollingsworth

Subversion |

April 23, 2015

| by Rodger Hollingsworth

SVN checkout to an existing live folder

Scenario:  You have a folder of code on a site that is in use but is not connected to SVN. The folder was created by regular FTP process. The Code that is in the folder exists in SVN but was not checked out to the folder,  so it is not a working copy.

Desire:  you want to get the existing folder connected to SVN so that you can just pull updates from SVN and not maintain a manual synchronization of the files.

I have done this a few times and here is how I connected the existing folder to an existing SVN repository.

How:

Assuming that the SVN repository has the version of the code that you want and you do not want to delete the entire existing folder structure and just do a checkout.  (maybe you have image upload folder,  or lo files that you do not want to delete)

Checkout the SVN repository branch to the existing folder with the –force option.

cd {existing folder}
svn co --force {path to the repository branch to checkout}.

 Don’t forget the “.” at the end of the checkout command.  

This basically creates a working copy of the SVN repository in the existing folder,  but it does not modify any files that already existed in the folder.

After the checkout,  SVN update.  not sure this is needed at this point,  but I run it anyhow.  This is also the command I use to update the folder from SVN.  the parameters ensure that the SVN copy overwrites any changes.  The files should not have been changed outside of SVN anyhow.

svn update --force --accept theirs-full

The files in the existing folder are still not completely in sync with the SVN repository, To get all the files completely in sync with the SVN repository, one more command.

svn revert -R ./

This will result in all the files in the folder being in sync with the repository.

Hope someone find this useful and it saves them time,  I know I spent time searching for the answer and as usual, I needed a few pieces from different places to make it happen so I just put them together here.

jQuery, Uncategorized |

September 8, 2014

| by Rodger Hollingsworth

jQuery Ajax with .html() does not fire js code

I ran across a situation where the I wanted to load the content of a div (modal popup) using jQuery AJAX.

Done it hundreds of times so implementing the AJAX call to populate the content was no issue,  however I now needed to include some custom JS just for the content of the popup.  I could not bind to the events of the elements in the popup until after the content of the popup was loaded, so this meant I could not include the JS in the main JS file, or if I did,  I would need to execute a function to bind to the events after the AJAX call was complete. (Example below)

When I looked at the data returned by the AJAX call,  it looked fine.  Some HTML,  then a script tag that included the small piece of JS I needed.

Problem was that the JS was firing before the HTML was actually added to the DOM.  (try it and you will see)

The core reason is that jQuery functions like .html() , .prepend and a few others will add the script tag separately (and what appears to be before) it actually adds the HTML content.

I know there are ways to accomplish this with rewriting the AJAX call to not use .html(data),  but I needed a quick way to accomplish this without alot of code. Welcome back setTimeout(). Easiest way I found to accomplish the task quickly was to wrap the small piece of JS code I was adding in a setTimeout() function.  IF you are loading a large amount of content,  this may not work.  you will need to test it.

Does not work for me

<div><input id="myButton" name="myButton" type="button" value="Click me" /></div>
<script>
$("#mybutton").on("click", function () {
 alert("Clicked");
});
</script>

Works for me

<div><input id="myButton" name="myButton" type="button" value="Click me" /></div> 
<script> 
setTimeout(
$("#mybutton").on("click", function () { alert("Clicked"); }) , 1000 ); </script>
Comment
Subversion |

August 13, 2014

| by Rodger Hollingsworth

Installing and setting up Subversion on a WHM/Cpanel server

Last Update  4/6/2018 – Refer to this cpanel article for EA4 help https://forums.cpanel.net/threads/svn-install-on-centos-7-ea4.613563/.

UPDATED 2/11/2016.  I use this document as a reference for myself and my company,  every time I have issues with SVN (easyapache updates can cause the SVN installation to break)  I just refer to this article,  and follow the steps,  It always seems to fix the issues.

I have read many posts on installing Subversion on WHM servers. A few were helpful, one was pretty good, but none of them worked for a long time. EasyApache updates would break most the installations. This is my method of installing (and updating) Subversion on a WHM server so that it will not be broken by EasyApache rebuilds.

This process has been used on a number of servers in 2013 and 2014.  All were CentOS and WHM.  I do not think the exact versions of each matter,  and the process would be similar for related versions of Linux.

In this Post,  The term svnaccount** is used to identify the user account name that will be used to host the Subversion url.

The term svndomain** is used to indicate the domain name that will be used to access the Subversion repository.

Overview

  • Install mod_dav
  • Install Subversion
  • Subversion and Apache
  • Setup Subversion Repository
  • Add Subversion Users
  • Cleanup
  • Test

Installing mod_dav (if needed)

First, check to see if mod_dav isn’t already installed on your system by running the following command in the terminal:

root@machine [~]# /sbin/service httpd -M | grep dav

If mod_dav is already installed, it will return:

dav_module (static)
dav_fs_module (static)

 

If not, you will have to run EasyApache (EasyApache is a script used by WHM installations to configure Apache). You can do this by clicking on the EasyApache (Apache Update) link in the WHM menu. Select the most suitable profile to load based on what you are using the server for (if this is not a fresh server, it is better to read the EasyApache documentation before proceeding so that you don’t lose prior configurations). When you reach step for Exhaustive Options List be sure to Dav in the Apache Built-in Modules list. Some article indicate that DAVFs is needed as well.  I have it both ways and it does not seem to matter if DAVFs is selected or not. Save and build. Note: Running EasyApache will take a few minutes.  Your httpd service will be restarted at the end of the process to activate the new build.  

Install Subversion

In order to properly configure latest version of Subversion it needs to be compiled from its sources.

First, go to http://subversion.apache.org/download/#recommended-release and copy the link pointing to the .tar.gz archive (at the time of this post that latest version tarball is at ,http://apache.mirrors.hoobly.com/subversion/subversion-1.8.13.tar.gz). Login to SSH as root user , download the source and unpack it:

root@machine [~]# cd /usr/local/src/
root@machine [/usr/local/src]# wget http://apache.mirrors.hoobly.com/subversion/subversion-1.8.13.tar.gz
root@machine [/usr/local/src]# tar -xvf subversion-1.8.13.tar.gz

Before compiling Subversion, SQLite needs to be copied to the sources. Go to http://www.sqlite.org/download.html and get the link for the latest tarball. (at the time of this post the latest tarball is at  http://sqlite.org/2015/sqlite-autoconf-3080900.tar.gz

root@machine [/usr/local/src]# wget http://sqlite.org/2015/sqlite-autoconf-3080900.tar.gz
root@machine [/usr/local/src]# tar -xvf sqlite-autoconf-3080900.tar.gz
root@machine [/usr/local/src]# cd subversion-1.8.13
root@machine [/usr/local/src/subversion-1.8.13]# mkdir sqlite-amalgamation
root@machine [/usr/local/src/subversion-1.8.13]# cp -r ../sqlite-autoconf-3080900/* ./sqlite-amalgamation/

Now, you need to configure Subversion in order to install it:

root@machine [/usr/local/src/subversion-1.8.13]# ./configure --with-apxs=/usr/local/apache/bin/apxs --with-apr=/home/cpeasyapache/src/httpd-2.2/srclib/apr --with-apr-util=/home/cpeasyapache/src/httpd-2.2/srclib/apr-util
root@machine [/usr/local/src/subversion-1.8.13]# make && make install

You may need to update your path to httpd, if you get the following error:

checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.

root@machine [/usr/local/src/subversion-1.8.13]# ls -all /home/cpeasyapache/src/

Look for httpd-*.*.** (where the stars are your script version) and update accordingly. cd back to the subversion directory and run the configure, make and make install commands again.

EA4 –  The location of apxs has moved.  the latest configure command I have used is ..

./configure --with-apxs=/usr/bin/apxs --with-apr=/home/cpeasyapache/src/httpd-2.4/srclib/apr --with-apr-util=/home/cpeasyapache/src/httpd-2.4/srclib/apr-util

Subversion and Apache

When using WHM and EasyApache, you can’t just modify the Apache configuration to include the Subversion modules. Instead, you must use the Include Editor, which you can find by browsing to “Apache Configuration” in the WHM menu. There, you must use the Pre Main Include. Select the latest Apache version from the dropdown list and a textarea will appear. Add the following to it and click on “Update”:  (Note — The make install command used whenn installing Subversion in the above step,  will put the .so files in these folders. IF you copy them to the standard apache modules folder, then when you rebuild apache using easyApache, and you will trust me, then the files will be deleted and your easyapache rebuild will break due to these include files not being in the modules folder. )

LoadModule dav_svn_module /usr/local/libexec/mod_dav_svn.so
LoadModule authz_svn_module /usr/local/libexec/mod_authz_svn.so

Set up your first repository

I use one repository per domain / subdomain.  These instruction will work for multiple repositories.

First, you need to add a new virtual host for your repository: (NOTE:  apache 2.4 users check if your server uses /2_4/ folder instead of /2/ )

root@machine [~]# cd /etc/httpd/conf/userdata/std/2/

If you get a “-bash: cd: /etc/httpd/conf/userdata/std/2/: No such file or directory” error, run these commands to create the folder:

root@machine [~]# mkdir /etc/httpd/conf/userdata
root@machine [~]# mkdir /etc/httpd/conf/userdata/std
root@machine [~]# mkdir /etc/httpd/conf/userdata/std/2

Now, add a folder for your domain:

root@machine [~]# mkdir /etc/httpd/conf/userdata/std/2/svnaccount**
root@machine [~]# mkdir /etc/httpd/conf/userdata/std/2/svnaccount**/svndomain**
root@machine [~]# cd /etc/httpd/conf/userdata/std/2/svnaccount**/svndomain**

Next, you need to create the Subversion config file

root@machine [/etc/httpd/conf/userdata/std/2/svnaccount**/svndomain**]# nano svn_custom.conf

Paste the following config and save the file. For every repository you wish to create, add another <location> block

<IfModule mod_dav_svn.c>
   #begin location
   <location /repo>
	DAV svn
	SVNPath /home/svnaccount**/public_svn/repo/svn/
	AuthType Basic
	AuthName "SVN Repo"
	AuthUserFile /home/svnaccount**/.svn.htpasswd
	Require valid-user
    </location>
   #end location
</IfModule>

We  use a folder called public_svn which is outside the standard public_html folder. It is NOT recommended to add repositories in the same place as the public webserver files, because you are going to confuse Apache when you are going to try to access the repository through a local Subversion interface. Although you will be able to load the repository in your browser, you will get a “Repository moved permanently to ‘http://example.com/repo/’; please relocate” error when trying to access remotely. This happens because Apache doesn’t know how to respond to the request and gets confused on what it should return.

Now, create the actual repository files:

root@machine [~]# su svnaccount**
example@machine [/root]# cd ~
svnaccount**@machine [~]# mkdir public_svn
svnaccount**@machine [~]# mkdir public_svn/repo
svnaccount**@machine [~]# cd public_svn/repo
svnaccount**@machine [~/public_svn/repo]# svnadmin create svn
svnaccount**@machine [~/public_svn/repo]# chmod 775 -R svn

 Stay logged in at the svnaccount** user.

Add Subversion users

Run the following command to create the new password file with its first user. You will be asked for password:

svnaccount**@machine [~]# /usr/local/apache/bin/htpasswd -cm ./.svn.htpasswd username

For each additional user,  run the following command:  (remove the -c option)

svnaccount**@machine [~]# /usr/local/apache/bin/htpasswd -m ./.svn.htpasswd username

When you have added all the users you need (you can always add more later) Logout of the svnaccount**. You should be back to root access.

svnaccount**@machine [~]# exit

Cleanup

For most VPS hosting accounts that use CentOS you will need to change the permissions on the repo folder so that the svn module can write to the the filesystem. The httpd service runs as nobody so we set the nobody group on the repo folder. If you dont do this you will be able to browse the repository, but not modify it.

root@machine [~]# chown -R svnaccount**:nobody /home/svnaccount**/public_svn/repo

 Tell cPanel to update the Apache configuration to use the custom vhost includes:

/scripts/ensure_vhost_includes --all-users

 

Test

Go to http://svndomain**/repo to test your repository. It should ask for your user and password and then show you something like the following:

SVN-Repo

Comment
Exim |

July 24, 2014

| by Rodger Hollingsworth

WHM Exim Configuration send mail with Amazon SES

Problem:   You use the email system on your WHM / CPanel server to send emails,  but you do not have the time or resources to ensure your server is configured properly for all the different email systems out there.  Reverse DNS, SPF, DKIM etc.  so your server winds up on the blacklist for hotmail, live, yahoo maybe even gmail.  

If you have the time to learn and configure all these all the different pieces of the puzzle so that your server can send emails reliably, and to maintain those settings as the different email providers tighten their criteria, then great.  You should offer that as a service.

I personally do not have the extra time to do it.   

So what is your option.

Use a Third party service,  Like Amazon SES to relay the mails for you.

If you use Exim (default mail system on WHM servers) and have root access to the server.  then Amazon has documented how to setup SES as your relay server. http://docs.aws.amazon.com/ses/latest/DeveloperGuide/exim.html

The instructions are straight forward and work except for one piece.  If you setup email forwarders, they will not work.   Exim will use the SES server when forwarding emails, and the original sender of the email is most likely not on the approved senders list.

How I finally figured out how to get forwarders to work (not use SES) but route all other mail through SES.

 From the Amazon documentation:  you need to modify the router section of the instructions slightly.

 

send_via_ses:
driver = manualroute
domains = ! +local_domains
transport = ses_smtp
route_list = * email-smtp.us-east-1.amazonaws.com;

Modify the above section to read like this:

send_via_ses:
driver = manualroute
domains = !+local_domains
condition = ${if !eqi{$local_part@$domain}{EMAIL_ADDRESS1}}
condition = ${if !eqi{$local_part@$domain}{EMAIL_ADDRESS2}}
transport = ses_smtp
route_list = * email-smtp.us-east-1.amazonaws.com

Notice the 2 new lines that start with “condition”.  Just replace the EMAIL_ADDRESS1 and EMAIL_ADDRESS2 with valid email addresses that your system forwards mail to.

I tried other Exim conditions, and I could not get them to work properly.  But this simple approach works like a charm.

It is not dynamic,  so if you add forwarders to new addresses, it will not automatically add them,  you would need to copy one of the condition lines and change the email address.

If I get a chance, I am sure there is a way to make this read the list of forwarders that are setup on the server.  but I just needed a quick fix and did not have time to figure out how.

Comment
Portfolio |

July 9, 2014

| by Rodger Hollingsworth

WordPress Engage

WordPressEngage.com is our premium WordPress theme that features, Fully responsive design, Visual Composer editor included, compatible with Wishlist Member, WooCommerce and Revolution slider.   Coming soon will be a set of Plugins that will tightly integrate with the Engage theme and provide users with a set of tools to create an Engaging site that results in conversions!.

Comment
Portfolio |

March 20, 2014

| by Rodger Hollingsworth

UNIFFI

UNIFFI

UNIFFI is a custom web based application designed to streamline the workflow of the company that it was created for.  The application has allowed the company to automate and expand operations while streamlining and standardizing their procedures and processes.

 

Comment
Portfolio |

March 20, 2014

| by Rodger Hollingsworth

Gung-Ho

Gung-Ho.com

 

Gung-Ho is a WordPress site based on a commercial theme that has been modified for specific features that the customer desired.   A dynamic menu system was created that allows different areas of the site to use custom logos and menus based on a parent – child page relationship.  set the menu and logo for a parent and all the child pages will use the parents settings unless you want to set specific setting for a child.

Portfolio |

March 20, 2014

| by Rodger Hollingsworth

AthleanX

AthleanX.com

 

AthleanX.com is a custom built WordPress based site that has many custom features,

  • Aweber based free  membership area
  • Ultrcart shopping cart integration
  • Multiple themes / styles for different areas of the site
  • Enhanced google analytics traffic and conversion tracking
Portfolio |

March 20, 2014

| by Rodger Hollingsworth

Collier County Fair

CollierCountyFair.com

 

Collier County Fair and Exposition Inc website is a responsive WordPress site that manages all the content for this non profit organzation’s online presence.   The online ticketing system was built by RCH Tech Solutions and is integrated into the web site for both online sales , Ticket management and ticket redemption.

PHP |

April 9, 2013

| by Rodger Hollingsworth

Simple PHP script to create a nice listing of directories only

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div style="width: 600px; margin: 50px auto">
<h1>Directory Listing</h1>
<?php 
// Your start directory
getDirectory(dirname(__FILE__));
function getDirectory( $path = '.', $level = 0 )
{ 
// Directories to ignore when listing output. 
$ignore = array( '.', '..' );
// Open the directory to the handle $dh
$dh = @opendir( $path );
// Loop through the directory 
while( false !== ( $file = readdir( $dh ) ) ) 
{ 
// Check that this file is not to be ignored 
if( !in_array( $file, $ignore ) )
{ 
// Indent spacing for better view
$spaces = str_repeat( '&nbsp;', ( $level * 5 ) );
// Show directories only
if(is_dir( "$path/$file" ) )
{ 
// Re-call this same function but on a new directory. 
// this is what makes function recursive. 
echo "$spaces<a href='$path/$file/index.php'>$file</a><br />";
//uncomment the following line to display multiple levels of directories.
//getDirectory( "$path/$file", ($level+1) ); 
} 
} 
}
// Close the directory handle 
closedir( $dh ); 
} 
?>
</div>
</body>
</html>
Comment

Post navigation

1 2 Next »

Menu

  • Home
  • About
    • Services
  • Products
    • Visitor Logic Pro
    • Engage Theme For WordPress
    • WishList Member Upsell WordPress Plugin
  • Portfolio
  • Articles
    • Apache
    • Subversion
    • PHP
    • jQuery
    • WordPress Solutions
    • Exim
  • Members Dashboard
    • License Details
    • Support

Recent Posts

  • SVN checkout to an existing live folder
  • jQuery Ajax with .html() does not fire js code
  • Installing and setting up Subversion on a WHM/Cpanel server
  • WHM Exim Configuration send mail with Amazon SES
  • WordPress Engage
  • UNIFFI
  • Gung-Ho
  • AthleanX
  • Collier County Fair
  • Simple PHP script to create a nice listing of directories only

Menu

  • Home
  • About
  • Products
  • Services
  • Portfolio
  • Contact Us

Products

Engage Theme For Wordpress

WLM Upsells Wordpress Plugin

Support

footer-logo

© RCH Tech Solutions 2017

Lost your Password

OR