In this post you will get to know about how to setup a virtual network using apache features. By setting up a virtual network you can organise your various domain and customer domain in a clean and order manner so that you can publish your website in a few seconds to the internet.
Before we start, make sure you have installed the apache web server and If you have not installed apache web server then read my previous post 'install apache web server'. Once you have a working apache web server installed, we can get straight to setting up virtual network in not more than 5 minutes.
create a file 'myvirtualnetwork-hosts.conf' inside the directory 'conf'. You can find conf folder under the folder where you have installed apache
e.g, C:\Program Files\Apache Software Foundation\Apache2.2\conf
copy the following code into the file 'myvirtualnetwork-hosts.conf'....
------------------------------------------------------
# Use name-based virtual hosting.
< directory >
Order Deny,Allow
Allow from all
< /directory >
NameVirtualHost 127.0.0.1
< virtualhost >
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ServerName localhost
CustomLog "logs/access.log" common
ErrorLog "logs/error.log"
< /virtualhost >
< virtualhost >
DocumentRoot "C:\www\domain1.com\site\web"
ServerName subdomain.domain1.com
CustomLog logs/subdomain.domain1.com.access.log combined
ErrorLog logs/subdomain.domain1.com.error.log
< /virtualhost >
< virtualhost >
DocumentRoot "C:\www\domain2.com\site\web"
ServerName subdomain.domain2.com
CustomLog logs/subdomain.domain2.com.access.log combined
ErrorLog logs/subdomain.domain2.com.error.log
< /virtualhost >
-----------------------------------------------------
You can rename the subdomain.domain1/subdomain.domain2 to your wish. Make sure you give name relavent to your actual domain but not the actual domain name itself. If you give the actual domain name then the browser will not load the domain on remote host but from your local host itself.
The path 'C:\www\domain1.com\site\web' should exist. The path 'C:\www\domain1.com\site\web' can also be 'C:\www\domain1.com'. I have used it to give a logical structure, resembling my domain.
Once you are done with the previous step you can add the file name 'myvirtualnetwork-hosts.conf' to 'httpd.conf'. The file 'httpd.conf' will be found in the same directory, where you have created the file 'myvirtualnetwork-hosts.conf'.
Add the following line....
------------------------------------------------------
Include conf/myvirtualnetwork-hosts.conf
------------------------------------------------------
Final step is to add the following code to the file 'hosts'. The file can be found under the path 'C:\WINDOWS\System32\drivers\etc'. You should have access to write to that file.
copy the following code at the end of the file.
------------------------------------------------------
127.0.0.1 localhost
127.0.0.1 subdomain.domain1.com # site description
127.0.0.1 subdomain.domain2.com # site description
------------------------------------------------------
Restart apache. Feel the joy......
Thursday, November 27, 2008
Setting up a virtual network with Apache HTTPD
Labels:
Apache server,
Virtualhost
Friday, November 21, 2008
VirtualHost by Apache Web server - HTTPD
Apache support for Virtual host. Virtual host is the feature where one can define one or more domain within a localhost system. Fore more information on virtualhost by apache visit http://httpd.apache.org/docs/2.2/vhosts/. In the up coming post we will talk about how to setup the virtualhost in apache 2.2.10.
I look for your valuable comments to improve my-tech-park. So don't forget to comment.
I look for your valuable comments to improve my-tech-park. So don't forget to comment.
Labels:
Virtualhost
Configure PHP extension to support Session and MYSQL
Before you start reading this post make sure that you have installed Apache web server , PHP and Mysql.If you have also configured web server for PHP then we can start to configure PHP for mysql if not then view the post to configure web server for PHP. Basically PHP comes with support for lots and lots of extension. To make use of the extensions in php edit the php.ini file as follows to point to /ext/ folder inside installed php5.2.6 folder
------------------------------------------------------
;ORIGINAL
;extension_dir = "./"
;EDITED
extension_dir = "C:\Program Files\Apache Software Foundation\Apache2.2\php-5.2.6-Win32\ext\"
------------------------------------------------------
Now having set the php.ini file to point to the php extension directory we are going to make the
extension for mysql available. Edit the php.ini file as follows
------------------------------------------------------
;ORIGINAL
;extension=php_mysql.dll
;EDITED
extension=php_mysql.dll
------------------------------------------------------
NOTE : if this is not done then you will get the error 'Fatal error: Call to undefined function mysql_connect()---'
To make use of the session make the following changes in the php.ini file
------------------------------------------------------
session.save_path = "C:\WINDOWS\Temp"
------------------------------------------------------
Set the save_path for session to any directory that exist.
NOTE : php.ini is the file copied to %SYSTEMROOT% folder during installation of PHP.
For information on how to install PHP visit previous post
------------------------------------------------------
;ORIGINAL
;extension_dir = "./"
;EDITED
extension_dir = "C:\Program Files\Apache Software Foundation\Apache2.2\php-5.2.6-Win32\ext\"
------------------------------------------------------
Now having set the php.ini file to point to the php extension directory we are going to make the
extension for mysql available. Edit the php.ini file as follows
------------------------------------------------------
;ORIGINAL
;extension=php_mysql.dll
;EDITED
extension=php_mysql.dll
------------------------------------------------------
NOTE : if this is not done then you will get the error 'Fatal error: Call to undefined function mysql_connect()---'
To make use of the session make the following changes in the php.ini file
------------------------------------------------------
session.save_path = "C:\WINDOWS\Temp"
------------------------------------------------------
Set the save_path for session to any directory that exist.
NOTE : php.ini is the file copied to %SYSTEMROOT% folder during installation of PHP.
For information on how to install PHP visit previous post
Mysql as Database for Script
Its often necessary to maintain data in a table over the server.Scripting language enable the developer to connect to the database and get the data. Here we are going to setup a free community database software mysql version 5.1.2600. Mysql is been supported by php right from beginning of its journey. Lets see how to install and then configure php for mysql.
Download the mysql installation file 'mysql-5.0.67-win32.zip'and install it just by clicking next and next, after extrating to temp directory.During installation check the option to install mysql as a service. So that mysql can be started from from command prompt as follows,
RUN COMMAND :cmd
------------------------------------------------------
>mysql -u root -p
Enter Password:*******
>mysql>
------------------------------------------------------
Prompt appears asking password , give a valid password(created during installation) to work with mysql.
Right now mysql is been installed but it still need to be configured with PHP for php code access Mysql database.Configuring PHP for mysql will be discussed in next post.
Download the mysql installation file 'mysql-5.0.67-win32.zip'and install it just by clicking next and next, after extrating to temp directory.During installation check the option to install mysql as a service. So that mysql can be started from from command prompt as follows,
RUN COMMAND :cmd
------------------------------------------------------
>mysql -u root -p
Enter Password:*******
>mysql>
------------------------------------------------------
Prompt appears asking password , give a valid password(created during installation) to work with mysql.
Right now mysql is been installed but it still need to be configured with PHP for php code access Mysql database.Configuring PHP for mysql will be discussed in next post.
Labels:
Mysql
Configure Apache for PHP
Lets see how to configure Apache for PHP. Before proceeding with this post make sure you have installed PHP. Installing PHP was discussed in last post.
Following are the steps to configure apache2.2.10 for PHP5.2.6:
Step 1 :
Open the file 'httpd.conf' inside \Apache Software Foundation\Apache2.2\conf and add the following lines.
# ADDED FOR PHP HANDLING
------------------------------------------------------
LoadModule php5_module "C:\Program Files\Apache Software
Foundation\Apache2.2\php-5.2.6-Win32\php5apache2_2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
------------------------------------------------------
The folder 'php-5.2.6-Win32' in the LoadModule line is the unzipped php installation file.
STEP 2 :
Restart the apache server.
STEP 3 :
Create a php file 'index.php' with the following code.
------------------------------------------------------
phpinfo();
?>
------------------------------------------------------
And save it inside the folder 'htdocs' in /Apache2.2/ folder
STEP 4 :
Load the following URL in your browser -
http://localhost/index.php , you should get the php setting displayed to indicate that the php in properly parsed.
Following are the steps to configure apache2.2.10 for PHP5.2.6:
Step 1 :
Open the file 'httpd.conf' inside \Apache Software Foundation\Apache2.2\conf and add the following lines.
# ADDED FOR PHP HANDLING
------------------------------------------------------
LoadModule php5_module "C:\Program Files\Apache Software
Foundation\Apache2.2\php-5.2.6-Win32\php5apache2_2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
------------------------------------------------------
The folder 'php-5.2.6-Win32' in the LoadModule line is the unzipped php installation file.
STEP 2 :
Restart the apache server.
STEP 3 :
Create a php file 'index.php' with the following code.
------------------------------------------------------
phpinfo();
?>
------------------------------------------------------
And save it inside the folder 'htdocs' in /Apache2.2/ folder
STEP 4 :
Load the following URL in your browser -
http://localhost/index.php , you should get the php setting displayed to indicate that the php in properly parsed.
Labels:
Apache server,
PHP
Installing PHP
PHP is being prefered by many web developers to perform their server side scripting nowsdays. PHP is getting more and more efficient in recent time supporting for its wide approval. Lets see how to install a php parser so that your local system web server can make use of it to parse any php web page.
While i am writing this post the most recent version was 5.2.6. Download the zipped file PHP 5.2.6 zip package and extract it to the directory where Apache is installed.
Now copy the file'php.ini-dist' inside moved 'php 5.2.6' folder to %SYSTEMROOT% in Windows XP and rename it to 'php.ini'. Then Copy the file 'php5ts.dll' to %SYSTEMROOT%\System32 in WindowXP.
Right now setting up php is done and it need to be added to apache web server by configuring the httpd.conf file. This will discussed in next post.
While i am writing this post the most recent version was 5.2.6. Download the zipped file PHP 5.2.6 zip package and extract it to the directory where Apache is installed.
Now copy the file'php.ini-dist' inside moved 'php 5.2.6' folder to %SYSTEMROOT% in Windows XP and rename it to 'php.ini'. Then Copy the file 'php5ts.dll' to %SYSTEMROOT%\System32 in WindowXP.
Right now setting up php is done and it need to be added to apache web server by configuring the httpd.conf file. This will discussed in next post.
Labels:
PHP
Setting up Apache Web Server
Now we are going to see one of the project by apache software foundation which is http server project. Most Current version of httpd software can be downloaded from http://httpd.apache.org/ . When i am writing this post the most recent version is 2.2.10 which is considered to be most stable at this point.
I just downloaded apache_2.2.10-win32-x86-no_ssl.msi, which is a installer file. Setup is quite easy just clicking next and next. The http server can be configured latter at any point by editing the file httpd.conf file.
While installing you will be prompted for entering the domain, server name and email address.
Enter
Domain: localhost
Server Name: localhost
Email Address: admin@localhost
Once the installation is over you can verify the integration of the installation by checking the path 'http://localhost/' in any browser. You will get 'It works' showing that the localhost is handled by the web server.
The web server can be configured with other software like php etc by editing the httpd.conf file found inside the conf folder in the apache installed location.
When we talk about other software (another post) will discuss about how to configure web server to manager those application.
I just downloaded apache_2.2.10-win32-x86-no_ssl.msi, which is a installer file. Setup is quite easy just clicking next and next. The http server can be configured latter at any point by editing the file httpd.conf file.
While installing you will be prompted for entering the domain, server name and email address.
Enter
Domain: localhost
Server Name: localhost
Email Address: admin@localhost
Once the installation is over you can verify the integration of the installation by checking the path 'http://localhost/' in any browser. You will get 'It works' showing that the localhost is handled by the web server.
The web server can be configured with other software like php etc by editing the httpd.conf file found inside the conf folder in the apache installed location.
When we talk about other software (another post) will discuss about how to configure web server to manager those application.
Labels:
Apache installation
Lets Start Programming Server Side Script
As we start to learn any server side scripting we should also test some of the script in real time to see how it actually behaves and how the flow occurs. But to perform these we need to make some initial arrangement such as getting a real server access or the local system should be made to behave as a server. Often young developers prefer going on for setting up local system server. Thus making use of the localhost 127.0.0.1 to perform the task of a server.
Before we start let turn to the procedure to setup the local server.There are many developer tools to setup server configuration. Microsoft offers IIS which is often bundled with the XP Installation CD. The most widely used one is the Apache Project tool i.e http server by apache. Its is best and we are going to discuss in another post about how to setup it.
Before we start let turn to the procedure to setup the local server.There are many developer tools to setup server configuration. Microsoft offers IIS which is often bundled with the XP Installation CD. The most widely used one is the Apache Project tool i.e http server by apache. Its is best and we are going to discuss in another post about how to setup it.
Labels:
Apache server
Welcome to Mytechpark
Hello visitors
First off all i need to thank you people for visiting my blog. Thanks a lot. Hope you people will find some interesting tips around this blog. I just created this blog to share my technical learning in the area of web programming. Here in this blog i will post articles on how to program some internet programming language like html,javascript,php,xml,jsp etc and also the recent technological development in WWW. I will be grateful if you people make a friendly comments and suggestion. Thanks for visiting ...and keep visiting ... Have a great day
First off all i need to thank you people for visiting my blog. Thanks a lot. Hope you people will find some interesting tips around this blog. I just created this blog to share my technical learning in the area of web programming. Here in this blog i will post articles on how to program some internet programming language like html,javascript,php,xml,jsp etc and also the recent technological development in WWW. I will be grateful if you people make a friendly comments and suggestion. Thanks for visiting ...and keep visiting ... Have a great day
Labels:
Welcome Note
Subscribe to:
Posts (Atom)