• Skip to main content
  • Skip to primary sidebar

Code Inherit

Simple Programming Code Examples

Bijoy Converter

14th October 2025 by Site Admin Leave a Comment

Bijoy Converter

💡 Need more tools? Try our Bengali Typing Test or Unicode Keyboard

Powered by ConverterAZ

Filed Under: Uncategorised

How to amend previous commit with current changes in git and github?

17th September 2024 by Site Admin Leave a Comment

f you change a page’s text and want to merge it with the previous commit (i.e., not create a new commit but update the existing one), you can follow these steps:

1. Make the Changes

Make the changes you want to the file(s), such as updating the text on the page.

2. Stage the Changes

Stage the changes you just made using:

git add <file>
Replace <file> with the name of the file you modified, or use . to stage all modified files:

git add .

3. Amend the Previous Commit

Now, instead of creating a new commit, you will amend the previous one:

git commit –amend –no-edit

• –no-edit: This flag keeps the previous commit message intact while including your newly staged changes in the previous commit.

4. Push the Amended Commit

Since you are modifying a commit that has already been pushed to GitHub, you will need to force-push the changes:

git push –force

mportant Notes:

• Force-pushing rewrites the history of your repository, so be cautious if you’re working with others, as they will need to pull and reset their branches accordingly.

Filed Under: Uncategorised

How to install PHP 8.1 alongside PHP 7.4 using HomeBrew in MacOs?

7th September 2024 by Site Admin Leave a Comment

To install PHP 8 alongside PHP 7.4 and have it in a sibling directory (e.g., /opt/homebrew/etc/php/8.0 or /opt/homebrew/etc/php/8.1), follow these steps:

1. Add the shivammathur/php Tap:

First, you need to add the shivammathur/php tap to access older PHP versions, including PHP 8.x.

brew tap shivammathur/php

2. Install PHP 8.1 (or PHP 8.0):

To install PHP 8.1, use the following command:

brew install shivammathur/php/php@8.1

This will install PHP 8.1 and place its configuration and binaries in a sibling directory to PHP 7.4, such as /opt/homebrew/etc/php/8.1.

If you prefer PHP 8.0, run:

brew install shivammathur/php/php@8.0

3. Check the Installation Location:

You can check where PHP 8 is installed with the following:

brew info php@8.1

This will show you the location of PHP 8.1, which should be something like /opt/homebrew/etc/php/8.1 if you are using Homebrew installed in /opt/homebrew.

4. Switch Between Versions:

You can now use the brew unlink and brew link commands to switch between PHP 7.4 and PHP 8.

  • To switch to PHP 8.1:
  • brew unlink php@7.4
  • brew link php@8.1 --force --overwrite
  • To switch back to PHP 7.4:
  • brew unlink php@8.1
  • brew link php@7.4 --force --overwrite

Now, PHP 7.4 and PHP 8.x will reside in sibling directories, and you can easily switch between them.

Filed Under: Uncategorised

Create a shell script to switch 7.4 to 8.1 and vice versa

7th September 2024 by Site Admin Leave a Comment

Here’s a shell script that you can use to easily switch between PHP 7.4 and PHP 8.1 on macOS when using Homebrew. The script will handle unlinking the current PHP version, linking the desired one, and restarting Apache to apply the change.

Script: switch_php.sh

#!/bin/bash

# Function to switch PHP versions
switch_php() {
local version=$1
if [ "$version" == "7.4" ]; then
echo "Switching to PHP 7.4..."
brew unlink php@8.1
brew link php@7.4 --force --overwrite
sudo sed -i '' 's|php@8.1|php@7.4|' /opt/homebrew/etc/httpd/httpd.conf
elif [ "$version" == "8.1" ]; then
echo "Switching to PHP 8.1..."
brew unlink php@7.4
brew link php@8.1 --force --overwrite
sudo sed -i '' 's|php@7.4|php@8.1|' /opt/homebrew/etc/httpd/httpd.conf
else
echo "Invalid PHP version specified. Please choose 7.4 or 8.1."
exit 1
fi

# Restart Apache to reflect the change
echo "Restarting Apache..."
sudo brew services restart httpd

# Verify the PHP version
echo "Current PHP version:"
php -v
}

# Check if a version argument was provided
if [ -z "$1" ]; then
echo "Usage: $0 [7.4|8.1]"
exit 1
fi

# Call the switch_php function with the desired version
switch_php "$1"

