PHP installation guide on Kali Linux

 

from Gemini

 

Setting up PHP 8.2 on Kali Linux involves configuring it for your web server (usually Apache) and ensuring the command line interface (CLI) is using the correct version.

Since you've already installed it, here are the steps to finalize the configuration:


1. Set PHP 8.2 as the Default CLI Version

If you have multiple versions of PHP installed, Kali might still be pointing to an older one.

Bash
 
sudo update-alternatives --config php

Select the number corresponding to /usr/bin/php8.2. Verify with:

Bash
 
php -v

2. Configure PHP 8.2 for Apache

To let Apache handle PHP files using version 8.2, you need to enable the specific module.

 

 

  1. Install the Apache module (if not already done):

    Bash
     
    sudo apt install libapache2-mod-php8.2
    
  2. Disable old versions (e.g., if 8.1 was active):

     

     

    Bash
     
    sudo a2dismod php8.1
    
    
3.  **Enable PHP 8.2**:
    ```bash
    sudo a2enmod php8.2
    ```
4.  **Restart Apache** to apply changes:
    ```bash
    sudo systemctl restart apache2
    ```

### 3. Install Essential Extensions
For penetration testing or web development, you’ll likely need common modules (like MySQL support or MBString):
```bash
sudo apt install php8.2-{common,mysql,xml,xmlrpc,curl,gd,imagick,cli,dev,imap,mbstring,opcache,soap,zip,intl}

4. Verify the Setup

Create a test file in your web root to confirm Apache and PHP are communicating:

Bash
 
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Visit http://localhost/info.php in your browser.

Note: For security, delete this file once you've confirmed it works: sudo rm /var/www/html/info.php.

5. Common Configuration Files

If you need to adjust memory limits or upload sizes, the configuration files are located at:

  • CLI: /etc/php/8.2/cli/php.ini

  • Apache: /etc/php/8.2/apache2/php.ini


Summary Checklist

Task Command
Check Version php -v
Enable Module sudo a2enmod php8.2
Config Path /etc/php/8.2/
Restart Webserver

sudo systemctl restart apache2

 

 

 

posted @ 2026-05-05 02:35  profesor  阅读(5)  评论(0)    收藏  举报