XAMPP for Windows - Apache not starting - apache

I was trying to set up multiple websites on my computer, following this tutorial: https://delanomaloney.com/2013/07/how-to-set-up-virtual-hosts-using-xampp/
I stopped apache and then changed two files: hosts and httpd-vhosts.conf.
Here is hosts:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 www.sewing.dev
And httpd-vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/sewing"
ServerName sewing.dev
ServerAlias www.sewing.dev
<Directory "c:/xampp/htdocs/sewing">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
I saved the files and clicked to restart apache. Nothing happens. It says that it's attempting to start but doesn't actually start. I checked the error logs, but didn't see anything that I could understand.
Error log:
[Fri May 22 21:33:45.065111 2015] [ssl:warn] [pid 2136:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri May 22 21:33:46.063513 2015] [ssl:warn] [pid 2136:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri May 22 21:33:55.657529 2015] [mpm_winnt:notice] [pid 2136:tid 384] AH00455: Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.5.15 configured -- resuming normal operations
[Fri May 22 21:33:55.657529 2015] [mpm_winnt:notice] [pid 2136:tid 384] AH00456: Apache Lounge VC11 Server built: Jul 17 2014 11:50:08
[Fri May 22 21:33:55.657529 2015] [core:notice] [pid 2136:tid 384] AH00094: Command line: 'C:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Fri May 22 21:33:55.657529 2015] [mpm_winnt:notice] [pid 2136:tid 384] AH00418: Parent: Created child process 3600
[Fri May 22 21:33:57.654333 2015] [ssl:warn] [pid 3600:tid 276] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri May 22 21:33:58.044334 2015] [ssl:warn] [pid 3600:tid 276] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri May 22 21:33:58.106734 2015] [mpm_winnt:notice] [pid 3600:tid 276] AH00354: Child: Starting 150 worker threads.
[Fri May 22 21:41:40.093670 2015] [mpm_winnt:notice] [pid 2136:tid 384] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Fri May 22 21:41:42.121674 2015] [mpm_winnt:notice] [pid 3600:tid 276] AH00364: Child: All worker threads have exited.
[Fri May 22 21:41:42.449274 2015] [mpm_winnt:notice] [pid 2136:tid 384] AH00430: Parent: Child process 3600 exited successfully.
When I comment out all of the httpd-vhosts.conf file, apache will start.

You need to close your default virtual host directive.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost> # <<< missing closing directiv!!!

Related

Apache2 server failed to start due to error in conf

I am trying to start the apache2 server installed on Ubuntu 22.04 LTS Desktop. However the restart failed and from what I can see in the error log, it is related to my configuration. However I cannot debug further on the exact issue. My apache2 server configuration is as below.
cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIDaemonProcess flaskapp threads=5 python-home=/home/hd2900/Documents/Python/hd2900TakeawayPrint/env
WSGIScriptAlias / /home/hd2900/Documents/Python/hd2900TakeawayPrint/flaskapp.wsgi
WSGIApplicationGroup %{GLOBAL}
<Directory /home/hd2900/Documents/Python/hd2900TakeawayPrint>
          WSGIProcessGroup flaskapp
          Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
When trying to start the server
sudo service apache2 restart
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xeu apache2.service" for details.
Digging further into systemctl status apache2.service it seems that I have an issue on line 18 in my apache2 configuration file. I have checked that line, and cannot see exactly what the issue is.
systemctl status apache2.service
× apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-08-28 00:11:46 CEST; 1min 14s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 4561 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
CPU: 66ms
Aug 28 00:11:45 hd2900 systemd[1]: Starting The Apache HTTP Server...
Aug 28 00:11:46 hd2900 apachectl[4564]: AH00526: Syntax error on line 18 of /etc/apache2/sites-enabled/000-default.conf:
Aug 28 00:11:46 hd2900 apachectl[4564]: Invalid command '\xe2\x80\x86', perhaps misspelled or defined by a module not included in the server configuration
Aug 28 00:11:46 hd2900 apachectl[4561]: Action 'start' failed.
Aug 28 00:11:46 hd2900 apachectl[4561]: The Apache error log may have more information.
Aug 28 00:11:46 hd2900 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Aug 28 00:11:46 hd2900 systemd[1]: apache2.service: Failed with result 'exit-code'.
Aug 28 00:11:46 hd2900 systemd[1]: Failed to start The Apache HTTP Server.
I also checked the error.log and get the below print out. I am still not sure what the exact issue is.
cat /var/log/apache2/error.log
[Sat Aug 27 23:42:48.764507 2022] [mpm_event:notice] [pid 2886:tid 281473433382944] AH00489: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations
[Sat Aug 27 23:42:48.765058 2022] [core:notice] [pid 2886:tid 281473433382944] AH00094: Command line: '/usr/sbin/apache2'
[Sat Aug 27 23:46:40.942688 2022] [mpm_event:notice] [pid 2886:tid 281473433382944] AH00492: caught SIGWINCH, shutting down gracefully
[Sat Aug 27 23:46:41.074596 2022] [mpm_event:notice] [pid 4010:tid 281473172430880] AH00489: Apache/2.4.52 (Ubuntu) mod_wsgi/4.9.0 Python/3.10 configured -- resuming normal operations
[Sat Aug 27 23:46:41.075061 2022] [core:notice] [pid 4010:tid 281473172430880] AH00094: Command line: '/usr/sbin/apache2'
[Sat Aug 27 23:52:16.956956 2022] [mpm_event:notice] [pid 4010:tid 281473172430880] AH00491: caught SIGTERM, shutting down

