# php_download **Repository Path**: leisore/php_download ## Basic Information - **Project Name**: php_download - **Description**: A simlpe file download page based php and mod_xsendfile. - **Primary Language**: PHP - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-06-30 - **Last Updated**: 2023-07-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README A simlpe file download page based php and mod_xsendfile. # test env ```shell [root@bogon ~]# uname -a Linux bogon 4.18.0-240.el8.x86_64 #1 SMP Fri Sep 25 19:48:47 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux ``` # install ali yum repod ```shell [root@bogon ~]# cd /etc/yum.repos.d/ [root@bogon ~]# curl https://mirrors.aliyun.com/repo/Centos-8.repo -o Centos-8.repo ``` # install httpd ```shell [root@bogon ~]# yum install -y httpd.x86_64 [root@bogon ~]# yum install -y httpd-devel.x86_64 [root@bogon ~]# yum install -y php.x86_64 [root@bogon ~]# yum install -y gcc [root@bogon ~]# yum install -y redhat-rpm-config [root@linux8 ~]# httpd -v Server version: Apache/2.4.37 (centos) Server built: Nov 12 2021 04:57:27 ``` # install mod_xsendfile ```shell [root@bogon ~]# wget https://tn123.org/mod_xsendfile/mod_xsendfile-0.12.tar.gz [root@bogon ~]# tar xvzf mod_xsendfile-0.12.tar.gz [root@bogon ~]# cd mod_xsendfile-0.12 [root@bogon ~]# apxs -cia mod_xsendfile.c ``` # install php ```shell [root@linux8 ~]# yum install -y php.x86_64 [root@linux8 ~]# yum -y install php-gd [root@linux8 ~]# php -v PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies ``` # config httpd >> /etc/httpd/conf/httpd.conf ``` XSendFile On Options FollowSymLinks AllowOverride None Require all Order allow,deny deny from all ``` # config php >> /etc/php.ini ``` display_errors = on error_reporting = E_ALL html_errors = on log_errors = on ``` # deploy php 1. copy the php files of this project into /var/www/html/ 2. the target download files located /var/www/html/download by default # config download in index.php ```php // download dir $downloadDir = '/var/www/html/download'; // download logs dir $downloadLogDir = '/var/www/html/download_logs'; ``` # start httpd ```shell [root@bogon ~]# mkdir /var/www/html/download_logs/ [root@bogon ~]# chown -R apache:apache /var/www/html/download_logs/ [root@bogon ~]# chcon -R -t httpd_sys_rw_content_t /var/www/html/download_logs/ [root@bogon ~]# systemctl stop firewalld [root@bogon ~]# systemctl start httpd ``` # visit >>http://ip