Current Location: Home> Latest Articles> Comprehensive Guide to Configuring PHP with XAMPP on Linux for Quick Development Setup

Comprehensive Guide to Configuring PHP with XAMPP on Linux for Quick Development Setup

gitbox 2025-08-04

Guide to Setting Up PHP Environment with XAMPP on Linux

Using XAMPP to set up a PHP development environment on Linux is an efficient and convenient choice. This article provides a complete configuration process to help you easily build your PHP environment and improve development efficiency.

Introduction to XAMPP

XAMPP is a free, open-source, cross-platform web server package that integrates Apache HTTP Server, MariaDB database, PHP, and Perl. With XAMPP, users can quickly create a local server environment, facilitating web application development and testing.

Steps to Install XAMPP

To install XAMPP on Linux, first download the installation package from the official website. After downloading, assign execution permissions and run the installer using the following commands:

sudo chmod +x xampp-linux-x64-*.run
sudo ./xampp-linux-x64-*.run

Then follow the installation wizard prompts to complete the setup.

Basic PHP Configuration

After installation, you need to perform some basic PHP configurations to optimize usage. The PHP configuration file is usually located at /opt/lampp/etc/php.ini.

Editing the php.ini File

Use the following command to open the configuration file for editing:

<span class="fun">sudo nano /opt/lampp/etc/php.ini</span>

Inside the file, you can adjust the following common settings as needed:

Enable Error Reporting

To facilitate debugging and troubleshooting, it is recommended to enable error reporting by modifying these parameters:

error_reporting = E_ALL
display_errors = On

Adjust Upload File Size Limits

If you need to upload larger files, increase the file upload and POST data size limits by changing the following parameters:

upload_max_filesize = 20M
post_max_size = 20M

Restart XAMPP Service to Apply Changes

After completing configuration, restart the XAMPP service with the following command:

<span class="fun">sudo /opt/lampp/lampp restart</span>

Advanced PHP Configuration

Beyond basic settings, you can enable advanced features according to your project needs.

Enable PDO Extension

PDO provides a consistent interface for accessing databases in PHP. It is recommended to enable it by uncommenting the following lines in php.ini:

extension=pdo.so
extension=pdo_mysql.so

Set Timezone

To ensure correct execution of time-related functions, set the timezone, for example, to Shanghai timezone:

<span class="fun">date.timezone = "Asia/Shanghai"</span>

Summary

By following these steps, you can successfully install and configure the PHP environment with XAMPP on Linux. Proper configuration helps improve development efficiency and application performance. If you encounter configuration issues, it is advisable to consult official documentation or relevant technical forums for assistance. Happy coding!