|
Blog > Webservers Getting Apache's ModRewrite to work
Posted on March 30, 08 @ 12:26 am under Webservers and has no comments.
Apache ModRewrite module makes the URLs to be rewritten in a search engine friendly manner. ModRewrite means Rewrite Module. For example, Drupal uses the ModRewrite to change the appearance of URLs. To use this functionality, ModRewrite should be enabled on the Apache server. This tutorial is based on Apache 2.2.8 on Windows. The same process can be applied to other versions.
First of all the rewrite module has to be enabled on the server. For this, in httpd.conf, uncomment the following line and restart the server.
<code>LoadModule rewrite_module modules/mod_rewrite.so</code>
Once it is done, its left to applications to use this feature. Applications need to turn on this feature in .htaccess file. For this, add following line to .htaccees file.
<code>RewriteEngine on</code>
Finally the rewrite condition has to be specified in .htaccess.

Creating virtual hosts on Apache 2.2
Posted on March 30, 08 @ 12:20 am under Webservers and has no comments.
While developing websites, you might be giving relative paths starting from webroot. In such cases having the website as a subfolder under docroot doesn't serve purpose. So you need to emulate the website on your localhost. For this, a virtual host on the localhost server needs to be created.
In Apache 2.2, the virtual hosts is maintained in seperate file --conf/extra/httpd-vhosts.conf. This file is included in the main httpd.conf file. First enable this inclusion by removing the comment for the following line in httpd.conf.
<code>Include conf/extra/httpd-vhosts.conf</code>
Create a directory, e.g. C:\virtuals, which holds all the virtual host websites.
Because of the permissions issue, I recommend creating a top-level folder to hold all virtual hosts in your local development environment. The following instructions assume that all virtual hosts are located in a folder called C:\vhosts.
1. Create a subfolder inside C:\vhosts for each virtual host that you want to add to your Apache server.
2. Open C:\WINDOWS\system32\drivers\etc\hosts in Notepad or a script editor. Look for the following line at the bottom:
127.0.0.1 localhost
3. On a separate line, enter 127.0.0.1, followed by some space and the name of the virtual host you want to register. For instance, to set up a virtual host called mywebsite, enter the following:
127.0.0.1 mywebsite
4. Add any further virtual hosts, each one on a separate line and pointing to the same IP address (127.0.0.1). Save the hosts file, and close it.
5. Open C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf in a text editor, scroll down to the Supplemental configuration section at the end, and locate the following section (around line 460):
#Virtual hosts
#Include conf/extra/httpd-vhosts.conf
6. Remove the # from the second line so the section now looks like this:
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
7. Save httpd.conf and close it.
8. Open C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf in Notepad or a text editor. The main section looks like this:Contents of httpd-vhosts.conf
9. Position your cursor in the blank space shown on line 15 in the preceding screenshot, and insert the following four lines of code:
<Directory C:/vhosts>
Order Deny,Allow
Allow from all
</Directory>
This sets the correct permissions for the folder that contains the sites you want to treat as virtual hosts. If you chose a location other than C:\vhosts as the top-level folder, replace the pathname in the first line. The pathname must use forward slashes in place of the Windows convention of backward slashes. Also surround the pathname in quotes if it contains any spaces.
As long as all your virtual hosts are in subfolders of this top-level folder, this directive sets the correct permissions for all of them. However, if they are in different top-level folders, create a separate <Directory> directive for each one.
10. The code shown on lines 27 through 42 in the preceding screenshot shows examples of how to define virtual hosts. It shows all the commands that can be used, but only DocumentRoot and ServerName are required.
When you enable virtual hosting, Apache disables the main server root, so the first definition needs to reproduce the original server root. You then add each new virtual host within a pair of <VirtualHost> tags, using the location of the site’s web files as the value for DocumentRoot, and the name of the virtual host for ServerName. Again, use forward slashes, and if the path contains any spaces, enclose the whole path in quotes. If your server root is located, like mine, at C:\htdocs, and you are adding phpdw as a virtual host in C:\vhosts, change the code shown on lines 27 through 42 so they look like this:
<VirtualHost *:80>
DocumentRoot c:/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot c:/vhosts/mywebsite
ServerName phpdw
</VirtualHost>
11. Save httpd-vhosts.conf, and restart your computer. All sites in the server root will continue to be accessible through http://localhost/sitename/. Anything in a virtual host will be accessible through a direct address, such as http://phpdw/.
12. If you still have difficulty accessing your virtual hosts, make sure that you have added index.php to the DirectoryIndex directive in httpd.conf.

Managing GlassFish Webserver
Posted on December 26, 07 @ 03:00 am under Webservers and has no comments.
GlassFish webserver will be installed by default with Netbeans 6.0. Here is some useful information.
asadmin.bat file in C:Program Filesglassfish-v2in is used for issuing asadmin commands. Understand "asadmin" as "as admin". Double click it and give the commands. This will open a seperate command prompt with asadmin>.
Knowing the domains:
Domains are the places where webapplications are deployed. The domains will be found in C:Program Filesglassfish-v2domains. By default domain1 will be present.
Starting the domain:
* asadmin>start-domain domain1
Type "start-domain domain1" and press enter. Atfirst it will show the address of logfile. Then the ports available for admin and port available for the webapplications, and ports the domain is listening to. To access the application, note down the ports for webapps.
Stopping the domain:
* asadmin>stop-domain domain1
Administering domain:
Notedown the adminport while start-domain and go to that URL. enter the admin ID and password. (For default installations, admin password will be 'adminadmin').
Controlling from Netbeans:
You can otherwise control the GlassFish from within Netbeans 6.0 itself. You have to register before controlling it.
Adding Server:-
* Go to Window menu and select Services. A palette will be displayed with different items.
* Right click on Servers node and select Add Server.
* From the list of servers displayed, select Glassfish V2. (If you have v1, select GlassFish V1)
* Select the domain you want to control and enter the details.
* Enter admin username and password and click finish. An instance will be added to the Servers node.
From here, you can directly Start-Stop-Restart the server. Using these instances, you can deploy the webapps you develop. 
Pages: [1]
|