How to change port number of Apache server in ubuntu - apache

I want to change my port number 80 to some other number of my Apache server . how it possible in ubuntu

Change your virtal host on any OS, ubuntu path is something like /etc/apache2/apache2 config or something.
#Virtual host for YOURSITE
<VirtualHost *:4343>
ServerAdmin john.doe#jd.com
ServerName webpage.dev #same as in your /etc/hosts file
DocumentRoot /var/www/yoursite
DirectoryIndex index.html
<Directory /var/www/yoursite>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/yoursite_error.log
#CustomLog /var/log/apache2/customLog.log #for ubuntu
</VirtualHost>
Hope this will help you, you should read about apache coinfiguration...
Here's a great link https://www.digitalocean.com/community/tutorials/how-to-configure-the-apache-web-server-on-an-ubuntu-or-debian-vps

You can create a virtual host configuration file in /etc/apache2/sites-available
Example :--
<VirtualHost *:8080>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
. . .
and you have to change Listen port on /etc/apache2/ports.conf
EX:--
Listen 8080

Related

XAMPP can't see virtual host

I am trying to create virtual host with xampp but it seems my apache configuration can't read host I created.
Every single time when I'm going to moodle36.dev/moodle/install.php in my browser it's reading xampp/htdocs/moodle instead of moodle from vhosts
That's my htttpd-vhosts.conf
NameVirtualHost *80
...
<VirtualHost *:80>
DocumentRoot "C:/xampp/vhosts/moodle36.devel"
ServerName moodle36.dev
ServerAlias www.moodle36.dev
<Directory "C:/xampp/vhosts/moodle36.devel">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
That's httpd.conf
<Directory />
AllowOverride all
Allow from all
</Directory>
DocumentRoot "C:/xampp/htdocs"
<Directory />
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
<Directory "C:/xampp/htdocs">
...
</Directory/>
I uncomented
Include conf/extra/httpd-vhosts.conf
and System32/drivers/etc/hosts
127.0.0.1 moodle36.dev
I'm completly stuck and i would apreciatte any kind of help.
It might be because .dev is an existing top level domain.
Try .localhost or something that isn't in this list:
https://www.icann.org/resources/pages/tlds-2012-02-25-en

virtual host setup in xampp, won7

I install XAMPP(OS : win 7 ) in D drive. Document root is D:/xampp/htdocs
When I open localhost/xampp/ then it open . No problem
I create virtual host zf2.local as bellow and it's working fine.
<VirtualHost zf2.local:80>
ServerAdmin webmaster#localhost
DocumentRoot "D:/xampp/htdocs/WORK/zend/public"
ServerName zf2.local
</VirtualHost>
But when I configure like bellow then it's show forbiden
<VirtualHost zf2.local:80>
ServerAdmin webmaster#localhost
DocumentRoot "D:/WORK/zend/public"
ServerName zf2.local
</VirtualHost>
Actually I want to set document root outside the htdocs & both should work means localhost as well as virtual host. please help me.
<VirtualHost *>
ServerAdmin admin#localhost.com
DocumentRoot "C:/xampp/htdocs" # change this line with your htdocs folder
ServerName localhost
ServerAlias localhost
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Read this article for further help
This should solve your problem:
<Directory "D:/WORK/zend/public">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
Require all granted
</Directory>
OR
<Directory "D:/WORK/zend/public">
Allow from all
Require all granted
</Directory>

XAMPP Windows Apache vhosts not redirecting properly

<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
<Directory "C:/xampp/htdocs/">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/gl"
ServerName gl.dev
<Directory "C:/xampp/htdocs/gl">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
The above is what I currently have in my vhosts file. When I hit localhost I want my root to open, but when I load gl.dev I want the individual site to open. Any ideas?
hosts file:
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 gl.dev
I think in windows you have to use backslash when specifying document root. please try the following
<VirtualHost *:80>
ServerName localhost
ServerAlias *.localhost
DocumentRoot "C:\xampp\htdocs\"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName gl.dev
ServerAlias *.gl.dev
DocumentRoot "C:\xampp\htdocs\gl"
<Directory />
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Restart WAMP server

2 domains pointing to 1 server (2 different subfolders)

OK, so, I think the title is rather self-explanatory.
I've set up my own Apache server (on Debian) and hosting 2 different sites (let's say mysite1.com at /home/www/mysite1, and mysite2.com at /home/www/mysite2).
In my domain name registrar setup page (Dynadot actually), I created A records (still not sure what this is exactly...) for both of them, pointing to my server's ip...
Now, on the server's side, here'e what my .conf file looks like (/etc/apache2/sites-enabled/mysite actually)
<VirtualHost *:80>
DocumentRoot /home/www/mysite1.com
ServerName www.mysite1.com
ServerAdmin drkameleon#gmail.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/www/mysite1.com>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin
<Directory "/home/www/mysite1.com/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot /home/www/phpmyadmin
ServerName www.mysite1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/www/mysite2.com
ServerName www.mysite2.com
ServerAdmin drkameleon#gmail.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/www/mysite2.com>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Now, the thing is. Now matter which site I visit (1 or 2), I always get mysite1's contents.
What am I doing wrong? Any ideas?
There are multiple possibilities of what could go wrong.
Do you have
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
somewhere in the config? (http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost)
Without that config entry Apache is not sensitive to domain names in dispatching requests to virtual hosts.
It's just a guess.
Make sure Apache has been reloaded after any changes to the config!

Erro Setting up VirtualHost for folders belonging to same domain

Noob Here.. I have the following folder structure on my Ubuntu Machine
/var/www/
/folder1
/folder2
Now i want to redirect my url xyz.com to folder1 & xyz.com/blog to folder2. I am using the following Vhost Config file
For xyz.com to folder1
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName xyz.com
ServerAlias www.xyz.com
DocumentRoot /var/www/folder1
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
.......
</VirtualHost >
And for xyz.com/blog to folder2
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName xyz.com/blog
ServerAlias www.xyz.com/blog
DocumentRoot /var/www/folder2
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
.......
</VirtualHost >
When i enter xyz.com in url, it serves me index file from folder1(As expected & correct) but when i enter xyz.com/blog it shows 404:Not found Error
Not Found
The requested URL /blog/ was not found on this server.
Apache/2.2.22 (Ubuntu) Server at socialcosmo.com Port 80
I have spent hours on this and still unable to figure out the problem :(
Any help would be greatly appreciated
There's no such thing as a host (domain name) with a path in it. xyz.com/blog is not a valid ServerName.
Delete the second virtual host and add an alias directive to your first one.
Alias /blog /var/www/folder2