I'm trying to create a virtual host on apache2 but I am getting no response. I have tried serveral tutorials but nothing has helped. This is my file:
<VirtualHost *:80>
ServerName androidwebservice.com
DocumentRoot "/var/www/my_webservice/public"
LogLevel warn
ErrorLog /var/log/apache2/redmine_error.log
CustomLog /var/www/my_webservice/android_access.log combined
<Directory "/var/www/my_webservice/">
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
RailsEnv production
RailsBaseURI /my_webservice
PassengerResolveSymlinksInDocumentRoot on
</Directory>
</VirtualHost>
I have enabled it using the command sudo a2ensite androidbackend(this is the file name). The file is located in /etc/apache2/sites-available.
The ServerName has been declared in /etc/hosts:
127.0.1.1 androidwebservice.com
Are you visiting androidwebservice.com or www.androidwebservice.com
Because you have declared androidwebservice.com not www.androidwebservice.com
The basic (working) example is over here:
https://reformatcode.com
Related
I have completed following apache2 confirmation
<VirtualHost *:80>
ServerName start.example.com
DocumentRoot /var/www/start.example.com/public/
<Directory "/var/www/start.example.com/public/" >
AllowOverride all
Allow from all
Options -MultiViews
RailsBaseURI /rails
RailsEnv production
RewriteEngine On
</Directory>
</VirtualHost>
I set file in /etc/apache2/site_availables/start.example.com.conf
same file set in site_enables
service start succesfully but it's not point to my domain name or ip address.
I don't getting what's wrong with this.
Please Help Me. Thanks In Advance.
In Document Root or Directory, you need to give the path of your project.
<VirtualHost *:80>
ServerName start.example.com
DocumentRoot /var/www/projectName/public/
<Directory "/var/www/projectName/public/" >
AllowOverride all
Allow from all
Options -MultiViews
RailsBaseURI /rails
RailsEnv production
RewriteEngine On
</Directory>
</VirtualHost>
After this, need to restart apache2 server.
sudo service apache2 restart
Now, last step go to hosts file
Ubuntu : /etc/hosts
Windows: C:\Windows\System32\Drivers\etc\hosts
Add, your host here
127.0.0.1 start.example.com
Now, Browse!
It will work.
I develop projects that I've located in /home/user/projects directory. This directory is chmod 777. The problem is that I'm always getting Error 403 Forbidden when I try to access this directory or any subdirectory. This is how my /etc/apache2/sites-available/000-default.conf looks like:
<VirtualHost *:80>
ServerName localhost
ServerAdmin user#user.com
DocumentRoot /home/user/projects
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Options +FollowSymLinks
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /home/gtakacs/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
What's wrong with this? When I used /var/www as my document root, everything worked.
EDIT : try doing chmod -R 777 /home to make sure all your home is available (note that this solution is NOT RECOMENDED, having your project in /var/www would definitely be a better solution in my opinion)
(Can't comment so post reply)
Isn't there a config file in your project where you're supposed to set who can access the app? Check if you didn't forget to add your ip adress and domain name in this file.
When using Apache2 with Django framework (python), I had the same error, and it was because I forgot to add the domain name to authorized hosts.
You can also check access.log and error.log to have more detailed informations on what caused the error.
Command out:
#Order allow,deny
I had this issue before, the problem might be that your document root does not contain the described directories.
I'm trying to enable an other site in my localhost without success. I already have this file like /etc/apache2/sites-avaiable/itransformer.conf:
<VirtualHost *:80>
ServerName itransformer
DocumentRoot /home/manolo/MiServer/itransformer/web
<Directory /home/manolo/MiServer/itransformer/web/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
and it works right. But when I try to add a site, it doesn't work.
I copy the same file:
$ sudo cp itransformer.conf itransformer-2.0.conf
And modify the file like this:
<VirtualHost *:80>
ServerName itransformer-2.0
DocumentRoot /home/manolo/MiServer/itransformer-2.0/web
<Directory /home/manolo/MiServer/itransformer-2.0/web/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Then, I eneble the site:
$ sudo a2ensite itransformer-2.0.conf
And restart the server:
$ sudo service apache2 restart
And it should work when I put itransformer-2.0 in the browser, but does nothing.
I am having trouble removing a VirtualHost, so I thought of just simply editing the /etc/apache2/sites-available/default file. It turns out that I am trying to add the original 'index.html' file, which I have in the /var/www/ directory. But it is not working because another VirtualHost has taken port 80 and I don't see my 'index.html' file listed there in the default file. I am super frustrated, so I am thinking of just doing a fresh install of the apache2 service. But even though I use this command to remove it:
sudo apt-get install --remove apache2 php5 libapache2-mod-php5
Even though I do this, it is not removed and I get this error at the end of the process:
Errors were encountered while processing:
libopenvnc-imgproc2.3
libavfilter2:armhf
libav-tools
ffmpeg
E: Sub-process /usr/bin/dpkg returned an error code (1)
Is there any way to do a fresh install of apache2 along with php5 and libapache2-mod-php5 as I had installed them when I first got my Pi? I am just lost, I have gone to a million forums and none have helped me.....
Here is the 'default' file text:
NameVirtualHost *:8091
NameVirtualHost *:80
NameVirtualHost *:443
This is what I tried doing, but it didn't work, it said the file couldn't be found!
<VirtualHost *:80>
DocumentRoot /var/www/remote_replay.php
ServerName 192.168.1.80
</VirtualHost>
This part below works fine, but I want it removed!!!!!
WSGIDaemonProcess web2py user=www-data group=www-data
<VirtualHost *:8091>
WSGIProcessGroup web2py
WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /home/www-data/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
/home/www-data/web2py/applications/$1/static/$2
<Directory /home/www-data/web2py/applications/*/static/>
Options -Indexes
Order Allow,Deny
Allow from all
</Directory>
<Location /admin>
Deny from all
</Location>
<LocationMatch ^/([^/]+)/appadmin>
Deny from all
</LocationMatch>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/self_signed.cert
SSLCertificateKeyFile /etc/apache2/ssl/self_signed.key
WSGIProcessGroup web2py
WSGIScriptAlias / /home/www-data/web2py/wsgihandler.py
WSGIPassAuthorization On
<Directory /home/www-data/web2py>
AllowOverride None
Order Allow,Deny
Deny from all
<Files wsgihandler.py>
Allow from all
</Files>
</Directory>
AliasMatch ^/([^/]+)/static/(?:_[\d]+.[\d]+.[\d]+/)?(.*) \
/home/www-data/web2py/applications/$1/static/$2
<Directory /home/www-data/web2py/applications/*/static/>
Options -Indexes
ExpiresActive On
ExpiresDefault "access plus 1 hour"
Order Allow,Deny
Allow from all
</Directory>
CustomLog /var/log/apache2/access.log common
ErrorLog /var/log/apache2/error.log
</VirtualHost>
There is a problem with your virtual host configuration, DocumentRoot must be a directory. If you want to serve a specific file, use DocumentIndex to specify the files to use in order of preference:
<VirtualHost *:80>
DocumentRoot /var/www/
DocumentIndex remote_replay.php index.php index.html index.htm
ServerName 192.168.1.80
</VirtualHost>
I have two directories in /var/www (say, /var/www/app1 and /var/www/app2) whose error logs I want sent to different files. Both are under the same domain, so I think that I can't put them under different virtual hosts. So, for example, I would access them as:
http://localhost/app1
http://localhost/app2
I came across this page:
Generate access logs for different subdirectories in Apache
whose solution works perfectly for the access logs. However, the "env" argument doesn't seem to work with the ErrorLog directive.
Before this "discovery", I was working on this, which seems wrong:
<VirtualHost *:80>
ServerAdmin ray#localhost
DocumentRoot /var/www/app1
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/app1/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/app1/access.log combined
</VirtualHost>
I'm somewhat lost about what I should be doing. That is, if there is some way to get ErrorLog to work or if I should keep trying with configuring a virtual host for each directory. Any help would be appreciated! Thank you!
Why do you set Directory options for / in the VirtualHost context? Use <Directory /var/www/app1> instead of <Directory />
Due to the Apache ErrorLog directive docs its context is server config, virtual host - which means that it's only possible to define ErrorLog for the whole server or for a VirtalHost, not for a Directory. So if you want to send different logs to different files, try to use SetEnvIf to set an Env variable. Depeding on the directory where you are, it should be something like SetEnvIf Request_URI ^\/a1\/ a1 and SetEnvIf Request_URI ^\/a2\/ !a1. Then write logs depending on the a1 environment variable.
Set custom ID for every Directory and you can separate logs by directories like this:
<Directory app1>
SetEnv app1
</Directory>
<Directory app2>
SetEnv app2
</Directory>
CustomLog ${APACHE_LOG_DIR}/site1.log combined env=app1
CustomLog ${APACHE_LOG_DIR}/site2.log combined env=app2
Finally I did it, first create internal subdomains per folder and with proxypass pass the subdomain content.
Enable apache mods:
a2enmod authz_core dir proxy proxy_http
/etc/hosts
127.0.0.1 localhost
127.0.0.1 a.localhost
127.0.0.1 b.localhost
/etc/apache2/sites-available/default.conf
<VirtualHost *:80>
ServerName localhost
ServerAdmin fake#mail.com
DocumentRoot "/dev/null"
ProxyPass /a http://a.localhost/
ProxyPassReverse /a http://a.localhost/
ProxyPass /b http://b.localhost/
ProxyPassReverse /b http://b.localhost/
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/default-error.log
CustomLog ${APACHE_LOG_DIR}/default-access.log combined
</VirtualHost>
/etc/apache2/sites-available/a.conf
<VirtualHost *:80>
ServerName a.localhost
ServerAdmin fake#mail.com
DocumentRoot "/Publikoa/a"
<Directory "/Publikoa/a">
DirectoryIndex index.html
Require all granted
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/a-error.log
CustomLog ${APACHE_LOG_DIR}/a-access.log combined
</VirtualHost>
/etc/apache2/sites-available/b.conf
<VirtualHost *:80>
ServerName b.localhost
ServerAdmin fake#mail.com
DocumentRoot "/Publikoa/b"
<Directory "Publikoa/b">
DirectoryIndex index.html
Require all granted
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/b-error.log
CustomLog ${APACHE_LOG_DIR}/b-access.log combined
</VirtualHost>
Enable sites:
a2ensite default a b
Restart apache:
/etc/init.d/apache2 restart