Apache server in port number 80 - apache

Though the question asked seems to be very ridiculous but I am practically facing this and left with no option but to ask it.
In httpd.conf file whenever I give port no other than 80 it works fine but if I give port no 80 after some time or may be from beginning it stops working means I am not able to get the desired web page though
when I try netstat -ano it shows that apache server is running on port no 80.
previously IIS7 was working on port no 80.I stoped the process.

Locate your apache config and search for:
Listen 80
change 80 to your desired port
Next you may want to change the vHost setting. Find whereever your vhost settings are located (mostly conf/extra/httpd-vhosts.conf) and locate something like this:
<VirtualHost *:80>
ServerAdmin mail#domain.tld
DocumentRoot "path/to/my/document/root"
ServerName subdomain.domain.tld
ErrorLog "path/to/my/error/log/domain.error.log"
CustomLog "path/to/my/access/log/domain.access.log" common
</VirtualHost>
change the 80 here again to your desired port. Restart your apache.
If youre working on unix:
service apache22 start
service apache22 stop
(commands for apache 2.2)
on windows:
net stop apache2.2
net start apache2.2
(commands for apache 2.2)
Greetings
(make sure your firewall doesnt block your desired port and its not used by another programm. For additional help you should always check your error logs.

Related

What is wrong with my apache Virtual host setup?

I have set up the virtual host like its displayed in the apache documentation:
NameVirtualHost Localhost:8080
<VirtualHost Localhost:8080>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot D:\Users\daniel_diezel\Apache24\htdocs
</VirtualHost>
<VirtualHost Localhost:8080>
ServerName www.otherdomain.tld
DocumentRoot D:\Users\daniel_diezel\Apache24\htdocs
</VirtualHost>
After i saved it and started the httpd.exe the following error accured while starting Apache:
`
(OS 10013)Der Zugriff auf einen Socket war aufgrund der Zugriffsrechte des Sockets unzulõssig. : make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs`
But if i change the Port to 8080 its working.
But the problem no is when the apache starts i cant find the server when i type https://domain.ltd in my browser but if I go for Localhost:8080 it shows me the index file on the site.
What can i do to fix it?
There seems to be two different issues. According to your file structure I assume you are using Windows.
Port usage
Port 80 might be already in use. Open CMD and type netstat -ano and find all processes using port 80 apart from the system process (typically PID 4). Identify the processes by using the command tasklist and look for the PIDs using port 80 from the step before.
Now open your task manager and stop all processes if they are not relevant to keep your system running. Now the port binding error should be gone.
Accessing local domain names
domain.tld is resolved by your configured DNS-provider, so it is looked up to be found in the internet. If you want to resolve domain-names locally (before reaching out for the DNS) you have to add it to your host file.
Open C:/Windows/drivers/etc/hosts with a editor of your choice an add the following line:
127.0.0.1 domain.tld
Now everything should work as expected. If you want to use different ports you can also use 127.0.0.1:port domain.tld

Cant Run http://localhost instead of http://localhost:8012

I try configure my localhost XAMPP on like these step How to change XAMPP apache server port?
But when i try restarted my apache and try open http://localhost instead of http://localhost:8012. It said HTTP Error 404. The requested resource is not found.
My suggestion problem :
on file http-ssl.conf i cant found line ServerName localhost:443
Maybe that my problem cant instead http://localhost instead of http://localhost:8012?? Or did i missing something, if i try open http://localhost:8012 is working.
My XAMMP version is 3.2.2 and my apache is Apache2.4, windows 7. And idk i'm using IIS or not because is not my own computer but is my computer office.
Just in case, the full answer does not answer the question. Only some parts do.
If I understand your question, you want to run your website on http://localhost. I just want to clarify that the normal localhost runs on port 80 i.e. http://localhost:80.
So, port 80 and just the localhost aren't different, so please don't get confused. You should not worry about httpd-ssl.conf, you shouldn't have to change it. The configuration is in the main conf: httpd.conf. And, I don't think the link you've given in your question is similar.
Can you access localhost using https://localhost
After all, I think, you want to change your port from 8012 to 80 (http default).
Please follow the following steps to change the port.
1) Click on Config after opening XAMPP
2) Click on Service And Port Settings
3) Change the port to 80 from your current port
If it still has the same error, do this:
Take a backup of httpd.conf before doing the following.
1) Edit your httpd.conf, change the following.
Listen 8012
To:
Listen 80
If still not working, go ahead and add the following at the end:
<VirtualHost *:80>
ServerAdmin your#email.com
DocumentRoot "C:\path\to\website"
</VirtualHost>
Thanks.
Edit:
The only way you could do this is by running your XAMPP server on a different IP like 127.0.0.2
So, try the following:
Edit httpd.conf and say:
<VirtualHost 127.0.0.2:80>
ServerAdmin your#email.com
DocumentRoot "path to htdocs"
</VirtualHost>
Go to the C:\Windows\System32\drivers\etc
Edit hosts file:
For some time, please add something like this.
127.0.0.2 localhostt
Also
You could also change the port of the application that is running on port 80
Open up the CMD
Run the following command:
netstat -aon | findstr "80"<br>
And get the info of something like:
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 11560<br>
Get the info of the last number i.e is in this post is 11560
Run the following after that
tasklist | findstr "11560"<br>
Replace 11560 to the number that you got running the previous command
And you will know what app is running in the port
My Last Guess:
The new way I found out is by doing this:
Change the listen directive to:
Listen 127.0.0.2:80
Go to the C:\Windows\System32\drivers\etc
Edit hosts file:
Try this:
127.0.0.2 localhost
OR
For some time, please add something like this.
127.0.0.2 localhostt
Hope it works.