How to run wsgi and usual site on one apache server?

I have an apache server on VPS powered by centos7.
I have a usual website here, and now I want to add flask application.
httpme.tk is my flask application
mniek.ru is my website
so, the configs looks like that:
/etc/httpd/conf.d/http_error_api.conf
<VirtualHost *>
ServerName www.httpme.tk
ServerAlias httpme.tk
WSGIDaemonProcess application user=apache group=apache threads=5
WSGIScriptAlias / /var/www/http_error_api/wsgi.py
WSGIScriptReloading On
<Directory /var/www/http_error_api>
WSGIProcessGroup application
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
/etc/httpd/conf.d/mniek.ru.conf
<VirtualHost *:80>
ServerAdmin n-i-k-i-t#yandex.ru
ServerName mniek.ru
ServerAlias www.mniek.ru
DocumentRoot /var/www/mniek.ru
<Directory /var/www/mniek.ru>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/www/mniek.ru/logs/error.log
CustomLog /var/www/mniek.ru/logs/access.log common
</VirtualHost>
<VirtualHost *:443>
ServerAdmin n-i-k-i-t#yandex.ru
ServerName mniek.ru
ServerAlias www.mniek.ru
DocumentRoot /var/www/mniek.ru
<Directory /var/www/mniek.ru>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/www/mniek.ru/logs/error.log
CustomLog /var/www/mniek.ru/logs/access.log common
</VirtualHost>
And my /var/www/http_error_api/wsgi.py file:
from sys import path
path.insert(0, '/var/www/http_error_api')
from main import app as application
Apache logs:
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 0.0.26.144. Set the 'ServerName' directive globally to suppress this message
[Sun Jul 19 07:50:35.700799 2020] [lbmethod_heartbeat:notice] [pid 65294] AH02282: No slotmem from mod_heartmonitor
[Sun Jul 19 07:50:35.725938 2020] [mpm_prefork:notice] [pid 65294] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16 mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Sun Jul 19 07:50:35.725986 2020] [core:notice] [pid 65294] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Jul 19 07:55:41.639120 2020] [mpm_prefork:notice] [pid 65294] AH00170: caught SIGWINCH, shutting down gracefully
[Sun Jul 19 07:55:42.784997 2020] [suexec:notice] [pid 65403] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 0.0.26.144. Set the 'ServerName' directive globally to suppress this message
[Sun Jul 19 07:55:42.838510 2020] [lbmethod_heartbeat:notice] [pid 65403] AH02282: No slotmem from mod_heartmonitor
[Sun Jul 19 07:55:42.868170 2020] [mpm_prefork:notice] [pid 65403] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16 mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Sun Jul 19 07:55:42.868215 2020] [core:notice] [pid 65403] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sun Jul 19 08:06:12.281355 2020] [mpm_prefork:notice] [pid 65403] AH00170: caught SIGWINCH, shutting down gracefully
[Sun Jul 19 08:06:13.880590 2020] [suexec:notice] [pid 65576] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 0.0.26.144. Set the 'ServerName' directive globally to suppress this message
[Sun Jul 19 08:06:13.935885 2020] [lbmethod_heartbeat:notice] [pid 65576] AH02282: No slotmem from mod_heartmonitor
[Sun Jul 19 08:06:13.973518 2020] [mpm_prefork:notice] [pid 65576] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/5.4.16 mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations
[Sun Jul 19 08:06:13.973573 2020] [core:notice] [pid 65576] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
The problem is: when I open mniek.ru, I'm getting to my website. Also, when I go to httpme.tk, I'm also getting to my website, not to my flask application. What's wrong?

