Unable to point my site on Domain_Name or IP_Address - apache2

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.

Related

Are there any security risks for moving the DomainRoot of Apache2 to /home/ubuntu/www?

I was wondering if it was safe to move the DomainRoot of apache2 to /home/ubuntu/www. I am running Ubuntu 16.04 on AWS. I haven't found many articles about this. It doesn't seem safe, but I don't know why. Can you please help?
This is my current conf
<VirtualHost *:80>
ServerName Subdomain.MySite.com
ServerAdmin webmaster#localhost
DocumentRoot /home/ubuntu/www
<Directory /home/ubuntu/www>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>

VirtualHost on Apache2 gives no response

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

Enable sites in localhost doesn't work

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.

Virtual Host don't redirect properly with CakePHP and MAMP

I'm developing a web with cakePHP (using MAMP as localhost) and I just configured a virtual hosts to the root of my project.
My /etc/hosts is
127.0.0.1 localhost
127.0.0.1 altair.loc
And my httpd.conf
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Volumes/Macintosh HD/Users/robotThree/www/"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Volumes/Macintosh HD/Users/robotThree/www/ALTAIR/altair/"
ServerName altair.loc
</VirtualHost>
With this I can access to my project typing http://altair.loc and all controllers and actions works perfectly (i.e. http://altair.loc/controller/action).
The problem is that all files accessed statically fails. For example http://altair.loc/css/main.css fails, but it works if I type http://altair.loc/ALTAIR/altair/css/main.css, as if the virtual host wasn't configured.
Do you know what could be happening?
Thank you in advance
Solved. In httpd.conf is necessary to check that Override is for all, it was an .htaccess and mod_rewrite issue:
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
</Directory>

Apache2 serving multiple sites on one IP

I have two domains that point to the same IP, which is an Ubuntu VPS with apache2. I need to server both domains out of apache. I've read the config manual at http://httpd.apache.org/docs/2.0/vhosts/examples.html#purename and added the following two files:
1) webikenconsultants
<VirtualHost *:80>
ServerName www.webikenconsultants.com
DocumentRoot /var/www/coming_soon
<Directory /var/www/coming_soon>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
2) webikentrading
<VirtualHost *:80>
ServerName www.webikentrading.net
#WSGIScriptAlias / /opt/webikentrading/current/src/webikentrading/django.wsgi
DocumentRoot /var/www
<Directory /var/www >
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
As you can see, webikentrading is a Django project, but for the time being, just to get things working, I am serving it as a static site, until I figure out what's going on. The problem is that when I visit either domain, only the coming_soon content shows up, what am I doing wrong??
I figured out the problem. The vhost entry points to www.webikentrading.net however, the browser was using webikentrading.net so i added a separate entry for just webikentrading.net and all is fine
EDIT:
This is quite old, but I have a new and improved way of doing this now and I hope it can help someone else.
Use the mod_wsgi daemon directive which allows you to add the python path of your choice. Example config is:
<VirtualHost *:80>
ServerName qa.webiken.net
....
WSGIDaemonProcess qa.webiken.net processes=2 threads=15 python-path=/usr/local/pythonenv/QA-WEBIKEN-1/lib/python2.5/site-packages display-name=%{GROUP}
WSGIProcessGroup qa.webiken.net
</VirtualHost>
<VirtualHost *:80>
ServerName staging.webiken.net
....
WSGIDaemonProcess staging.webiken.net processes=2 threads=15 python-path=/usr/local/pythonenv/staging-WEBIKEN-1/lib/python2.5/site-packages display-name=%{GROUP}
WSGIProcessGroup staging.webiken.net
</VirtualHost>

Resources