MAMP Virtual Hosts not working properly, loading 'It Works!' page

I had an issue last night where MAMP just refused to connect to the Apache server(unsure whether this has something to do with my issue). I decided to uninstall and reinstall. I was able to connect once again, however, when I added my virtual host to the httpd-vhosts.conf file in my MAMP folder, and navigate to it I get brought to a 'It works!' page. (I also realised I get this page by typing localhost even without running MAMP?)
Below are some of my files
httpd.conf(in MAMP)
//Uncommented line below
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
httpd.conf(in MAMP)
NameVirtualHost *:80
<VirtualHost *:80>
ServerName portfolio
DocumentRoot '/Applications/MAMP/htdocs/portfolio'
</VirtualHost>
<VirtualHost *:80>
DocumentRoot '/Applications/MAMP/htdocs'
ServerName localhost
</VirtualHost>
/private/etc/hosts
##
# Host Database
# localhost is used to configure the lookback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 portfolio
This is a copy paste of what I had before which worked 100%, unsure what happened between MAMP stopping working, the uninstall and reinstall. Is there an issue with apache somehow overwriting something? Really out of my depth here with this issue. Is there somewhere else I should be looking to debug this?
For reference, localhost:8888 & localhost:8888/portfolio work as expected, localhost/ & portfolio/ don't, brings me to the 'It works!' page. Before this issue I was able to do 'localhost/phpmyadmin' to bring me to phpmyadmin and 'localhost/portfolio' to bring me to that directory, but neither of those work either. I've been wracking me brain for hours over this, watching tutorials and reading other answers but to no avail.
Anyone have any idea why this is occuring? Any help would be greatly appreciated.
So I eventually figured it out if anyone else has the same issue. I had forgotten previously that I had my localhost running on port 80. However when I tried that before my apache server wouldn't start on MAMP, the reason being was due to port 80 being used by /private/etc/apache2, so I used the answer to this question
https://superuser.com/questions/986775/how-can-i-remove-apache2-that-i-have-installed-in-mac-os-x
to remove apache. (Alternatively I guess you could just change the port number it listens to in the httpd.conf files?) I then changed my MAMP to listen to port 80 and this fixed my problem. Hope this helps anyone else with same issue

