Author: Sam

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.

Installing Magento 2.4 on Windows 10 can be really frustrating because of all the errors related to configurations. Here is a very simple step by step tutorial to install Magento 2.4, configuring and resolving all the errors that arise in the process. A video-based tutorial is also available if you prefer to watch and follow the steps.

Following are the pre-requisites required for installing Magento. Download the setups of the following.

After downloading the setups, You need to install XAMPP and Composer and follow the steps below.

  • Start Apache and MySQL from XAMPP Control Panel.
  • Navigate to htdocs folder inside XAMPP installation directory.
  • Create a new folder inside htdocs with the name of “elasticsearch”. Paste the downloaded Elasticsearch zip file inside the newly created folder. Extract the zip file, navigate to bin folder, and double click on “elasticsearch.bat” to start elasticsearch cluster.
  • Make sure that elasticsearch is up and running by visiting localhost:9200 by any browser. You should see a JSON object.
  • Now visit localhost/phpmyadmin and create a new database ‘magento
  • Create a new folder inside htdocs with the name of ‘magento’. Paste the Magento zip file, that we downloaded earlier, inside this folder and extract it.
  • Inside your magento directory, navigate to vendor\magento\framework\Image\Adapter and open G2d.php with any code editor. Search for the method named “validateURLScheme”, which should be at line # 86. Replace the entire method code with this code:
  • Inside your magento directory, navigate to vendor\magento\framework\View\Element\Template\File and open Validator.php with any code editor. Scroll down to line # 138. Replace the entire line with the following snippet:
  • Inside your magento directory, navigate to vendor\magento\framework\Interception and open PluginListGenerator.php with any code editor. Scroll down to line # 158. Replace the entire line with the following snippet:
  • Inside your XAMPP installation directory, navigate to xampp/php and open php.ini with any code editor. Enable the extensions intl, soap, sockets, xsl on line 921, 943, 944, 949 respectively by removing semi-colon before the word extension. Now restart xampp.
  • Inside your magento directory, open cmd and run the following commands in order. If any command gives an error, make sure your PHP version is 7.3 or greater and you’ve made all the changes mentioned above.
  • We are nearly there. Open localhost/phpmyadmin and switch to database ‘magento’. Now the run the following query in the SQL Query tab:
  • Open localhost/magento/admin in any browser and login using ‘admin’ and ‘admin123’ as username and password respectively. After logging in, if the loader does not disappear and keeps on loading then there is one more change you need to make. Inside your magento directory, navigate to app/etc/di.xml and search for

and replace it with

  • Now refresh the page and voila, you have installed Magento 2.4 successfully! Phew, that was a lot of work.

If you got stuck at any point, there is a video tutorial available and you can watch it for a reference.

How to install the extension

  1. Backup your store’s database and web directory.
  2. Login to your server’s SSH console and navigate to the root directory of the Magento 2 store.
  3. Copy the installation instructions from the page My Downloadable Products to the SSH console and press ENTER.
  4. Run command php -f bin/magento module:enable Mirasvit_Core Mirasvit_Related to enable the extension.
  5. Run command php -f bin/magento setup:upgrade to install the extension.
  6. Run command php -f bin/magento cache:clean to clean the cache.
  7. Deploy static view files

    rm -rf pub/static/*; rm -rf var/view_preprocessed/*; php -f bin/magento setup:static-content:deploy

  8. Run command php -f bin/magento indexer:reindex mst_related_index to reindex extension-related data.
  9. Make sure that the native Magento cron job is configured and working correctly. The Related Products for Magento 2 extension runs all tasks in cron.

“(Magento\Framework\Exception\NoSuchEntityException): The attribute with a “sw_menu_block_top_content” attributeCode doesn’t exist. Verify the attribute and try again.”

Remove modulde Smartwave_megamenu from table setup_module on database and ran

$ php -f bin/magento setup:upgrade
$ php -f bin/magento setup:di:compile

 

Disabling the Extension

Temporarily Disable

To temporarily disable the extension please follow these steps:

  1. Login to your server’s SSH console and navigate to the root directory of the Magento 2 store.
  2. Run command php -f bin/magento module:disable Mirsvit_Related to disable the extension.
  3. Log in to the Magento backend and refresh the store cache (if enabled).

Removing the Extension

To uninstall the extension, please follow these steps:

  1. Login to your server’s SSH console and navigate to the root directory of the Magento 2 store.
  2. Run the command composer remove mirasvit/module-related to remove the extension.
  3. Log in to the Magento backend and refresh the store’s cache (if enabled).

To upgrade the extension, follow these steps:

  1. Backup your store’s database and web directory.
  2. Login to your server’s SSH console and navigate to the root directory of the Magento 2 store.
  3. Run command composer require mirasvit/module-related:* --update-with-dependencies to update current extension with all dependencies.

    Note

    There are some cases when the command above is not applicable; it is not possible when updating the current module; neither will it be applicable when upgrading all the Mirasvit modules in a bundle. In this case, the command above will be of no effect. 

    Run instead composer update mirasvit/* command. It will update all Mirasvit modules installed in your store.

  4. Run command php -f bin/magento module:enable Mirasvit_Core Mirasvit_Related to enable the extension.
  5. Run command php -f bin/magento setup:upgrade to install updates.
  6. Run command php -f bin/magento cache:clean to clean the cache.
  7. Deploy static view files

    rm -rf pub/static/*; rm -rf var/view_preprocessed/*; php -f bin/magento setup:static-content:deploy

  8. Run command php -f bin/magento indexer:reindex mst_related_index to reindex the data related to the Related Products for Magento 2 extension.

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