I have apache running on Ubuntu, my initial directory structure was like :
var/www/html/myproject,
Now I had cloned a git repository in html folder above now my directory structure becomes :
1] var/www/html/myproject this is intact,
2] var/www/html/my_repo/myproject this is newly created after cloning,
Now I want apache to deploy this newly created 2nd dir as root, hence I made the change in file located at /etc/apache2/sites-available/000-deafult.conf with following changes :
DocumentRoot var/www/html/my_repo/myproject
Then restarted the apache but somehow, server is still loading pages from var/www/html/myproject instead of var/www/html/my_repo/myproject.
So is there any extra config changes that I have missed OR Do I need some permissions to be given to cloned repository files ? How do I resolve this issue.
Did you change your original DocumentRoot in apache configuration file? If you didn't, change it, if you did, just reset browser cache by Ctrl+F5 or open page in Private Mode.
I figured it out it was /etc/apache2/sites-enabled where the seperate cofiguration file only for myproject named myproject.config in which I made following changes :
DocumentRoot var/www/html/my_repo/myproject & also
<Directory var/www/html/my_repo/myproject>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Now server is taking new directory as root.
Related
I have recently been tasked with hosting a git server on Linux. I am very new to the Linux world so it was struggle just to get where I am today. I am at the point where I have created a bare repository and can view it using GitWeb (hosted on Apache).
Since I can browse to it with GitWeb I figured my configuration of the apache server and git were correct, but I still cant clone the repository on a remote machine. Depending on how I have apache configured, I either get a 403 Forbidden error or a 404 error when attempting to clone.
I am not sure if my git repository isn't configured correctly, my apache configuration is bad, or the folder security makes it inaccessible. It could be multiple things.
I have since removed GitWeb so that I could work with the simplest git and apache configurations possible. I am sure there are plenty of different reasons for my issues, so I am more asking for a few common misconfigurations that might be the culprit.
Here are some portions of my apache configuration. My repository is located at /opt/git
<VirtualHost *:80>
ServerName gitserver
DocumentRoot /opt/git
<Directory /opt/git>
Options ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
</Directory>
ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
</VirtualHost>
<Directory "/opt/git">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
As I said, I was able to (with a different configuration) browse to my GitWeb page, so apache is definitely running and at some point the VirtualHost was configured correctly, but something is definitely wrong.
Thanks!
Looks like it wasn't an issue with apache, it is an issue with git. I needed to run the command
git update-server-info
I was confused because This Documentation made it seem like the command would run automatically, since I just copied the sample hooks. I guess you have to run the command whenever you create a new repository?
I just installed Apaxy for a better and customizable folders views.
It works perfectly, but not in my virtualhost.
Folder (localhost) :
Virtualhost (local.dev.conf, access with local.dev):
<VirtualHost *:80>
ServerName local.dev
DocumentRoot /var/www/local.dev
</VirtualHost>
Unfortunately, in the virtualhost (local.dev) apaxy doesn't work.
I assume it's normal because the server try to find files in local.dev/themes/...
Or my 'themes' folder is in the parent folder, so it is possible to resolve this ?
Here is the .htaccess :
https://justpaste.it/t8yp
Problem
Apache serves file from the directory /var/www/local.dev.
Solution
Moving the directory /var/www/theme into /var/www/local.dev would work. Nevertheless if, for any reason, you do not want to move theme you can link it using the command ln -s /path/to/theme /path/to/local.dev/theme.
IMHO
Moving the directory would be a better solution as linking it, would force the configuration to enable follow-symlink, as it can be considered as a security issue.
I am facing a peculiar problem with apache2 running on debian 8. I followed a couple of tutorials to install it and everything worked great. The problem is that i have partitioned the disk as 9gb for the system files, 1gb swap and 30gb for the home folder so I wanted to move the www folder from it's current location (/var/www) to home(/home/www).
I found more than a few guides on how to do that, some saying that i should change the lines in apache2.conf from this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
to this:
<Directory /home/paul/www/>
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
</Directory>
As well as the documentRoot
Others suggested using the 000-default.conf file located in the /etc/apache2/sites-available folder and change the default folder from /var/www to /home/paul/www.
I did both and the folder was seen but not accessible, so i used the quick solution and use chroot 777. After that apache redirected me back to /var/www.
All settings point to /home/paul/www and the www folder has full read write permission. In fact neither the apache.conf nor 000-sites-available has any reference of /var/www so why does apache keep pointing me there? Is there something i missed?
p.s i did updates and upgrades multiple times as well as restarted the apache service and the entire pc.
you need to change the ownership of files to allow apache there
please try
chown -R www-data /home/paul/www/
however if you set a particion for your paul www why not mount the partition in /var/www
or you can create a symlink
ln -s /home/paul/www /var/www/paulsite
then edit your apache conf accordingly.
Regarding the edited file I recomend you use the 000-default better. in fact i would use that as a skeletone. and create a new file for your site then enable that site.
Ok so with a little research i realized that what i was trieing to do was not the best practice at all! (Thanx for the heads up Sudakatux).
I found the solution in askubuntu for anyone interested.
Instead of trieing to change the mechanics of apache i enabled the userdir module and set up public_html in my home folder with 755 permissions. I use a redirection script from the initial location to the various locations on my home directory. Works just fine!
I have linux server (Red Hat Enterprise Linux Server release 5.3 (Tikanga)) with apache installed. It is already used for browsing some documents. Now I would like to add a new Directory (with a html page), so whenever the directory is browsed it can display the html page.
But I am not sure of where all to edit the httpd.conf file
Existing httpd.conf:
When I hit the url "http://servername/eng" it displays list of folders.
Now, I want to add a website to this existing, so when user hit the url "http://servername/builds" it should display a html page in the browser.I have added my "index.html" page in location "/var/www/html/builds/"
For this I added the below code to httpd.conf file
Please let me know what all modifications are required in the conf file
You can do it in a few different ways.
Putting index.html in /build
This requires you to have this setting:
DirectoryIndex index.html
(it should be there by default on most platform.)
Also for this to work, rather than putting new <Directory>, you should put the build/ directory in the directory that holds your http://example.com/ files. For instance:
/var/www/example.com/public_html/eng/
/var/www/example.com/public_html/builds/
/var/www/example.com/public_html/builds/index.html
Storing build/ in folder completely unrelated to example.com, but still be able to reach it via example.com/builds
For this, you need to rewrite the URLs so that example.com/builds redirects the user to the final URL. This is most easily achieved through mod_rewrite. You enable mod_rewrite module in your Apache's configuration, make sure that example.com can have .htaccess files through ensuring proper AllowOverride entry in example.com's <Directory> configuration, create /var/www//example.com/public_html/.htaccess (or similar) file, and fill it RewriteEngine On and RewriteRules you need. More on mod_rewrite in the Internet and in the documentation.
Completely separate virtual server, for example builds.example.com/
In this case, what you're looking for are virtual servers. These are not defined in httpd.conf or configuration itself, but usually have dedicated directory.
For example, to add builds.example.com that works for port 80, you'd need to create following entry:
<VirtualHost *:80>
ServerName builds.example.com
DocumentRoot /var/www/builds.example.com/public_html/
</VirtualHost>
Where to put this? Well, it depends on the platform. For Debian, you put this in a new file in /etc/apache2/sites-available/, e.g. /etc/apache2/sites-available/example.com, and symlink to it in /etc/apache2/sites-available (on Debian, you can do this easily with a2ensite <NAME_OF_FILE>. On your platform this procedure might be different, so look it up ("adding virtual servers on " would be a start). After adding virtual servers, you need to reload your Apache configuration.
Please let me know if this satisfies your question, if not, I'll edit the answer accordingly.
I am trying to change the DocumentRoot in httpd.conf from /var/www to /var/www/shop just so I can be organized. But even when I do that after restarting apache and httpd, I go to localhost and it still points to /var/www. My httpd.conf is basically the same as this file here:
http://www.devside.net/guides/config/linux/httpd-conf
I am running this on Debian.
Any ideas? Thanks
Debian uses various include files and a "site" concept, so httpd.conf isn't normally changed at all (the includes are). You likely changed the value before the "default" site changes it back to /var/www.