Steps to Use the Script:

  1. Create the Script File: Save the script as switch_php.sh in your desired location, such as your home directory:bashCopy codenano ~/switch_php.sh Paste the script content, then save and exit.
  2. Make the Script Executable: Make the script executable by running:bashCopy codechmod +x ~/switch_php.sh
  3. Switch PHP Versions:
    • To switch to PHP 7.4: ~/switch_php.sh 7.4
    • To switch to PHP 8.1: ~/switch_php.sh 8.1

This script will update Apache’s configuration to use the correct PHP version and restart Apache automatically.

Disable the Old PHP Module (PHP 7.4):

Find the line that loads PHP 7.4 and comment it out. It will look something like this:

#LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so

You can comment it out by adding a # at the beginning of the line.

Enable the PHP 8.1 Module:

Now, add or uncomment the line to load PHP 8.1. It should look something like this:

LoadModule php_module /opt/homebrew/opt/php@8.1/lib/httpd/modules/libphp.so

If the line doesn’t exist, you can add it manually to point to PHP 8.1.

Restart Apache:

After updating the configuration, restart Apache to apply the changes:

sudo brew services restart httpd

Verify PHP 8.1 is Active in Apache:

Create a PHP file in your web server’s document root (usually /opt/homebrew/var/www/ or similar). Create a file called info.php with the following content:

<?php phpinfo(); ?>

Visit http://localhost/info.php in your browser, and you should see the PHP 8.1 information page.

This will make Apache use PHP 8.1 for handling .php files! Let me know if you run into any issues.

Filed Under: Uncategorised

How to reflect PHP8.1 to Apache in MacOS?

7th September 2024 by Site Admin Leave a Comment

To reflect PHP 8.1 in Apache on macOS, follow these steps after installing PHP 8.1 via Homebrew:

1. Update Apache Configuration:

Open the Apache configuration file to update the PHP module. On macOS, the configuration file is usually located at /opt/homebrew/etc/httpd/httpd.conf if you’re using Homebrew-installed Apache.

Edit the file:

sudo nano /opt/homebrew/etc/httpd/httpd.conf

2. Disable the Old PHP Module (PHP 7.4):

Find the line that loads PHP 7.4 and comment it out. It will look something like this:

#LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so

You can comment it out by adding a # at the beginning of the line.

3. Enable the PHP 8.1 Module:

Now, add or uncomment the line to load PHP 8.1. It should look something like this:
LoadModule php_module /opt/homebrew/opt/php@8.1/lib/httpd/modules/libphp.so

If the line doesn’t exist, you can add it manually to point to PHP 8.1.

4. Update the DirectoryIndex:

Ensure that Apache knows to look for PHP files by updating the DirectoryIndex directive. Find the line that starts with DirectoryIndex and ensure it includes index.php:

DirectoryIndex index.php index.html

5. Set the PHP Handler (Optional):

Make sure that Apache uses PHP to handle .php files by adding the following lines:

<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>

6. Restart Apache:

After updating the configuration, restart Apache to apply the changes:

sudo brew services restart httpd

7. Verify PHP 8.1 is Active in Apache:

Create a PHP file in your web server’s document root (usually /opt/homebrew/var/www/ or similar). Create a file called info.php with the following content:

<?php phpinfo(); ?>

Visit http://localhost/info.php in your browser, and you should see the PHP 8.1 information page.

This will make Apache use PHP 8.1 for handling .php files! Let me know if you run into any issues.

Filed Under: Uncategorised

How to link PHP 7.4 with Apache in Mac OS?

7th September 2024 by Site Admin Leave a Comment


Since your Apache configuration file is located at /opt/homebrew/etc/httpd/httpd.conf, follow these steps to enable PHP 7.4:

Step 1: Edit the Apache Configuration File

1. Open the configuration file:

sudo nano /opt/homebrew/etc/httpd/httpd.conf

2. Load the PHP 7.4 Module:

In the httpd.conf file, search for any existing LoadModule php lines (press Ctrl + W in nano to search) and either comment them out or replace them with the following line to load the PHP 7.4 module from Homebrew:

LoadModule php7_module /opt/homebrew/opt/php@7.4/lib/httpd/modules/libphp7.so

3. Add PHP Handling for .php Files:

Ensure that Apache handles .php files correctly by adding or ensuring the following line is present:

AddType application/x-httpd-php .php

4. Update Directory Index:

Make sure Apache serves PHP files as the default when accessing a directory. Find the line that starts with DirectoryIndex and ensure it includes index.php:

DirectoryIndex index.php index.html

Step 2: Restart Apache

After making the changes, restart Apache to apply the new settings:

sudo apachectl restart

Step 3: Test PHP 7.4

To verify that PHP 7.4 is running:

1. Navigate to your web root directory (this is usually /opt/homebrew/var/www/):

cd /opt/homebrew/var/www/


2. Create a test PHP file:

sudo nano info.php


3. Add the following PHP code:

<?php phpinfo(); ?>


4. Visit http://localhost/info.php in your browser. You should see the PHP information page, confirming that PHP 7.4 is correctly set up.

==========================================================================

sudo apachectl restart          

AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using Mds-MacBook-Pro-2.local. Set the ‘ServerName’ directive globally to suppress this message

The message you are seeing is a common Apache warning and doesn’t usually affect the functionality of the server. However, you can suppress it by setting the ServerName directive in your Apache configuration file. Here’s how you can fix this:

Step 1: Edit the Apache Configuration File

1. Open the Apache configuration file for editing:

sudo nano /opt/homebrew/etc/httpd/httpd.conf

2. Set the ServerName Directive:

Look for a place near the top of the configuration file, or search for an existing ServerName directive. If you don’t find one, add the following line to set the ServerName to localhost:

ServerName localhost


Step 2: Restart Apache

sudo apachectl restart

Step 1: Set Up the Virtual Host

To set up virtual hosts on macOS with Apache, follow these steps:

Step 1: Edit the Apache Configuration File

1. Open the Apache configuration file (httpd.conf):

sudo nano /opt/homebrew/etc/httpd/httpd.conf


It should now look like this:

Include /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf

sudo nano /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf

<VirtualHost *:8080>

ServerAdmin webmaster@mysite.test

DocumentRoot “/Users/mdanwarhossain/Sites/mysite”

ServerName mysite.test

ErrorLog “/private/var/log/apache2/mysite-error_log”

CustomLog “/private/var/log/apache2/mysite-access_log” common

<Directory “/Users/mdanwarhossain/Sites/mysite”>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

======================


1. Open the /etc/hosts file to map your local domain to localhost:

sudo nano /etc/hosts

127.0.0.1 mywebsite.test
127.0.0.1 anotherwebsite.test
127.0.0.1 mysite.test

sudo chmod -R 755 ~/Sites/

sudo apachectl restart

Forbidden
You don’t have permission to access this resource.

sudo chmod -R 755 /Users/yourusername/Sites/mysite

tail -f /private/var/log/apache2/mysite-error_log


AH00035: access to / denied (filesystem path ‘/Users/mdanwarhossain/Sites’) because search permissions are missing on a component of the path

sudo chmod +x /Users/mdanwarhossain

sudo chmod -R 755 /Users/mdanwarhossain/Sites

sudo apachectl restart


Link navigation showing not found

sudo nano /opt/homebrew/etc/httpd/httpd.conf

LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L]

sudo nano /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf


ServerAdmin webmaster@mysite.test
DocumentRoot “/Users/mdanwarhossain/Sites/mysite”
ServerName mysite.test
ErrorLog “/private/var/log/apache2/mysite-error_log”
CustomLog “/private/var/log/apache2/mysite-access_log” common

<Directory "/Users/mdanwarhossain/Sites/mysite">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

sudo apachectl restart

Filed Under: Uncategorised

  • Page 1
  • Page 2
  • Page 3
  • Interim pages omitted …
  • Page 7
  • Go to Next Page »

Primary Sidebar

Recent Posts

  • Bijoy Converter
  • How to amend previous commit with current changes in git and github?
  • How to install PHP 8.1 alongside PHP 7.4 using HomeBrew in MacOs?
  • Create a shell script to switch 7.4 to 8.1 and vice versa
  • How to reflect PHP8.1 to Apache in MacOS?

Recent Comments

    Archives

    • October 2025
    • September 2024
    • January 2024
    • July 2023
    • October 2021
    • September 2021
    • February 2021
    • January 2021
    • October 2020
    • September 2020
    • August 2020
    • May 2020
    • March 2020
    • February 2020
    • January 2020
    • November 2019
    • May 2019

    Categories

    • Couchbase
    • Cron Job
    • dhis2
    • Linux, MySQL
    • MySQL
    • Oracle
    • Oracle Client
    • PHP
    • SSL
    • Subdomain
    • Uncategorised
    • Wordpress
    • WP
    • Zip

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org

    Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in