XAMPP (WIN7) port change and vhosts

I've decided to change the ports for Apache to clear up some conflicts with other applications, and maybe even give IIS a shot in the future. I've run into the problem described below.
The basic context:
WIN 7 x64
XAMPP 1.7.4 (Apache 2.2.17, MySQL 5.5.8, PHP 5.3.5)
So I've changed the default Apache port from 80 to 8080, by changing this in the httpd.conf:
Listen 8080 (was Listen 80)
ServerName localhost:8080 (was ServerName localhost)
In my vhosts file I have:
NameVirtualHost 127.0.0.1:8080
And several virtual hosts defined like this:
<VirtualHost 127.0.0.1:8080>
DocumentRoot "somepath"
ServerName servername
<directory "somepath">
usual stuff here
</directory>
</VirtualHost>
When I try to access the virtual host using the servername defined above it does not work without explicitly specifying the port:
servername:8080
It would also seem that the port defined in the vhosts file does not make any difference, whatever I tried (80, 8080, nothing), it allways requires the port to be given with the server name.
phpinfo() says:
SERVER_PORT: 8080
Apache error logs do not show any errors.
I guess I'm wondering if this is normal behaviour, or there is something I overlooked.
The 80 port is default for browsers so that's why you don't need to access servername:80. In your case it's normal to acces server like this : servername:8080
If your want to access localhost without specify the port number in the URL http://localhost instead of http://localhost:8080.
Open Xampp Control Panel
Go to Config ► Service and Port Settings ► Apache
Replace the Main Port value ​​with 8080.
Save Service settings
Save Configuration of Control Panel
Restart the Apache Server

How can I get Apache HTTP Server 2.2 and IIS 5.1 to both work on my localhost?

I figured the easiest thing to do was to just change the port number that Apache listens to, but I still can't get it to start back up after installing IIS. My IIS currently serves up pages correctly at http://localhost:80. I have several PHP projects, and here are the basics of how ports are configured in my httpd.conf:
Listen 81
# Begin listening for virtual hosts.
NameVirtualHost *:81
<VirtualHost *:81>
# virtual.myvirtualdomain.com virtual host.
ServerAdmin webmaster#virtual.myvirtualdomain.com
DocumentRoot "c:/Development/HTTPServer_WWW/virtual.myvirtualdomain.com/www"
ServerName virtual.myvirtualdomain.com
ErrorLog "c:/Development/HTTPServer_WWW/virtual.myvirtualdomain.com/logs/log"
<Directory "c:/Development/HTTPServer_WWW/virtual.myvirtualdomain.com/www">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Then in my Windows hosts file I have an entry like this:
127.0.0.1 virtual.myvirtualdomain.com
I have several of these virtual domains setup, all running locally for numerous PHP projects I'm working on currently. This was all working correctly on port 80, but then I installed IIS 5.1, and the service no longer starts up. I did some research, and they can't both be running on the same port. I changed it so Apache looks to port 81 now, but it still will not start.
EDIT:
So, I uninstalled IIS, and now I can't get Apache HTTP Server to startup at all still. I changed all of the settings back to port 80, and it is still failing.
Stop the service, then run Apache from the command line. It will show you the errors occuring during start up.
I did what Haarsma suggested, and it turns out that I had removed a virtual directory, and so Apache couldn't find it (thus not starting). Apparently it had nothing to do with the ports at all, and was my dumb mistake. I reinstalled IIS, changed my config for Apache to listen on port 81, and it works!
Stop the iis server and see if apache starts.
In command line, run:
netstat -ano
this will tell you which process ID runs on which port.
Disable windows firewall
It's very strange! I have IIS 6.0 and Apache 2.2 working together correctly on my Windows Server 2003. IIS on port 80, Apache on port 8081, both services set to run automatically.