solved: [warn] _default_ VirtualHost overlap on port 80, the first has precedence

Here I am using the Fedora 9 for this example. I solved the issue of _default_ VirtualHost overlap on port 80 warning in linux

If you want to host many sites on one computer or machine.
I added following lines to httpd.conf file(end of file).

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

<VirtualHost  *:80>

Options +FollowSymLinks
ServerName example1.com
DocumentRoot /var/www/html/example1

VirtualHost>

<VirtualHost  *:80>

Options +FollowSymLinks
ServerName example2.com
DocumentRoot /var/www/html/example2

</ VirtualHost>

[/viral-lock]

When I restarted the apache server using following command.
#su
#ROOT_PASSWORD
#/etc/init.d/httpd restart

I got the following error;
[warn] _default_ VirtualHost overlap on port 80, the first has precedence

Again I opend the httpd.conf tile and I read following lines;
#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80

# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

Than only I uncommented following line and restarted the Server.

NameVirtualHost *:80

My promlem get solved.

Solved issue -Directory index forbidden by Options directive:

I want to change the default location of Apache folder which is (var/www/html).
I am using the Fedora as OS and apache 2 here. you can use following code with any linux box like centos or ubuntu. Here we solved the issue of directory.

When I inserted the following code in bottom of the httpd.conf file.
<VirtualHost *:80>
Options +FollowSymLinks
ServerAdmin siwan@yahoo.co.in
DocumentRoot /var/www/html/testfolder
ErrorLog logs/error_log_net
TransferLog logs/access_log_net
</VirtualHost>

When tried the http://localhost/ in browser, I got the default browser page.
Then I tried to look my apache error using following command:
#[root@localhost ]# tail -f /var/log/httpd/error_log

In apache error log I got following error.
[Wed Oct 07 15:59:50 2008] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/testfolder/

I changed the AllowOverride option but nothing is happens. Then I read the welcome page text
“To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.”
I opend the welcome.conf file.

I found following lines in welcome.conf file.
<LocationMatch “^/+$”>
Options -Indexes
ErrorDocument 403 /error/noindex.html
LocationMatch>

I changed that to as follows:

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

<LocationMatch “^/+$”>
Options Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>

[/viral-lock]

That solve my problem. Some time your selinux will cause the issue so you need to deactivate the selinux.
Some time File permission will also cause the issue.
You can change the file permission using following command, go to that directory and run following command.
#chmod 777 *

You can use above commands on any linux box. Ubuntu, centos, redhat or on fedora box.. still solution will be same.

clean url with html file

We have site in plain html file and some time we want to use clean URLs or Pretty URLs for our site.
Clean URLs are in demand becasue of Seach Engine Optimiztion.

You can achive the Clean URLs. With not doing rework of building site.

Requirement:
Apache Server.
mod_rewrite engine need to on.

Create .htaccess file
and copy paste the following lines

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

#code for About us Page
RewriteRule ^about-us(\d+)*$ ./about.html$1

Put this file into your root folder.

What this will do?

For example I want

www.example.com/about.html to look like www.example.com/about-us/

Use PHP in Rails project

Many times you need to use PHP scripts in Rails project. You will got so much open source PHP scripts for various use.

Example is So many Rails site is using WordPress for blogging system.

Main reason behind using PHP files or script is SEO. PHP is a very SEO friendly.

Customer does not want to spend money or time already existing scripts or program.

If you want to use PHP files or project under Rails project. Just create any folder in Public directory and put your php files in to that folder.

lets say you created the “fourm” dir in public directory.

You need to add following lines in your apache rule file(httpd.conf)

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_http_module modules/mod_proxy_http.so

Under <VirtualHost  *:80> tag add following lines:

ProxyRequests Off

RewriteEngine On

RewriteCond  %{HTTP_HOST}    ^example.com [NC]
RewriteCond %{REQUEST_URI}  !^/forum(.*)$ [NC]

RewriteCond  %{HTTP_HOST}    ^example.com [NC]

RewriteRule ^/forum/?(.*)$ /document_root/forum/$1 [QSA,NC,L]

Than you are able to use PHP code or scripts in Rails project

setting up basic authentication apache

Two months back, we got the requirement of do basic authentication for testing site server. We given steps and code for setting up basic authentication apache. So Google or any search engine site cannot index the testing sites.

setting up basic authentication apache

We are using Fedora as Operating System and Apache as web server on our testing machine. We hosted more than fifteen test sites on that server.

I successfully created basic authentication on server.

Use following commands:

#su

#ROOT_PASSWORD

#vi /etc/httpd/conf/httpd.conf

in that file you need to insert following lines.

AccessFileName htaccess.acl .htaccess
# htpasswd -c /home/USER/pwd.txt USER(you can define your user of stystem.)
New password: mypassword
Re-type new password: mypassword

That sit. Your username and password is set for popup.

Now you need to only create or update your .htaccess  file. You can create or find .htaccess file in your project folder.

Use or copy and paste following code in that file: (.htaccess file)

AuthUserFile /home/USER/pwd.txt
AuthName "Protected"
AuthType Basic


require valid-user

I following exact method for my server and projects. It is working perfect for me.