Problem with Ubuntu Apahce2.4 unable to access the JS directory has been resolved

  • 2020-05-27 08:03:34
  • OfStack

Problem description

Today, I debugged a project. The project is located in the javascript directory under webroot. In any case, it is set to 403 You don t have permission to access /javascript/ on this server.

Thinking process

First reaction 1, Google made an error You don't have permission to access /javascript/ on this server. "And found that most of the answers referred to the Directory Settings in the configuration file. Such as


<Directory />
 Options FollowSymLinks
 AllowOverride All
 Order deny,allow
 Allow from all
</Directory>

But I can't access the whole webroot, all other folders can be accessed, is the directory javascript folder has no permission to access, my setting is


<Directory /home/hfx/workspace/>
  Options Indexes FollowSymLinks
#  AllowOverride None
  AllowOverride All
  Require all granted
</Directory>

So there's no problem in principle, just the javascript directory can't be accessed, and I tried to reset the permissions on the javascript directory


chmod 777 -R javascript

I tried changing javascript to javaScript or creating a new folder with another name that was accessible, so I assumed the problem was that the configuration there prevented the web root path from being javascript.

Found the problem

So I looked at all the apache configuration files, opened the /etc/apache2/ conf-enable/directory, found a configuration file named javascript-common.conf, and opened 1


Alias /javascript /usr/share/javascript/
<Directory "/usr/share/javascript/">
  Options FollowSymLinks MultiViews
</Directory>

I don't know exactly what that means, but I can probably see from the literal meaning that the configuration specifies a single name /javascript to the directory /usr/share/javascript/, and instead of the javascript directory we created in the web root, we should access /javascript to the directory /usr/share/javascript/.

The solution

So google1, javascript-common.conf, that's where a lot of the real issues come in, so there are a lot of real solutions, some of them just modify the alias name to/javascript-common, and I think the best solution is

You don't need to edit the conf file or purge the package just disable it.


a2disconf javascript-common
service apache2 reload

If for some reason you want to use that conf:


a2enconf javascript-common
service apache2 reload

In addition, explain the role of a2disconf and a2enconf


a2enconf, a2disconf - enable or disable an apache2 configuration file

The function of it is straightforward from the introduction. Quickly enable or disable 1 apache module.

There are also several similar commands:

apache2ctl - Apache HTTP server control interface a2enmod, a2dismod - enable or disable an apache2 module

conclusion

The above is the whole content of this article, I hope the content of this article to your study or work can bring 1 definite help, if you have questions you can leave a message to communicate.


Related articles: