top of page

How to Install and Run XAMPP on a Linux Virtual Machine

6月 19

讀畢需時 4 分鐘

0

2

0

Are you looking to set up XAMPP on your Linux virtual machine? This comprehensive guide will walk you through the steps to download, install, and run XAMPP, ensuring your development environment is up and running smoothly. Let’s dive in!

Step 1: Download XAMPP Installation File

First things first, you need to download the XAMPP installation file. We’ll use the wget command for this purpose.


wget https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/8.2.12/xampp-linux-x64-8.2.12-0-installer.run/download

Step 2: Verify the Downloaded File

After downloading, ensure the file is in your current directory. Use the ls command to list files and check its presence.


ls

Look for download in the output. If it appears as download and not xampp-linux-x64-8.2.12-0-installer.run, it means the file is named download due to direct saving in the home directory.

Step 3: Change File Permissions

Next, let’s change the permissions of the downloaded file to make it executable.

  1. Navigate to your home directory:


cd ~
  1. Change the file permissions:


chmod +x download

Step 4: Run the Installation Program

With the file permissions updated, you can now run the installation program with administrative privileges.


sudo ./download

Step 5: Start XAMPP

Once the installation is complete, start XAMPP with the following command:


sudo /opt/lampp/lampp start

Step 6: Verify XAMPP Installation

To ensure XAMPP is running correctly, open a web browser and navigate to:

You should see the XAMPP welcome page.


Step 7: Accessing XAMPP on Google Cloud

If you’re using a Google Cloud instance, follow these steps to access the XAMPP welcome page:

  1. Make sure XAMPP is running:


sudo /opt/lampp/lampp start
  1. In Google Cloud Console, go to VPC Network -> Firewall.

  2. Click Create Firewall Rule and configure as follows:

  3. Name: Choose a descriptive name, e.g., allow-http-https.

  4. Targets: Select All instances in the network.

  5. Source IP Ranges: Enter 0.0.0.0/0 to allow traffic from any IP.

  6. Protocols and Ports: Select Specified protocols and ports, then check tcp and enter 80, 443.

  7. Click Create to set up the firewall rule.

  8. Find your instance's external IP address in Google Cloud Console's VM instances page.

  9. Open your web browser and enter:

your_server_ip

Replace your_server_ip with your actual external IP address. You should see the XAMPP welcome page.

Note: Allowing traffic from 0.0.0.0/0 opens your web server to anyone. For production environments, it’s recommended to restrict access to specific IP addresses for security reasons.

FAQs

Q1: What is XAMPP? A1: XAMPP is a free and open-source cross-platform web server solution stack package developed by Apache Friends, consisting mainly of the Apache HTTP Server, MariaDB database, and interpreters for scripts written in the PHP and Perl programming languages.

Q2: Can I install XAMPP on any Linux distribution? A2: Yes, XAMPP can be installed on various Linux distributions like Ubuntu, Fedora, Debian, etc.

Q3: Why do I need to change file permissions with chmod? A3: The chmod command is used to change the access permissions of files and directories. Making the downloaded file executable allows it to be run as a program.

Q4: How do I stop XAMPP? A4: To stop XAMPP, use the following command:


sudo /opt/lampp/lampp stop

Q5: Can I access XAMPP remotely without adjusting firewall rules? A5: No, you need to configure firewall rules to allow remote access to your XAMPP server.

Wrapping Up

And there you have it! A step-by-step guide to installing and running XAMPP on a Linux virtual machine. By following these instructions, you’ll have a fully functional development environment in no time. Happy coding!

For any questions or further assistance, feel free to drop a comment below.

How to Upload and Manage PHP Files on XAMPP in Linux

Setting up a web development environment on a Linux server using XAMPP can streamline your workflow. This guide will walk you through the steps to upload PHP files to your server, move them to the appropriate directory, and manage permissions to ensure your web server runs smoothly.

Step 1: Upload PHP Files to Your Server

To run PHP files in your XAMPP environment, you need to place them in the web server’s document root directory. For XAMPP, the default document root is /opt/lampp/htdocs. Here’s how you can upload your PHP files to your Google Cloud instance:

Use the scp (secure copy) command to upload files:


scp /path/to/local/file.php username@instance_ip:/path/on/server

Replace /path/to/local/file.php with the path to your local PHP file, username with your Google Cloud instance’s username, and instance_ip with the instance's IP address.

Step 2: Move Files to XAMPP's Document Root

Once the files are uploaded to your server, move them to the XAMPP document root directory. Use the following commands to move the files:


sudo mv /path/on/server/file.php /opt/lampp/htdocs/
sudo mv /path/on/server/tiktok-shop-integration.php /opt/lampp/htdocs/

Step 3: Set File Permissions

Ensure the web server has read permissions for the uploaded files. Use the chmod command to set the appropriate permissions:


sudo chmod 644 /opt/lampp/htdocs/callback.php
sudo chmod 644 /opt/lampp/htdocs/tiktok-shop-integration.php

Step 4: Access the PHP Files

You can now access the PHP files via your web browser. Enter the following URLs, replacing your_server_ip with your Google Cloud instance’s external IP address:

Additional Tips:

  • Check for Syntax Errors: Ensure your PHP files are free of syntax errors. You can check this by running:


/opt/lampp/bin/php -l /opt/lampp/htdocs/callback.php
  • Permission Denied Errors: If you encounter "permission denied" errors when accessing PHP files, double-check the file permissions to ensure the web server can read them.

  • Security Measures: In a production environment, implement additional security measures such as proper access control, input validation, and error handling to protect your PHP applications.

Creating and Managing the tsp Directory in htdocs

To organize your files, create a new directory named tsp in the htdocs directory and move your files there:

  1. Navigate to htdocs:


cd /opt/lampp/htdocs
  1. Create the tsp Directory:


sudo mkdir tsp
  1. Move Files to tsp Directory:

  • sh 复制代码 sudo mvtsp/

  1. To move all files and subdirectories, use:


sudo mv ./* tsp/
  1. Verify the Files Have Been Moved:


ls tsp
  1. This command lists the contents of the tsp directory, ensuring all files have been moved successfully.

Conclusion

By following these steps, you can efficiently upload and manage PHP files on a Linux server using XAMPP. This setup ensures your development environment is organized, secure, and ready for use. For any questions or further assistance, feel free to drop a comment below.

6月 19

讀畢需時 4 分鐘

0

2

0

留言

Share Your ThoughtsBe the first to write a comment.
bottom of page