CentOS 7

Bash Shell Script to Backup a Directory

Share on LinkedIn

Here’s a simple little script to backup your web directory. This works on CentOS 7 with no problem. This script backs up the /var/www/html directory.

Create scripts directory

mkdir /home/scripts

Create directory to store backup files

mkdir /home/backups

Create the script

vi /home/scripts/www-backup.sh
FILENAME=www-backup-$(date +%-Y%-m%-d).tgz
tar --create --gzip --file=$DESTDIR$FILENAME $SRCDIR

Description of script elements
Source Directory
Destination Directory
Filename to include date stamp
Create and Compress file using tar command

Ensure execute permissions are set on the script

chmod +x www-backup.sh

Execute the script
To run the script, just type the following from within the /home/scripts directory


This will create a file similar to www-backup-2015317.tgz in your /home/backups directory.

To extract or unzip from backup
Navigate to /home/backups and run the following tar command to extract:

tar -zxvf www-backup-2015317.tgz

How To Ensure WordPress Auto Updates Work on Self-Hosted Linux Machine

Share on LinkedIn

I’ve been meaning to get this posted for some time now. It could prove useful to someone hosting their own WordPress site on a self-hosted Linux machine.

When you are logged into the admin console of your WordPress site, you will get notifications of needed updates. You may also want to upload new themes from time-to-time.

When you go to perform the Automatic Update, it will work without issue so as long as your permissions are setup properly on your apache web server.

If you find yourself running into this issue, ssh into the backend of your apache web server and follow these simple steps:

1. Set ownership of /var/www/html and make changes recursive

chown -R apache:apache /var/www/html

2. Ensure the apache user/group can write to /var/www/html and make changes recursive

chmod -R 0775 /var/www/html

3. Restart apache

service httpd restart

Once you made those changes to the backend, try to run the update(s) again from the admin portal. You should be all good to go from there.

How To Install SugarCRM

Share on LinkedIn

Performing a SugarCRM installation can be difficult if you’ve never done it. There are many articles on the web with instructions but I’ve found all of them, to include the instructions on SugarCRM’s web site, lacking details. And those were pretty much the best set of instructions that existed…until now! I had a colleague, not as familiar with Linux, go through these instructions. If it’s any consolation, he was able to get his SugarCRM server running! This is SugarCRM Community Edition v6.5.20 installed on CentOS 7. These instructions will work with Red Hat 7 as well.

You pick your machine, VM or physical machine. These instructions work on CentOS 7 no problem. They should work on Red Hat 7 and Fedora 21 as well. Don’t skip steps and good luck!

1. Set Time Zone for Server. In this example, CST.

timedatectl set-timezone America/Chicago

2. Install LAMP components and base tools/utilities
**There are additional component below that are not described in the post**

yum install php httpd mariadb mariadb-server php-mysqlnd php-mssql php-opcache php-mbstring unzip nano wget

3. Install EPEL (required to install php-imap for mail capabilities)

rpm -ivh http://elrepo.org/linux/elrepo/el7/SRPMS/elrepo-release-7.0-2.el7.elrepo.src.rpm
yum install epel-release

Install php-imap

yum install php-imap

4. Update system and all packages (not required but habit)

yum update

5. Change hostname

hostnamectl set-hostname sugarcrm

6. Set SELINUX to permissive

vi /etc/selinux/config

Find SELINUX=enforcing and change to


Write, Quit, Now


Make sure selinux is turned off for this session (same as permissive)

setenforce 0

7. Enable Firewalld and Allow HTTP on port 80 for public zone

firewall-cmd --zone=public --add-service=http --permanent
service firewalld restart
service firewalld status

8. Enable Service, Start Services, Set To Start Services Automatically on Boot

systemctl enable mariadb.service
systemctl start mariadb.service
systemctl restart httpd.service
systemctl stop firewalld
chkconfig firewalld on
chkconfig httpd on

9. Set AllowOverride to All for the Sugar installation directory
Before you install Sugar, set AllowOverride to All for the Sugar installation directory in the httpd.conf file. After you install Sugar, an .htaccess file is created in your Sugar installation directory.

There are at least 3 instances of AllowOverride. The first is for the root directory (/). The second is for /var/www. The third and the setting you need to change is /var/www/html.

vi /etc/httpd/conf/httpd.conf

Search for AllowOverride (for /var/www/html)

AllowOverride None

Change from None to All
Write, Quit, Now


10. Edit Hosts File (Not necessarily required, just habit. Use the ip of your machine.)

vi /etc/hosts
xxx.xxx.xxx.xxx sugarcrm.yourdomain.com sugarcrm
xxx.xxx.xxx.xxx sugarcrm

Write, Quit, Now


11. Edit php.ini file
Navigate to the php.ini file located in your Sugar root directory and set the variables_order parameter to EGPCS.

vi /etc/php.ini

Search for upload_max_filesize and change from 2M to 20M

upload_max_filesize =

Search for variables_order and change from GPCS to EGPCS

variables_order =

Search for date.timezone

; date.timezone =

Uncomment and set to America/Chicago as such

date.timezone = America/Chicago

Write, Quit, Now


12. Reboot the server


13. Download Installation Package and Copy To Linux Machine
Navigate to WWW directory

cd /var/www
wget http://downloads.sourceforge.net/project/sugarcrm/1%20-%20SugarCRM%206.5.X/SugarCommunityEdition-6.5.X/SugarCE-6.5.20.zip?r=http%3A%2F%2Fwww.sugarcrm.com%2Fthank-you-downloading-sugar-community-edition&ts=1426019617&use_mirror=superb-dca2

When complete, press Enter

Show contents of directory


You should see an html directory and your download which will lead with “SugarCE-Full-6.5.20.zip” followed by a bunch of other characters

Rename that file to something more manageable (highlight the file to select the exact name)

mv SugarCE-6.5.20.zip?r=http%3A%2F%2Fwww SugarCE-Full-6.5.20.zip

Show contents of directory


You should see an html directory and your new, abbreviated SugarCE-Full-6.5.20.zip file

14. Extract zip file to your www directory

unzip SugarCE-Full-6.5.20.zip

You should see an html directory, your new, abbreviated SugarCE-Full-6.5.20.zip file, and a new directory named SugarCE-Full-6.5.20

Output Example


15. Move contents of SugarCE-Full-6.5.20 directory to html directory

cd SugarCE-Full-6.5.20
mv * /var/www/html
cd ..
rm -rf SugarCE-Full-6.5.20

16. Create empty .htaccess file
Installation is supposed to do this automatically but I ran into problems so I created a blank one that can be written to.

cd /var/www/html
vi .htaccess

Write, Quit, Now


17. Change Owner and make changes recursive

chown apache:apache -R /var/www/html

18. Change Permissions to files and sub-directories

chmod -R 0775 /var/www/html

19. Configure mysql for first use
Setup Root user for first use

mysqladmin -u root password NEWPW

Test root user login

mysql -u root -p

Should now be logged into myslq


20. That’s it. Go to site from web browser

You SHOULD be able to reach the site and SHOULD be able to go through the entire install process from here! If not, we missed something somewhere!




How To Check Running Version of Linux

Share on LinkedIn

To check the version of Linux your system is running, simply run the following command:

cat /etc/*-release


Your output will look similar to this:

CentOS Linux release 7.0.1406 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID_LIKE="rhel fedora"
PRETTY_NAME="CentOS Linux 7 (Core)"

CentOS Linux release 7.0.1406 (Core)
CentOS Linux release 7.0.1406 (Core)