I have started Apache Web server and put all the required configuration in httpd.conf file like
DocumentRoot "c:/Apache2/htdocs"
<Directory "c:/Apache2/htdocs">
<Directory> DirectoryIndex
when i'm opening localhost in browser that time it not opening index.html document which is stored in htdocs directory. can someone please suggest my what i'm missing here, Thanks in Advance .
At the end you have to write the name of file 'index.html'
DocumentRoot "c:/Apache2/htdocs"
<Directory "c:/Apache2/htdocs">
<Directory> DirectoryIndex index.html
Related
I have a VPS server with Ubuntu 18 O.S. In this VPS I have installed VESTA CP, which comes with Apache 2 and Nginx. After that I have intalled Tomcat 9(port 8082) to serve a Java Spring based webapp.
If I enter the address "serverIP:8082/AppFolder" I can access the app, but I want to redirect the apache server to the tomcat one, so I can write the domain name and load the webapp.
I have tried .htaccess file but it shows an apache error page. I have no permission to view this file is the message.
What can I do to solve this?
-Nginx config:
location / {
proxy_pass http://IP:8080;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|eps|ps|zip|tar|tgz|gz|rar|bz2|7z|aac|m4a|mp3|mp4|ogg|wav|wma|3gp|avi|flv|m4v|mkv|mov|mpeg|mpg|wmv|exe|iso|dmg|swf)$ {
root /home/admin/web/webapp.com/public_html;
access_log /var/log/apache2/domains/webapp.com.log combined;
access_log /var/log/apache2/domains/webapp.com.bytes bytes;
expires max;
try_files $uri #fallback;
}
}
location /error/ {
alias /home/admin/web/webapp.com/document_errors/;
}
location #fallback {
proxy_pass http://IP:8080;
}
-Apache config:
<VirtualHost IP:8080>
ServerName webapp.com
ServerAlias www.webapp.com
ServerAdmin info#webapp.com
DocumentRoot /home/admin/web/webapp.com/public_html
ScriptAlias /cgi-bin/ /home/admin/web/webapp.com/cgi-bin/
Alias /vstats/ /home/admin/web/webapp.com/stats/
Alias /error/ /home/admin/web/webapp.com/document_errors/
#SuexecUserGroup admin admin
CustomLog /var/log/apache2/domains/webapp.com.bytes bytes
CustomLog /var/log/apache2/domains/webapp.com.log combined
ErrorLog /var/log/apache2/domains/webapp.com.error.log
<Directory /home/admin/web/webapp.com/public_html>
AllowOverride All
Options +Includes -Indexes +ExecCGI
php_admin_value open_basedir /home/admin/web/webapp.com/public_html:/home/admin/tmp
php_admin_value upload_tmp_dir /home/admin/tmp
php_admin_value session.save_path /home/admin/tmp
</Directory>
<Directory /home/admin/web/webapp.com/stats>
AllowOverride All
</Directory>
<IfModule mod_ruid2.c>
RMode config
RUidGid admin admin
RGroups www-data
</IfModule>
<IfModule itk.c>
AssignUserID admin admin
</IfModule>
IncludeOptional /home/admin/conf/web/apache2.webapp.com.conf*
</VirtualHost>
Thanks.
Finally I have found an answer...editing the config file of nginx:
proxy_pass http://IP:8082; <--TOMCAT PORT
root /home/admin/web/webapp.com/public_html; <--JSP PAGES PATH
Default config file has the Apache port and apache html pages path.
I suppose this can be done using apache proxy_mod, but I donĀ“t know which way is better...if anyone can explain the two ways(via apache or via nginx) I apreciate it.
Here /Example is my .war file and all file in it in .jsp format.
I have access my .war via http://example.com:8080.
How can I access it via http://example.com?
You can find the anwser in the Tomcat documentation at: https://tomcat.apache.org/tomcat-6.0-doc/config/http.html
You can do one of the following:
1) Edit the conf/server.xml file in your tomcat installation folder. (I assume you are using tomcat, if not - look for an equivalent file for your web server). Here is a sample entry (edit the port here)
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
Restart tomcat.
2) The second way is to use re-directs or url-rewrites to forward traffic to port 8080 to port 80.
Change the http connector port from 8080 to 80 in your tomcat's server.xml. Look for <Connector tag and there you will see port attribute
Rename your WAR file to ROOT.war, the name ROOT for tomcat means that it is the root context (all capital letters) and the name is reserved for such this purpose. See https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming
Next, change the listener port in conf/server.xml from 8080 to 80.
I have a java application.war and I copied the file to tomcat7/webapps directory.
I'm able to access it with www.application.com/application (My domain points to ip 200.xyz.12.jk:8080) BUT
I want to access it through www.application.com (without the name of the folder inside webapps directory)
Also i dont want to allow access to other folders inside webapps.
I have tried some topics but didnt succeed.
Failed to help:
Deploying my application at the root in Tomcat
https://josefbetancourt.wordpress.com/2011/02/12/tomcat7-change-root-app/
Tomcat 6: How to change the ROOT application
Thank you so much
Place your tomcat under apache http server then point it to tomcat's AJP protocol.
Example of Apache httpd.conf configuration:
Listen 80
ProxyPass / ajp://application.com:8009/application
In tomcat server.xml file you should have below ajp connector:
<Connector port="8009" protocol="AJP/1.3" />
As a result www.application.com/ url points to the application entire directory over ajp protocol.
Hope this will help you.
On machine1, I installed apache tomcat 7 listening on port 9999 and copied a sample.html file in ../webapps/dummy folder of tomcat machine.I was able to access the resource with URL http://localhost:9999/dummy/sample.html
On machine2, Tomcat is already part of some product listening on port 8080 which i thought of utilising it for my sample test. So, I copied a sample.html file in ../webapps/dummy folder of tomcat machine. I was unable to access the resource with URL http://localhost:8080/dummy/sample.html
On machine2, I have existing servlet programming modules running in another folder ../webapps/xyz.
My question:
I am trying to understand, What are the list of things that i need to verify on machine, which let me know, why i have an issue in accessing the URL(above) on machine2? Is this something to do with http access configuration like basic.user/basic.groups file?
It has nothing to do with the port on which tomcat is running.
Did you restart Tomcat after copying file over? It might be that on machine2 it's not configured to run in a dev mode so it doesn't pick up changes at runtime.
or
(if this is linux/unix/mac computer) Tomcat on machine2 is running as tomcat:tomcat user, but file you copied can't be read by this user. Change the permissions of the file.
HTH,
Jan
I am crazy about this thing, but i want to make it myself in php itself.
I have installed the following in my system.
WAMP Server 2.2 which includes following
Apache Web Server Version 2.2.222
MySQL Server Version 5.5.24
PHP Version 5.3.13
OS Version Windows 8 64Bit
Location of Hosts file:
C:\Windows\System32\Drivers\etc\hosts
Location of WAMP Server:
C:\wamp
Location of Apache Web Server:
- C:\wamp\bin\apache\apache2.2.22
- C:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf
Location of MySQL Server:
C:\wamp\bin\mysql\mysql5.5.24
Location of PHP:
C:\wamp\bin\php\php5.3.13
I have simple example of Create the VHost in localhost
e.g. I want to create simple domain www.mylocalsite.com on 80 port
For that I have following steps:
(1) Enagle Apache modules
rewrite_module
vhosts_alias_module
(2) Open httpd.conf file to enable Vhost settings
C:\wamp\bin\apache\apache2.2.22\conf\httpd.conf
Virtual hosts
Include conf/extra/httpd-vhosts.conf // Remove the # before Include and save file
(3) Add VHost entry in httpd-vhosts.conf file
<VirtualHost *:90>
DocumentRoot "C:/mylocalsite.com/"
ServerName www.mylocalsite.com
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "C:/mylocalsite.com/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "C:/mylocalsite.com/logs/error.log" // Logs folder should be exists
CustomLog "C:/mylocalsite.com/logs/access.log" common
</VirtualHost>
(4) Add entry in hosts file
Open file in Notepad with Admin Permission C:\Windows\System32\Drivers\etc\hosts
add following line at end of the file and Save it.
127.0.0.1 www.mylocalsite.com
(5) Restart the (From WAMP) Apache Web Server and run in browser http://www.mylocalsite.com/ will work.
Now, My Question is how can I do the above steps in dynamic nature using PHP/JSP or any other language.
Suppose I will create one Form in HTML with following fields and when submit it will create new MySQL entry for that domain.
EDIT:
Domain Type: select option or Radio Options ( Root/Sub-Domain )
Sub-Domain Name ( Optional ): Text field
Domain Name: Text field
Project Path: text field
Log Folder Path: text field
Tmp Folder Path: text field
Database Type: text field ( mysql/pgsql )
<Submit>
when i click on button it will automatically create the domain entry in hosts file, vhosts entry in httpd-vhosts.conf file.
And, when restart the Apache server it will run automatically created domain or sub-domain dynamically.
Can anyone knows how can i established the following things in any language for local system only?
Don't use web form. You can see my demo with batch file:
(1) Create vhost template template.txt
<VirtualHost *:90>
DocumentRoot "_ROOT_"
ServerName _DOMAIN_
# This should be omitted in the production environment
SetEnv APPLICATION_ENV development
<Directory "_ROOT_">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "_ROOT_/logs/error.log"// Logs folder should be exists
CustomLog "_ROOT_/logs/access.log" common
</VirtualHost>
(2) Create add_vhost.bat
#echo off
set /p domain=Domain (www.mylocalsite2.com):
set lineHost=127.0.0.1 %domain%
REM Create the domain entry in hosts file
echo %lineHost% >> C:\Windows\System32\drivers\etc\hosts
set /p folder=Folder (C:/mylocalsite2.com/):
REM Create vhost entry in httpd-vhosts.conf file
setlocal enabledelayedexpansion
for /f "tokens=*" %%i in (template.txt) do (
set str=%%i
set str=!str:_ROOT_=%folder%!
set str=!str:_DOMAIN_=%domain%!
echo !str! >> C:\wamp\bin\apache\apache2.2.22\conf\extra\httpd-vhosts.conf
)
(3) Run add_vhost.bat as Administrator (to write HOSTS file)