Category Archive : Uncategorized

XAMPP is a helpful development tool. However, you may run into problems at some point, such as receiving the notification: “Apache shutdown unexpectedly”. This error might seem to come out of nowhere, so identifying the cause – let alone the solution – can be puzzling.

Fortunately, there is a common explanation for Apache’s sudden shutdown. With a few simple modifications, you should be able to fix the problem and get Apache up and running again. All you have to do is update some settings in the configuration files.

In this article, we’ll discuss the common cause of this Apache error in XAMPP and then walk you through four steps to fix it, both on Windows and macOS.

Let’s get started!

An Introduction to the XAMPP “Apache Shutdown Unexpectedly” Error

XAMPP is a free, open source server stack that includes the Apache server and MariaDB database:

The XAMPP website.
The XAMPP website.

It runs PHP and Perl scripts, and is used to develop and test dynamic websites on local machines. This means that if you are building a website, you can install WordPress locally on your computer. You can use XAMPP without having to upload your site’s files to your web hosting service.

If you’re reading this article, we’ll assume you’re already at least somewhat familiar with XAMPP. However, what may be new to you is the “Apache shutdown unexpectedly” error you’re seeing.

This message is most commonly caused by a blocked port. Usually, it means that another application installed on your computer, such as Skype, is using the same port as XAMPP. Additionally, you may notice that the error message indicates the problem may also be attributed to “missing dependencies, improper privileges, a crash, or a shutdown by another method.”

In any event, the easiest fix is to simply modify the XAMPP default settings. However, the method for resolving the error varies slightly between Windows and macOS. Also, the interface may look a bit different depending on the XAMPP version you’re using. We will provide instructions for both operating systems below, starting with Windows.

How to Fix the XAMPP Error “Apache Shutdown Unexpectedly” in Windows

If you’re using a Windows device, you can follow these four steps to update your default port settings in XAMPP.

Step 1: Open the Configuration Settings from the XAMPP Control Panel

The first step is, of course, to launch XAMPP. This will open the XAMPP control panel. From here, you can update the configuration settings for the server stack.

Since this error is related to Apache, we’ll focus on those settings. In the “Apache” row of options, click on the Config button.

The XAMPP control panel in Windows.
The XAMPP control panel in Windows.

This will open a drop-down menu of files. We’re going to be editing two of these files, starting with httpd.conf.

Step 2: Change the Default Port Settings of the httpd.conf File

From the menu of files, click on Apache (httpd.conf). Once you do, the file will open in your computer’s default text editor:

The Apache (httpd.conf) file in XAMPP control panel.
The Apache (httpd.conf) file in XAMPP control panel.

Within this file, there are three settings you’ll want to update. To get started, press Ctrl + F, then enter “80” in the search field:

The Apache httpd.conf file in Windows.
The Apache httpd.conf file in Windows.

This will display all instances of the number 80 in the file. Locate “Port 80” and change it to “Port 8080”. Once the port setting is updated, search for “Listen 80” and update it to “Listen 8080”.

Finally, search for “servername localhost:80”. Once you find it, modify it to “servername localhost:8080”. When you’re finished, save and close the file.

Step 3: Update the Default Port Settings in the http-ssl.conf File

Now it’s time to move on to the second file. To do so, you can return to the XAMPP control panel, then select Config under the Apache settings again. This time, open the Apache (http-ssl.conf) file.

When the file opens in your text editor, press Ctrl + F, and then enter 443 in the search field. Locate “Listen 443” and update this to “Listen 4433”.

Next, search the file for the next instance of “443”. It should be “<VirtualHost _default_:443>”. Once you find it, you can go ahead and change it to “<VirtualHost _default_:4433>”. When you’re finished, remember to save and close the file.

Step 4: Restart Apache

Once you’ve updated the settings in both files, the final step is to stop Apache. You can do this by clicking on the Stop button along the same Apache row. After Apache has been stopped, click the Start button to complete the restart process.

The option to stop Apache in XAMPP.
The option to stop Apache in XAMPP.

That’s it! Your port numbers will be updated and Apache should now run without error.

How to Fix the XAMPP Error “Apache Shutdown Unexpectedly” in macOS

Depending on what version of macOS you’re running, you may already have Apache installed on your computer. This default application of Apache will use the same default port settings as the Apache server in XAMPP, so this may be the cause of the “Apache shutdown unexpectedly” error.

If you’re using macOS, you can follow these four steps to update the default port settings.

Step 1: Open the XAMPP Apache Configuration

To start, open the XAMPP Application Manager if you haven’t already done so:

The XAMPP application manager.
The XAMPP application manager.

Next, select the Manage Servers tab next to the Welcome tab at the top:

Looking for a powerful tool for local WordPress development? DevKinsta features one-click site creation, built-in HTTPS, powerful email and database management tools, and more. Learn more about DevKinsta!

XAMPP’s "Manage Servers" settings.
XAMPP’s “Manage Servers” settings.

On this screen, you’ll find a list of options. You can click on Apache Web Server, followed by the Configure button.

Step 2: Open the Conf File

From the Configure Apache Web Server box, select Open Conf File:

XAMPP’s "Configure Apache Web Server" options.
XAMPP’s “Configure Apache Web Server” options.

A warning box will appear, stating that the file is for advanced users:

XAMPP’s conf file warning “for advanced users”.
XAMPP’s conf file warning “for advanced users”.

You can click on Yes to continue. This will open the httpd.conf file.

Step 3: Update the Port Settings

Once the file opens in your text editor, the next step is to update the port settings. To do so, you can hit Ctrl + F, and then enter “80” in the search field. This will display instances of the number 80:

XAMPP’s httpd.conf file port settings.
XAMPP’s httpd.conf file port settings.

Locate the these lines:


#Listen 12.34.56.78:80
Listen 80
Once you do, go ahead and change them to the following:
#Listen 12.34.56.78:8080
Listen 8080

When you’re done, you can save and close the file. In the Configure Apache Web Server box, click on OK.

Step 4: Restart Apache

The final step is to stop and restart Apache, which you can do from the XAMPP Application Manager’s Manage Servers tab. Once Apache is stopped, click on Start to restart:

The XAMPP Apache port.
The XAMPP Apache port.

That’s it! Your port numbers will be updated and Apache should now run without error.

Summary

The XAMPP error “Apache shutdown unexpectedly” is commonly caused by another program, such as Skype, using the default Apache port. While this can be frustrating, it usually has a simple resolution.

As we discussed in this article, the easiest way to fix this problem is to update XAMPP’s Apache configuration settings. You can do this by editing the httpd.conf file and the http-ssl.conf file (for Windows users). Once this is done, you should stop and restart Apache to resume normal operation.

Listing sizes in AWS S3 Buckets

Getting the whole bucket size

aws s3 ls s3://$BUCKETNAME/ --recursive --human-readable --summarize | tail -n2

Tail is used because otherwise all files will be printed on screen (but you may want that for some reason).

Getting the size of a specific directory/file

You just need to add the path to the bucket name:

aws s3 ls s3://$BUCKETNAME/some/dir --recursive --human-readable --summarize | tail -n2

Getting the size of all subdirs

If you imagine there is something like ncdu or du -ha -d 1 /foo/bar you’re wrong. If you want to get the size of all subdirs you have to do it yourself:

Your Bucket contains in $BUCKETNAME/some/dir multiple subdirs (for e.g. 2020, 2019 and 2018) and you want to see the size of these 3 directories.

S3PATH='s3://$BUCKETNAME/some/dir/'
for dir in $(aws s3 ls "${S3PATH}" | grep PRE | awk '{print $2}'); do 
    echo "${S3PATH}${dir}:"
    aws s3 ls "${S3PATH}${dir}" --recursive \
                                --human-readable \
                                --summarize\
    | tail -n2
done

A | column after done could improve the readability.

Send A Test Mail via Exim Command line

Sending a test mail from a server with a configured exim is easy as pie.

From your user shell:

  1. tell exim that we want to send a mail to an recipient and tell us about the details of the sending procedure
    $ exim -v receipient@foo.bar
    
  2. Tell exim about the sender, the subject and input some text.
    From: user@your.domain.example
    Subject: Foobar
    Text Text Text
    
    I like Pie!
    
  3. Press Ctrl+d
  4. You should see the details about the SMTP connection. You can return to your shell with Ctrl+c

