Reputation: 656
I have the following file structure for a php application running with apache server in a debian computer.
/var/www/project/
|-- index/index.php
|-- local
|-- view
| `-- *.php
|-- model
| `-- *.php
|-- controller
| `-- *.php
|-- supportfiles
|-- css
| `-- *.css
|-- javascript
`-- *.js
. . .
I've configured apache so that when I type in my browser http://localhost, apache loads /var/www/project/index/index.php.
To do this, I've changed two files
/etc/apache2/sites-available/000-default.conf
where I set
DocumentRoot /var/www/project/index/
and the file
/etc/apache2/apache2.conf
where I also set
<Directory /var/www/project/index/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
This changes seem to work ok since http://localhost loads the intended index.php file located in the /var/www/project/index directory; however, I'm unable to load java script files such as the following
<!-- <script language="JavaScript" src="../local/supportfiles/javascript/validation.js"></script> -->
What is the problem here? I'm guessing the problem is that apache does not have access to /var/www/project/supportfiles/javasecript/*.js. The original apache configuration (where the apache root directory was /var/www/ and had to load the index.php file by typing http://localhost/project/index) loaded the java script files normally.
Upvotes: 2
Views: 10179
Reputation: 11
I Install phpmyadmin and after this javascript don´t load. I found on /etc/apache/conf.enabled the file javascript-common.conf inside this file has a line Alias /javascript /usr/share/javascript
This line make apache follow to /usr/share/javascript all content of pages. You need change on your pages of javascript to scripts or other name
Upvotes: 1
Reputation: 71
Apache cannot serve files that are outside of the document root. In this case, your document root should probably be set to /var/www/project/. If you would like to be able to still access your site with http://localhost/ then you should move "index.html" to the root of the project folder.
/var/www/project/
- index.php
- local/
- view/
- model/
- controller/
- supportfiles/
- css/
- javascript/
Upvotes: 5