I need to change the document root to something else.
for example I want my root as ~/Dropbox/www instead of /var/www/html
To achieve that I've changed my /etc/apache/sites-availabl/000-default.conf file
to
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster#localhost
DocumentRoot ../../home/ahmar/Dropbox/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
when I restart the server it seems fine
But When I open my localhost
it gives me a forbidden error
with this message
Forbidden
You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at localhost Port 80
Try Putting
"DocumentRoot /home/ahmar/Dropbox/www/"
It should fix the problem. :)
Related
Im on Linux (debian based), and my apache2 localhost doesn't give any warning / error messages. The apache error.log located at var/log/apache2/error.log gives errors / warnings but it will never output something on my website.
I made a file called /etc/apache2/sites-available/html.conf with the neccesary info:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName localhost
ServerAlias www.localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
however, If i change line 6 to the location of my error.log file (var/log/apache2/error.log), It does nothing.
EDIT:
I solved the problem
I had to change this line: log_errors = Off
to: log_errors = On
In the php.ini file (Line 503)
Using Ubuntu 18.04.01 and I set up multiple sites in apache so I can work on them locally. Here is my current set up:
/etc/hosts
127.0.0.1 localhost
127.0.1.1 site1.local
127.0.1.1 site2.local
/var/www
site1.com
site2.com
/etc/apache2/sites-available
000-default.conf
default-ssl.conf
site1.com.conf
site2.com.conf
site1.com.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/site1.com
ServerName site1.local
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
site2.com.conf looks the same as this but swap 'site1' with 'site2'
I also ran:
sudo a2ensite site1.com.conf
sudo a2ensite site2.com.conf
and the symlinks in in /sites-enabled are now there.
However the behavior I get is when I go to my browser and typle in http://site1.local it loads just fine. But when I enter in http://site2.local the browser just redirects back to site1.
Please advise.
Looks like it was just a caching issue with my browser
Hello I am using Server version: Apache/2.2.22 running Ubuntu 12.04.5 . I had my website on another server which was running correctly with 750 permissions to whole folder. When I moved to the new server :
I created the virtual host and I turned it on (a2ensite, reload and restart apache)
<VirtualHost *:80>
ServerAdmin webmaster#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /path/to/project/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I set permissions of the project folder to 750 and I get the error :
(13)Permission denied: /path/to/project/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
I cleared .htaccess file but I got the same error. SELinux is not installed and my httpd.conf file is empty. Any ideas?
I want to set up apache2 so that the wordpress website is served via port 80 and some other php website served via port 8080. This is on my local machine running Ubuntu 15.10.
The sites-available/000-default.conf contains:
Listen 80
Listen 8080
NameVirtualHost *:8080
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot /var/www/php-website
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
When I enter localhost into the browser, I get the Wordpress website. When I enter localhost:8080, I get (redirected it seems to) localhost.
What could be wrong here? I though there might be something wrong with the second VirtualHost config so it's defaulting to the first, so I changed their order. Same thing happened however.
It could be a problem with wordpress configuration. I think wordpress uses wordpress adress (url) or site adress (url) to redirect if you are in another domain. So you should configure this adresses to localhost and localhost:8080.
It was a browser issue. Chrome and Firefox were automatically changing the URL to localhost. It works with curl and in Incognito/Private modes.
I am trying to set virtual hosts for two Zend Framework applications. I started by changing the system32 hosts file.
It contains the following lines now:
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 quickstart
After that, I proceeded with changing the httpd-vhosts.conf file. Its current content:
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "G:\workspace\Andrew\ProjManer\public"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host2.localhost
DocumentRoot "G:\workspace\Andrew\quickstart\public"
ServerName quickstart
ServerAlias quickstart
ErrorLog "logs/quickstart-error.log"
CustomLog "logs/quickstart-access.log" combined
</VirtualHost>
If I don't add the virtual host with localhost first, I get a "Access forbidden 403 Error message".
The problem now is that both point to the same location, the localhost. How am I supposed to get the second virtual host working? I used the flushdns also.
You don't need the ServerAlias in them unless you want say quickstart2 to go to quickstart. In that case you will do ServerAlias quickstart2. You get access forbidden because your document root in your httpd.conf doesn't have an index.php or that virtualhost doesn't have an index.php and you have -Indexes set
Other than that the virtualhost and hosts file look fine. Try restarting your browser and restarting apache.