Bijoy Converter
💡 Need more tools? Try our Bengali Typing Test or Unicode Keyboard
Powered by ConverterAZ
Simple Programming Code Examples
💡 Need more tools? Try our Bengali Typing Test or Unicode Keyboard
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.
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:
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
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
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.
You can now use the brew unlink and brew link commands to switch between PHP 7.4 and PHP 8.
brew unlink php@7.4brew link php@8.1 --force --overwritebrew unlink php@8.1brew link php@7.4 --force --overwriteNow, PHP 7.4 and PHP 8.x will reside in sibling directories, and you can easily switch between them.
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.
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"
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.chmod +x ~/switch_php.sh~/switch_php.sh 7.4~/switch_php.sh 8.1This script will update Apache’s configuration to use the correct PHP version and restart Apache automatically.
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.
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.
After updating the configuration, restart Apache to apply the changes:
sudo brew services restart httpd
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.
To reflect PHP 8.1 in Apache on macOS, follow these steps after installing PHP 8.1 via Homebrew:
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
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.
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.
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
Make sure that Apache uses PHP to handle .php files by adding the following lines:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
After updating the configuration, restart Apache to apply the changes:
sudo brew services restart httpd
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.
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