Rewrite log says it gets applied... but it is not

Im on the end with my knowledge, same for my IT admin.
We setup a new Debian GNU/Linux 8 server
Installed apache and all..
ALL works Except the darn rules. Strange thing is. The rewrite rule log says they are working but the browser from which we open the url dous not.
Here is the complete log from when i open xxx.xxx.xxx/bla
[Fri Dec 16 03:37:04.064896 2016] [rewrite:trace2] [pid 1850] mod_rewrite.c(475): [client xxx.xxx.xxx:22260] xxx.xxx.xxx - - [sccatdev.office.dig/sid#7f35b0df5d20][rid#7f35b0d3c0a0/initial] init rewrite engine with requested uri /bla/
[Fri Dec 16 03:37:04.064936 2016] [rewrite:trace3] [pid 1850] mod_rewrite.c(475): [client xxx.xxx.xxx:22260] xxx.xxx.xxx - - [sccatdev.office.dig/sid#7f35b0df5d20][rid#7f35b0d3c0a0/initial] applying pattern '^/deploy/ajax/(.+)/(\\w+)/(\\w+?)$' to uri '/bla/'
[Fri Dec 16 03:37:04.064944 2016] [rewrite:trace3] [pid 1850] mod_rewrite.c(475): [client xxx.xxx.xxx:22260] xxx.xxx.xxx - - [sccatdev.office.dig/sid#7f35b0df5d20][rid#7f35b0d3c0a0/initial] applying pattern '^/bla/$' to uri '/bla/'
[Fri Dec 16 03:37:04.064950 2016] [rewrite:trace2] [pid 1850] mod_rewrite.c(475): [client xxx.xxx.xxx:22260] xxx.xxx.xxx - - [sccatdev.office.dig/sid#7f35b0df5d20][rid#7f35b0d3c0a0/initial] rewrite '/bla/' -> '/deploy/main.phtml'
[Fri Dec 16 03:37:04.065044 2016] [rewrite:trace2] [pid 1850] mod_rewrite.c(475): [client xxx.xxx.xxx:22260] xxx.xxx.xxx - - [sccatdev.office.dig/sid#7f35b0df5d20][rid#7f35b0d3c0a0/initial] local path result: /deploy/main.phtml
[Fri Dec 16 03:37:04.065062 2016] [rewrite:trace1] [pid 1850] mod_rewrite.c(475): [client xxx.xxx.xxx:22260] xxx.xxx.xxx - - [sccatdev.office.dig/sid#7f35b0df5d20][rid#7f35b0d3c0a0/initial] go-ahead with /deploy/main.phtml [OK]
To clerify, i emptied the logs. and opend exacly 1 time the page i got a 404, but logs say it passed the main.phtml trough.. so... wtf?
For testing i made a simple bla rule:
<VirtualHost *:80>
ServerName xxxx.xxx.xxx
ServerAdmin webmaster#dig.at
DocumentRoot /data1/www/xxxx.xxx.xx/htdocs
DirectoryIndex index.html index.phtml index.php
ErrorLog /data1/www/xxxx.xxx.xx/logs/error.log
CustomLog /data1/www/xxxx.xxx.xx/logs/access.log combined
LogLevel alert rewrite:trace8
#ajax handler for
RewriteEngine On
RewriteRule ^/deploy/ajax/(.+)/(\w+)/(\w+?)$ /deploy/ajax/handler.php?path=$1&class=$2&method=$3 [L,QSA]
RewriteRule ^/bla$ /deploy/main.phtml
</VirtualHost>
yess mod rewrite ext is on... yes we traced the call in the error log... the log is given above... we tried all what google spited out.
Server is a fresh install of:
Distributor ID: Debian
Description: Debian GNU/Linux 8.6 (jessie)
Release: 8.6
Codename: jessie

cant get virtual host to work in wamp

Version:2.5
I know there are many guides to do this but it does not work for some reason and I can't even this is what I did
in Virtual Host
<VirtualHost *:80>
DocumentRoot "D:/wamp/www"
ServerName localhost
<Directory "D:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/elgg"
ServerName elgg.local
ServerAlias elgg.local
<Directory "C:/elgg">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
in Hosts File
127.0.0.1 localhost
::1 localhost
127.0.0.1 elgg.local
::1 elgg.local
in Conf File
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
I did all this but when i type elgg.local it searches for an actual website
last 10 apache lines
[Fri Oct 16 10:33:49.873625 2015] [mpm_winnt:notice] [pid 1576:tid 668] AH00418: Parent: Created child process 1252
[Fri Oct 16 10:33:50.405080 2015] [mpm_winnt:notice] [pid 1252:tid 600] AH00354: Child: Starting 64 worker threads.
[Fri Oct 16 12:09:50.487027 2015] [mpm_winnt:notice] [pid 1576:tid 668] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Fri Oct 16 12:09:52.490354 2015] [mpm_winnt:notice] [pid 1252:tid 600] AH00364: Child: All worker threads have exited.
[Fri Oct 16 12:09:52.606432 2015] [mpm_winnt:notice] [pid 1576:tid 668] AH00430: Parent: Child process 1252 exited successfully.
[Fri Oct 16 12:09:54.598384 2015] [mpm_winnt:notice] [pid 6408:tid 656] AH00455: Apache/2.4.9 (Win64) PHP/5.5.12 configured -- resuming normal operations
[Fri Oct 16 12:09:54.598384 2015] [mpm_winnt:notice] [pid 6408:tid 656] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:42:59
[Fri Oct 16 12:09:54.598384 2015] [core:notice] [pid 6408:tid 656] AH00094: Command line: 'c:\\wamp\\bin\\apache\\apache2.4.9\\bin\\httpd.exe -d C:/wamp/bin/apache/apache2.4.9'
[Fri Oct 16 12:09:54.600385 2015] [mpm_winnt:notice] [pid 6408:tid 656] AH00418: Parent: Created child process 8152
[Fri Oct 16 12:09:54.943610 2015] [mpm_winnt:notice] [pid 8152:tid 580] AH00354: Child: Starting 64 worker threads.
Turns out there was not much, if anything, wrong with the Apache config.
However #Tryhard was using the Google Chrome browser, and that was doing a google search whenever the URL elgg.local was entered and not using it as a domainname. IE did not make this mistake, so it must be a Chrome issue!
The popular solution, that I have used before, of
Enter chrome://flags in the address bar and set "Built-in Asynchronous DNS" to "Disabled", then restart the browser. No longer seems to work as that option is no longer available in the flags parameters.
Dont know if this is a Chrome bug or just an oddity, but the only solution we could come up with was to add a trailing / to the domain name. That made Chrome use the url rather than start a search!
So elgg.local did a search
and elgg.local/ ran the website code.
If you ever get odd unexpected behaviours while using Chrome, always try FF and/or IE before anything else, to make sure the same things happen as Chrome seems to have quite a few odd behaviours when dealing with local development websites.

Laravel route not working in Apache using custom port in virtual host

I have a server running Linux. Its a VM with ip 10.61.0.3. Currently used to serve my web located at /var/www/html at port 80.
I want to serve Laravel app from this server located at /var/www/laraapp to port 8080.
My current apache conf for virtual host is:
<VirtualHost *:8080>
ServerName 10.61.0.3:8080
DocumentRoot /var/www/laraapp/public
</VirtualHost>
When I access 10.61.0.3:8080 nothing is shown up. Here is what show on apache error_logs:
[Mon Mar 17 17:28:43 2014] [notice] caught SIGTERM, shutting down
[Mon Mar 17 17:28:48 2014] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Mon Mar 17 17:28:48 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 17 17:28:48 2014] [notice] Digest: generating secret for digest authentication ...
[Mon Mar 17 17:28:48 2014] [notice] Digest: done
[Mon Mar 17 17:28:48 2014] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.4.7 configured -- resuming normal operations
[Mon Mar 17 17:28:48 2014] [error] avahi_entry_group_add_service_strlst("10.61.0.3") failed: Invalid host name
What should I do?
Note:
I can run my larapp using builtin PHP web server.
LoadModule rewrite_module modules/mod_rewrite.so is uncommented in /etc/httpd/conf/httpd.conf
Listen 8080 already declared in /etc/httpd/conf/httpd.conf
In Apache documentation, ServerName should something like domain name http://httpd.apache.org/docs/2.2/mod/core.html#servername
Try to change ServerName 10.61.0.3 to ServerName example.com.
Don't forget to add 127.0.0.1 example.com into your /etc/hosts.
If you want VirtualHost runnning on port 8080, you must define NameVirtualHost http://httpd.apache.org/docs/2.2/vhosts/examples.html#port
For example:
Listen 8080
NameVirtualHost 10.61.0.3:8080
<VirtualHost 10.61.0.3:8080>
ServerName example.com
DocumentRoot /var/www/laraapp/public
</VirtualHost>