由于上传的文件的所有者为 root ,Apache 无法正常写入,所以需要设置上传文件的宿主为 www-data。
使用putty登录vps执行如下命令,设置 /var/www下的所有文件的宿主都是 www-data,这样apache2就可以正常读写:
chown -R www-data:www-data /var/www
/etc/init.d/apache2 restart
执行结果如下所示:
root@241541:~# chown -R www-data:www-data /var/www
root@241541:~# /etc/init.d/apache2 restart
* Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 0.3.175.133 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 0.3.175.133 for ServerName
[ OK ]