简体   繁体   中英

XAMPP - How can I execute PHP files from home directory?

I've installed XAMPP on my Linux computer and server and database are running. Now I have a question how to execute my existing PHP-Files from /home path?

So far I have saved all of my PHP files in ./home directory (eg /home/Path-to-PHP-Files/Development_01/....php ) and until now I have uploaded them with FTP to server. In order to save myself from constant uploading, I thought that usage with XAMPP is faster and more elegant.

I found out that XAMPP apparently wants to save the PHP files in /opt/lampp/htdocs directory. Unfortunately I can neither call my PHP files from .home -directory in browser nor can I copy them to /opt/lampp/htdocs because this path is read-only. How can I configure XAMPP to make my PHP files run in /home directory?

Change the DocumentRoot in your virtual hosts file, then restart XAMPP. Here is an example:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/home/Path-to-PHP-Files/Development_01/"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
    <Directory C:/home/Path-to-PHP-Files/Development_01/> # or a linux path
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM