Après avoir essayé et reçu 403 erreurs interdites:
http://localhost/ Forbidden You don't have permission to access / on this server. Apache/2.4.7 (Ubuntu) Server at localhost Port 80
J’ai finalement vérifié l’ apachectl -S
et réalisé que l’emplacement du dossier hôte local n’était pas correctement défini:
$ apachectl -S Main DocumentRoot: "/var/www" Main ErrorLog: "/var/log/apache2/error.log" Mutex default: dir="/var/lock/apache2" mechanism=fcntl Mutex mpm-accept: using_defaults Mutex watchdog-callback: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 not_used Group: name="www-data" id=33 not_used
Il est clair que mon dossier localhost est / var / www alors que mon paramètre est autre chose:
/etc/apache2/sites-available/mynewsite.conf
ServerAdmin webmaster@localhost DocumentRoot /home/user/www ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
Et
/etc/apache2/apache2.conf
Mutex file:${APACHE_LOCK_DIR} default PidFile ${APACHE_PID_FILE} Timeout 300 KeepAlive On MaxKeepAliveRequests 100 KeepAliveTimeout 5 User ${APACHE_RUN_USER} Group ${APACHE_RUN_GROUP} HostnameLookups Off ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn IncludeOptional mods-enabled/*.load IncludeOptional mods-enabled/*.conf Include ports.conf Options FollowSymLinks AllowOverride None Require all denied AllowOverride None Require all granted Options Indexes FollowSymLinks AllowOverride None Require all granted AccessFileName .htaccess Require all denied LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %O" common LogFormat "%{Referer}i -> %U" referer LogFormat "%{User-agent}i" agent IncludeOptional conf-enabled/*.conf IncludeOptional sites-enabled/*.conf ServerName localhost
Pour l’autorisation de fichier:
$ ls -la /home/user/ total 3097944 drwx------ 9 user user 4096 Jan 3 19:28 . drwxr-xr-x 45 user user 4096 Jan 3 20:46 .. drwxr-xr-x 48 user www-data 4096 Jan 3 20:30 www
Le redémarrage d’Apache n’a pas de problème aussi:
$ sudo service apache2 restart * Restarting web server apache2 [ OK ]
Je me demande ce qui ne va pas
Vous devez faire un chmod a+x /home/user/
, puisque www-data ne pourra pas accéder à /home/user/www/
if /home/user/
ne sera pas accessible.