Basic Apache commands for a local Windows machine - apache

I have installed XAMPP on my Windows 7 machine and created a number of virtual servers. This part is straightforward enough.
Each time I add a new virtual server I am having to reboot my computer in order to reboot the Apache server, which is of course quite time consuming.
I have googled and found the correct console commands to use to reboot Apache, but absolutely non of the references that I have found actually tell you where to type the relevant commands! A certain level of knowledge is assumed.
So my question is - where do I actually type apache -k restart?

Going back to absolute basics here. The answers on this page and a little googling have brought me to the following resolution to my issue.
Steps to restart the apache service with Xampp installed:-
Click the start button and type CMD (if on Windows Vista or later and Apache is installed as a service make sure this is an elevated command prompt)
In the command window that appears type cd C:\xampp\apache\bin (the default installation path for Xampp)
Then type httpd -k restart
I hope that this is of use to others just starting out with running a local Apache server.

For frequent uses of this command I found it easy to add the location of C:\xampp\apache\bin to the PATH. Use whatever directory you have this installed in.
Then you can run from any directory in command line:
httpd -k restart
The answer above that suggests httpd -k -restart is actually a typo. You can see the commands by running httpd /?

Related

Does file copy deployments work with CakePHP?

I have a legacy CakePHP(1.3.13) app, running on Ubuntu server 16.04, on apache. It is using php 5.6. I'm trying to migrate the app to a development server, also Ubuntu 16.04, but running php 7.2.
On the production machine, php file(s) are being executed even before line 1 of index.php in the app I'm trying to migrate. On the dev box, this isn't happening.
I've sudo tar'ed the entire web server tree, and sudo untar'ed it on the dev box. I've copied the apache site configs, and only edited them for hostnames.
I don't understand why apache is running one or many php files PRIOR to running index.php on the production box. It is apparently loading a custom configuration php file, that sets up some global variable, but for the life of me I can't figure out why this is happening. I'm sure I'm just missing something dumb.
Greg Schmidt nailed it. There was a second auto_prepend_file=MagicallyExecutingScript.php in the php.ini.

Where can I find httpd.conf file for Apache on my windows?

I am trying to fix one venerability on my production web server(Apache), Venerability is "The HTTP headers sent by the remote web server disclose information that can aid an attacker, such as the server version and technologies used by the web server"
For this I have gone for some solutions , some where I found that to solve the above Venerability we need to edit the httpd.conf file on server but I did not find httpd.conf file in my entire system (using windows 10 os) can any one please let me know hot find that file or how to resolve that Venerability on production ?
You can find httpd.conf in
installed folder ex Apache24
Apache24/conf/httpd.conf
On Windows, I have seen people run Apache from all kinds of weird and wonderful places.
You need to track down where your Apache instance is running from, normally its running as a service on windows. If you open the properties on the service and look at the Path to executable, it should be something similar to the below.
"C:\Program Files\Apache24\bin\httpd.exe" -k runservice
Or it could be
"D:\Some Application\Version\WEB\tool\SOFTS\HTTPD\bin\httpd.exe" -k runservice
Unless there is an -f flag, setting the location of the conf. There will be a "conf" folder at the same level as the "bin" folder regardless of the path. This location is set at compile time so unless you have bespoke version off Apache this should be the location.
If you are struggling to find the service or a launcher that is running Apache. You can use WMI with a WQL query to look for processes which are called httpd.exe and get its executable path.
wmic process WHERE name="httpd.exe" GET ExecutablePath
In Xampp Control panel, in apache row, click on "config" button and then you see the term Apache(httpd.conf).

Apache2 Not Responding: Bitnami Magento Install (Legacy)

