Linux搭建PHP镜像站
搭建前的准备
yum -y --nogpgcheck install rsync创建源码目录
useradd www mkdir -p /www/php-web chown -R www:www /www/php-web获取镜像站源码(时间较长)
su www cd /www/php-web # 先获取小文件 /usr/bin/rsync -avzC --timeout=600 --delete --delete-after --exclude='distributions/*' ASIA.RSYNC.PHP.NET::phpweb /www/php-web # 再获取全部文件 /usr/bin/rsync -avzC --timeout=600 --delete --delete-after --include='distributions/*' ASIA.RSYNC.PHP.NET::phpweb /www/php-web定期更新镜像站源码(计划任务)
su www crontab -e 5 21 * * * /usr/bin/rsync -avzC --timeout=600 --delete --delete-after --include='distributions/*' ASIA.RSYNC.PHP.NET::phpweb /www/php-web ESC :wq修改nginx配置
server { listen 80; server_name php.xxx.com; root /www/php-web; index index.php index.html; location / { try_files $uri $uri/ $uri.php; } location ~* \.php { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }购买并备案域名
修改DNS解析到镜像站