This guide will show you how to extend or resize an ext2/3/4 and XFS File System without LVM at runtime. This could be a root partition configured with ext2/3/4 or XFS filesystem but without any LVM configured.

Step 1: Check your current root disk capacity

For this demonstration, I have a CentOS 7 VM with below partition scheme.

$ lsblk 
 NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
 sr0     11:0    1 1024M  0 rom  
 vda    253:0    0   10G  0 disk 
 └─vda1 253:1    0   10G  0 part /

As seen from the output, the root filesystem is on /dev/vda1 partition without LVM.

Step 2: Extend your OS root disk

I will extend my root block device to 30GB. I use KVM virtualization technology, so this guide works for me:

For KVM I can check virtual disk path using the command below:

$ sudo virsh domblklist centos7 
 Target   Source
-------------------------------------------------
 vda      /var/lib/libvirt/images/centos7.qcow2
 sda      -

$ sudo fdisk -l /var/lib/libvirt/images/centos7.qcow2
Disk : 10 GiB, 10739318784 bytes, 20975232 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

$ sudo qemu-img resize /var/lib/libvirt/images/centos7.qcow2 +20G
Image resized.

If you’re on a different Virtualization platform, refer to its documentation for how to extend OS virtual disk.

Step 3: Grow VM partition

Start your VM and ssh as a user with sudo privileges. The first thing to do is to confirm the new disk size.

$ lsblk 
 NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
 sr0     11:0    1 1024M  0 rom  
 vda    253:0    0   30G  0 disk 
 └─vda1 253:1    0   10G  0 part /

We can see the disk has grown by 20GB, from 10GB to 30GB. The next action is to expand the partition (Partition 1) in our example, to the maximum size the disk provides.

Install cloud utils package

For those new to growpart, it is a Linux command line tool used to extend a partition in a partition table to fill available space. This command is provided by cloud utils package.

On Ubuntu / Debian system, run:

sudo apt -y install cloud-guest-utils gdisk

For CentOS / RHEL / Fedora server, run:

sudo yum -y install cloud-utils-growpart gdisk

Help page can be viewed by passing -h argument

# growpart -h
growpart disk partition
   rewrite partition table so that partition takes up all the space it can
   options:
    -h | --help       print Usage and exit
         --fudge F    if part could be resized, but change would be
                      less than 'F' bytes, do not resize (default: 1048576)
    -N | --dry-run    only report what would be done, show new 'sfdisk -d'
    -v | --verbose    increase verbosity / debug
    -u | --update  R update the the kernel partition table info after growing
                      this requires kernel support and 'partx --update'
                      R is one of:
                       - 'auto'  : [default] update partition if possible
                       - 'force' : try despite sanity checks (fail on failure)
                       - 'off'   : do not attempt
                       - 'on'    : fail if sanity checks indicate no support

   Example:
    - growpart /dev/sda 1
      Resize partition 1 on /dev/sd

Now use growpart to extend your partition.

$ sudo growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=20969472 end=20971520 new: size=62912479,end=62914527

This will resize partition 1 on /dev/vda.

Validate the change.

$ lsblk 
 NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
 sr0     11:0    1 1024M  0 rom  
 vda    253:0    0   30G  0 disk 
 └─vda1 253:1    0   30G  0 part /

Step 4: Resize ‘/’ partition to fill all space

The last step is to resize the file system to grow all the way to fill added space

For ext4 file system, use resize2fs

$ sudo resize2fs /dev/vda1
resize2fs 1.42.9 (28-Dec-2013)
 Filesystem at /dev/vda1 is mounted on /; on-line resizing required
 old_desc_blocks = 2, new_desc_blocks = 4
 The filesystem on /dev/vda1 is now 7864059 blocks long.

If your filesystem is XFS, it can be grown while mounted using the xfs_growfs command:

sudo xfs_growfs /

Confirm new size using df -h

$ df -hT | grep /dev/vda
/dev/vda1      ext4       30G  1.2G   27G   5% /

Congratulations!, you have successfully resized an ext2/3/4 or XFS root partition on Linux without LVM.

Go to system/startup.php and find following lines of code:

if (!ini_get('date.timezone')) {
	date_default_timezone_set('UTC');
}

Replace with following lines of code by changing to your timezone

date_default_timezone_set('Australia/Sydney');

Synchronize PHP and Database Timezone

The query we use to set database timezone if you are super admin is below:

SET time_zone='offset';

But everyone has no super admin access so need to change in the code level. For that go to system/library/db/mysqli.php if you are using MySQLi and add code below after $this->connection->query(“SET SQL_MODE = ””);

$dt = new \DateTime();
$this->connection->query("SET time_zone='" . $dt->format('P') . "';");

With these changes your timezone in Opencart are changed.

Let us know if you find any issues, thanks a lot.

OpenCart is one of the simplest e-commerce platforms to build an online store. OpenCart offers you an ‘easy-to-work-with’ code-base with which you can get an e-Commerce site online, quickly. If you are looking for a safe way to move OpenCart website from one domain to another, follow the process below.

Here are the steps to migrate / move OpenCart website to a new server.

1. Download ALL the files from old server.
2. Create a backup of Database through PhpMyAdmin
3. Upload files to NEW SERVER
4. Install Database on NEW SERVER through PhpMyAdmin
5. Update the configuration files config.php and admin/config.php to reflect your new domain path.

The file should now open up for editing. Here, you will need to edit a few lines of code. Find the lines:

// HTTP

define('HTTP_SERVER', 'http://yourdomain.com/');

// HTTPS

define('HTTPS_SERVER', 'http://yourdomain.com/');

// DIR

define('DIR_APPLICATION','/
home/sites/YOUR-DOMAIN/public_html/catalog/');
define('DIR_SYSTEM','/home/sites/YOUR-DOMAIN/public_html/system/');
define('DIR_DATABASE','/home/sites/YOUR-DOMAIN/public_html/system/database/');
define('DIR_LANGUAGE','/home/sites/YOUR-DOMAIN/public_html/catalog/language/');
define('DIR_TEMPLATE','/home/sites/YOUR-DOMAIN/public_html/catalog/view/theme/');
define('DIR_CONFIG','/home/sites/YOUR-DOMAIN/public_html/system/config/');
define('DIR_IMAGE','/home/sites/YOUR-DOMAIN/public_html/image/');
define('DIR_CACHE','/home/sites/YOUR-DOMAIN/public_html/system/cache/');
define('DIR_DOWNLOAD','/home/sites/YOUR-DOMAIN/public_html/download/');
define('DIR_LOGS','/home/sites/YOUR-DOMAIN/public_html/system/logs/');

You will need to update these to your correct path. Contact your hosting company for the full path to your public folder.

Next, you need to update the database connection settings. Find the code below:

// DB

define('DB_DRIVER','mysql');
define('DB_HOSTNAME','localhost');
define('DB_USERNAME','your-old-opencart-databse-username');
define('DB_PASSWORD','your-old-opencart-databse-password');
define('DB_DATABASE','your-old-opencart-databse-database');
define('DB_PREFIX','oc_');

You will need to replace these with the new details made in step 3;

DB_HOSTNAME = Your database host (usually localhost).
DB_USERNAME = Your Database username.
DB_PASSWORD = Your Database password
DB_DATABASE = Your database name

Once you have updated these, save the changes & you are done.

Method-1: First Check the Timezone in Settings > Store. Make sure you set to UTC.

If you need to change it back you can in the SQL table “oc_setting” column “key” value “config_timezone” in the “value” column change it back to “UTC”

UPDATE oc_setting SET value='UTC' WHERE key = 'config_timezone';

If still issue, follow below method.

Method-2: You need to set your php time and mysql time the same. its deleting cookies to soon. You can fix this.

Open:

system/config/default.php
system/config/catralog.php
system/config/admin.php

Find:

$_[‘session_engine’] = ‘db’;

Replace:

$_[‘session_engine’] = ‘file’;

 

 

Step-1: Add 2 hidden fields to the contact form

[hidden your-first-name id:first-name-p]
[hidden your-last-name id:last-name-p]

Step-2: Write below jquery script in the footer

$("#name_field_id").focusout(function(){
     str = $(this).val();
     if(str){
      s = str.split(/(?<=^\S+)\s/); //split string in name field after first space found. 
      $("#last-name-p").val(s[1]); //s[1] value after the first space set to hidden field.
     }
  });

Output will be list this:-