For reasons too insane to even go into, I am attempting to install using the Bitnami Magento 1.9.2.4 image on a fresh Amazon AWS/Lightsail Ubuntu 16.04 instance (2gbs to avoid complaints and be sure I don't run into anything unnecessary).
I think this is really more of an Apache question. After I finish the install (success), I can't get the server to respond via the instance IP address at the default port (8080).
Regarding the old Bitnami Image, you can get (or wget) that Magento 1.9.2.4 image still, it's over here:
wget "https://downloads.bitnami.com/files/stacks/magento/1.9.2.4-3/bitnami-magento-1.9.2.4-3-linux-x64-installer.run"
So for the sake of anyone who's trying to work through the whole process, once you pull the above down to your instance you need to chmod the above file to 755. This assumes you are in the directory with your download:
chmod 755 bitnami-magento-1.9.2.4-3-linux-x64-installer.run
Then run it using it's full path, like:
/home/ubuntu/bitnami-magento-1.9.2.4-3-linux-x64-installer.run
So the install is going to ask a bunch of questions, for anyone keeping track my answers were all yes (ie. yes to Git, PhpMyAdmin, Beetailer... whatever that is).
Then I created an admin user / password etc.
As far as the port I didn't have anything running on 8080 so the install defaulted the port to 8080 with HTTPS on 8443 with MySQL on 3306 (more on ports in a minute).
I think Host/Domain is one of the keys to this problem. When I couldn't get the server to respond I just recreated an instance and tried a different Domain during the install process. I tried: internal AWS IP, External ACTUAL IP, 127.0.0.1
Here's what the Magento 1.9 Domain prompt looks like:
So basically that sort of brings us up to date.
Once I finished the install, like a normal human used to using bitnami as a cloud image I assumed the server would respond at whatever the default path was at the IP address it was running on. Ie:
BASEIPADDRESS:8080/magento
Not the case. When I hit that the server does NOT respond, hence the question. In addition to the above I have also tried the BASEIPADDRESS, and the BASEIPADDRESS:8080
Results checking open ports
So since the server is not responding I figured I would check the ports.
First I checked using netstat:
netstat -lntu
I got back:
Then I realized that netstat is now depreciated... so I went with:
ss -lntu
I got back:
(excuse the images, formatting wouldn't work for text)
To me it looks like 8080 (default) is open in both of those results. So why isn't the server responding at the default location?
#Bitnami Status = OK
Checking the status with:
/home/ubuntu/magento-1.9.2.4-3/ctlscript.sh status
Everything looks good:
apache already running
mysql already running
Memcached not running
Since it says Memcached was not running, I started memcached to see if that was the issue, no it was not.
I can access the instance via SSH and yes I am sure the IP is right. See images above.
I also posted this to the Bitnami community but haven't heard anything over there. Will cross populate as I get ideas.
It looks to me that you configured Magento using the private IP address, so you would not be able to access from your browser. A way to check it is by executing the following command in your machine:
curl -L 127.0.0.1:8080/magento
If that provides output, then the IP is misconfigured, so you would need to reinstall using the proper IP
So this ended up being PRIMARILY due to not running the Bitnami stack installer as root / sudo:
sudo /home/ubuntu/bitnami-magento-1.9.2.4-3-linux-x64-installer.run
Why Install with Sudo on AWS/Lightsail?
So the reason you need to install as sudo has to do with the fact that when run as the normal user (ie. not root) the installer defaults to port 8080 which is NOT open on aws by default. To complicate matters further you may not be able to get things running properly even if you manually swap to port 80 AFTER you run the installer.
To avoid a scenario where port 80 requires root access to utilize I just re-created my instance and ran the installer as root with the above command.
Host Setting
During install I selected the public IP for the "Host" prompt and everything worked as I thought it might (straight out of the box).
Thanks to Javier Salermon who put me on the right track and the devs at Bitnami for cueing me into the fact that 8080 is not open by default.

I can't get Apache to work for some reason

For some reason Apache just doesn't seem to want to work. I have been trying so many things to try and fix it but with no luck. At first there was programs blocking port 80. A few of the programs I tried to stop on port 80 are skype, World Wide Web Publishing Service, IIS(Internet Information Services), and NT Kernal & System. Then I ran Apache in the cmd. I typed: cd:/apache/bin then I typed httpd.exe but nothing happened and the cursor just kept blinking on the next line. I also went to ApacheMonitor in the bin file and ran that, then went to the little icon on the bottom and clicked start but it just said The requested operation has failed! I don't know what to do now.
I have windows 7.
I would recommend to Install Apache as a service.
However, if you want to start Apache via command prompt. First thing you check if the syntax in your conf files is ok. Open a command prompt as an Administrator. Change to Apache bin directory and use below command.
httpd -t
If it returns Syntax OK, that's a good news. Errors will be displayed if any. Fix all errors.
Once syntax looks ok, run below command to start Apache.
httpd -k start
It should start your Apache. If it doesn't check /logs/error.log and see what's going on.
Good Luck!

XAMPP Apache won't start

I am using Windows 8 Pro. I have just installed XAMPP Windows 1.8.1.
I tried to start Apache from the XAMPP control panel but it wont start. It gives the following error.
Also I have no IIS Services running, Web Deployment Agent Service also not running, World Wide Web Publishing Service also not running..
What could be the problem? Can anyone please help?
Error Log
To Windows users:
You can easily "debug" this error by calling the apache httpd-service directly.
Go to XAMPP\apache\bin
Open a cmd-shell or Powershell here (From explorer: 'Shift' + 'right click' on a blank area in the folder)
enter httpd.exe
read the output
It is usually something within one of the many *.conf-files in the XAMPP\apache\conf\extra folders.
As previously mentioned above in the comments - and tested out myself:
This error is rather ambiguous. Therefore, you should check the error.log located at \xampp\apache\logs
When I had this issue, it was because Skype was already listening on port 80 & 445. I was able to get around this by exiting Skype, starting the Apache service, and then restarting Skype. You can check the current port listeners by opening a command prompt and typing Netstat -a
It is also recommended to have User Account Control OFF as it may block some features built into xxamp.
Prior to this though, I had an issue after I modified my Apache httpd.conf file. Reverting those changes (or reinstalling in the user's case) will resolve that issue.
I am using Window 7 and It was same problem with me,I am using Skype and Not start Apache, but finally solved this problem, and It's working now
Check connection setting
In Skype click tools -> click option -> click Advanced -> click connection
Unchecked port number and click Save.
I had this problem as well in XAMPP [XAMPP Control Panel v3.2.1] on Windows 8 64bit.
The first thing I done was to use the "Take Ownership" command (see below for a link) and this created a better error message.
From the error message above it changed to:
5:49:08 p.m. [Apache] Problem detected!
5:49:08 p.m. [Apache] Port 80 in use by "C:\Program Files (x86)\Skype\Phone\Skype.exe" with PID 4968!
5:49:08 p.m. [Apache] Apache WILL NOT start without the configured ports free!
5:49:08 p.m. [Apache] You need to uninstall/disable/reconfigure the blocking application
5:49:08 p.m. [Apache] or reconfigure Apache and the Control Panel to listen on a different port
Closing skype fixes this, reopening skype allows it to change the port number itself.
Adding this only because Google finds this error as the best result for "xampp apache wont start". Sorry for posting on an older issue.
Take Ownership Command: http://www.eightforums.com/tutorials/2814-take-ownership-add-context-menu-windows-8-a.html
Look in the control panel: the service has not been installed yet!
Click the (X) button to install apache in windows service and reboot, it should be working now.
I had the same error, the error logs where empty, I ended up installing Apache as a service via XAMPP.
Now when I try and start Apache I at least get some informative errors in Windows Event Viewer.
Turned out to be a missing directory for a vhost, easy fix, however I was only able to view this error when attempting to start Apache as a service.
First of all, after installation restart windows. As strange as it may be, this does matter. Also, check all apps occupying port 80 (e.g. Skype).
Finally, what resolved my situation - port 443. VMWare have been using this port. AFter killing the VMWare process, Apache worked just fine.
I reinstalled it in another drive and that fixed it. But I have no idea what caused the problem in the first place.
For Linux Users:
The solution:
In terminal: sudo /etc/init.d/apache2 stop
Edit: If you still get this kind of error at next computer start then you probably have apache2 process starting at computer startup.
To prevent apache2 starting automatically at startup:
cd /etc/init.d/
sudo update-rc.d -f apache2 remove
Reboot your computer and now hopefully you can turn on Apache from the XAMPP Control Panel!
I commented Listen 443 directive in httpd-ssl.conf located on C:\xampp\apache\conf\extra, and that did the trick for me. Next restart Apache was green
I had the same problem. I started the Xampp Control Panel as an Administrator. That worked.
Some process is using the port 443, so you can change the port that is used by xampp, to be able to use it. For this job you have to do this:
1- Open httpd-ssl.conf in xampp\apache\conf\extra
2- Look for the line containing Listen 443
3- Change port number to anything you want. I use 4430. ex. Listen 4430.
4- Replace every 443 strings in that file with 4430 and save the file.
I experienced this issue and I preferred to free up the port .80 and my XAMPP/Apache restarted again.
This is how I made the port .80 free.
First:
-Open a command prompt and type this :
netstat -aon | findstr :80
You'll get this display:
Then type this command:
tasklist /fi "pid eq 4"
You'll get the name of the process using the is displayed. Now, press:
Win+R
services.msc in the invite, then press Ok.
Now you can start stopping all services which can use the port .80.
Find some of them here: W3SVC,WAS,SSRS,PeerDistSvc,NcbService.
After trying all the suggestion given above. Disable this, install that. I opened the xampp-control manager from the start but this this as administrator. After I opened it. MySQL was disable. I disable all of the program and enable apache first and then MySQL. Suddenly start working with no problem.
I gave all users full access on the xampp folder, inclusive subdirectories. Afterwards it worked.
Open services.msc directly from command prompt and disabled SQL Server reporting services
& SQL Server analysis services.
I had the same case .
The reason was that I had changed htdocs folder location to another drive and although made appropriate configuration, for physical reasons, when starting apache the drive was not accessible:
After making it accessible the problem has been solved .
Generally it seems logical that when apache doesn't find all of the components it won't start.
i had the same problem but after i went into the readme, i realised that i didn't have Microsoft Visual C++ 2008 Redistributable installed. after i instaled it, all worked just fine
Although this person's question seems to have been answered, I just wanted to add that I received this error because I had a typo in my httpd-vhosts.conf file (got in a hurry and didn't specify a port on the VirtualHost tag).
If you have skype shutdown and the problem still persists. Try this. It could be that apache is set to automatic on restart. Meaning apache is already using that port. Go to services in your XAMPP control and look for apache (whatever version you have). Look for startup type and double-click it to set it to manual.
Hope this works!
If it helps to anyone, I currently use VMWare Workstation in my computer, and it also blocks Apache from starting, because VMWare Workstation listens for requests on port 443.
You can either comment out "listen 443" inside the "httpd-ssl.config" or you can disable "Shared VMs" from VMWare Workstation General Preferences.
If you use your skype ports, turn the ports off from the skype settings->Connections and unmark the port like where it says ports 80 till 443.