Conflict between internal and homebrew installed apache - macos

Helo everyone, my lap is undergoing some conflict in case of internal apache (mac provide built in apache server) and home brew installed apache.. So that I cant access my localhost. Can anyone fix this?
Which -a httpd (terminal command) result two output ,
/usr/local/bin/httpd (home brew installed apache
/usr/sbin/httpd (default apache)
Whereis httpd (terminal command) results
/usr/sbin/httpd (it seems default apache)
But when I check httpd -V in terminal it gives path of homebrew intalled apache
I don't know which server is running internal or homebrew installed apache. I want to uninstall this homebrew installed apache and use default apache...

Related

Changing default Apache version on Mac OS

A security sweep of my network (using Nessus) revealed that my mac is running a version of Apache (2.4.46) with a few critical vulnerabilities. I've been told I need to upgrade to at least 2.4.47. I'm having issues getting MacOS to use the upgraded version over the default one:
The default httpd is located at /usr/sbin/, which is read only even as root. As far as I'm aware upgrading the default Mac OS version is not a possibility.
Installed a newer version of Apache (v2.4.48) using Homebrew. The homebrew version is located in /usr/local/bin/httpd and as long as /usr/local/bin is before /usr/sbin in the env path it should be the preferred version.
Running httpd -v in the terminal returns v2.4.48, but the vulnerability scan is still picking up the old version of Apache
What am I missing? Why is the OS picking up the old version? Do I simply have to wait for Apple to patch it? Is it even possible to upgrade /usr/sbin/httpd?
Two things here, how to set the default apache version, and whether your machine is vulnerable.
firstly, you can have multiple versions of apache installed, and even running simultaneously (listening on different ports). Installing homebrew apache, doesn't necessarily start the server automatically, or deactivate the default (apple) apache install.
You can see which versions of apache are running on your system by using the ps command, for example on my machine:
$ ps auxw | grep httpd
_www 782 0.0 0.0 34153280 1476 ?? S 26May22 0:00.83 /usr/sbin/httpd -D FOREGROUND
and check the version:
$ /usr/sbin/httpd -v
Server version: Apache/2.4.53 (Unix)
The apple httpd service is started by launchctl, and you can stop the apple httpd service from automatically starting up as follows:
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
To automatically start homebrew apache on system startup (assuming you have already installed it - brew install httpd), run brew services start httpd
Remember that the apache configuration files will be in a different location - apple conf file is /etc/apache2/httpd.conf, whereas homebrew's is in /usr/local/etc/httpd/httpd.conf. Also the default port may well be different - apple defaults to port 80 whereas homebrew httpd listens on port 8080 by default.
Secondly, does this security issue actually matter? By default apache listens on all network interface, but unless you need to access the web server from another machine, it is safer to configure it to only listen on localhost. You can do this in the httpd.conf file, as follows:
Listen 127.0.0.1:80
This page has a good walkthrough of the various steps: https://wpbeaches.com/installing-configuring-apache-on-macos-using-homebrew/

Have only one Apache running on macOS Big Sur

Via brew I installed an Apache Server with PHP 7.4 running, however it seems that there are two servers and two different PHP versions running.
On localhost phpinfo() shows 7.4 however on 127.0.0.1 phpinfo() shows 7.3
The localhost phpinfo() shows it's running on brew, however on 127.0.0.1 it seems that the built-in Apache is running, it shows Built-in HTTP server
Stopping Apache via sudo apachectl stop stops the brew one from working (localhost), but the built-in (127.0.0.1) is still running it seems.
which -a apachectl shows
/usr/local/bin/apachectl
/usr/sbin/apachectl
Any tips on how to stop the built-in one and only have the brew one running are gladly welcomed!
Thx!

XAMPP can't start Apache on Mac

manager-osx flicks from "Starting…" back to "Stopped" with no error, and when I run sudo /Applications/XAMPP/xamppfiles/ctlscript.sh start apache on the command line, I get back:
Syntax OK
/Applications/XAMPP/xamppfiles/apache2/scripts/ctl.sh : httpd started
I've tried port swapping and running sudo apachectl stop to stop the built in server (as described at XAMPP can't start Apache in mac), but no luck. Open port scan doesn't show any live Apache servers on my machine. I've reinstalled XAMPP (multiple different versions), but nothing.
Running macOS Catalina 10.15.1.
Update: I've also tried using MAMP, and it can't start Apache either.
sudo /Applications/XAMPP/xamppfiles/xampp start
run this command to Start XAMPP on MacOS Catalina.

I have 2 versions of Apache running on my system

There is another version of apache running on my system.
When in run sudo apachectl stop I still get the "It Works" page
So I found the location of the other version that is still running and it looks to be an older version which probably came pre-installed and is located in /opt/local/apache2/.
I tested this file /opt/local/apache2/htdocs/index.html.sample by just changing the text and then checked the browser again.
Server: Apache/2.2.29 (Unix)
I want to remove that one and keep the latest version which is located in private/etc/apache2
Server version: Apache/2.4.9 (Unix)
How can I do this safely.
I managed to fix this
I ran ps aux | grep apache to see the apache processes
I then ran sudo apachectl stop
Then sudo killall -9 httpd to kill all apache processes
Then sudo apachectl restart
I went to the browser and typed localhost~/username/sitename
Bingo it works again, my system is using the correct version of apache again!

Xdebug and Netbeans are not communicating with each other

I have spent a couple of days surfing the internet to find an answer to my question. I have tried everything I could but have been unsuccessful thus far in solving this problem. Netbeans keeps giving Waiting for Connection (netbeans-xdebug).
I am using the following software:
XAMPP Version 1.8.1.
Windows 7
Netbeans IDE 7.2.1
Xdebug 2.2.1
I installed the latest version according via the wizard for the xdebug.org site (http://xdebug.org/wizard.php). Xdebug is working according to phpinfo().The HMTL output in my browser (Firefox 17.0.1) shows xdebug code. However this is not communicated back to netbeans. Using Netstat via command prompt (Run -> cmd.exe) shows that there is a TCP connection on port 9000. However , nothing is reported back in Netbeans.
I have tried several different alternatives, for example:
Installing a similar IDE, Eclipse PDT. Eclipse shows that Xdebug is
working. However, because Eclipse is lacking functions I need I
wanted to use Netbeans.
Installing Netbeans on Ubuntu 12.04 LTS.
Still the same problem. Netbeans not working (waiting for
connection). Also output in browsers shows that Xdebug is working.
Whenever I install on a new Linux machine: "php xdebug" and netbeans I run these simple steps and I've always managed to corect integration of xdebug on netbeans.
So with the data you provide, I can only help you solve, the half of your problem. Allowing you to connect on Linux machines:
Installation with pecl:
# apt-get install php5-dev php-pear
# pecl install xdebug
Or direct installation:
# apt-get install php5-xdebug
find the library:
# find / -name 'xdebug.so'
/usr/lib/php5/20090626+lfs/xdebug.so
Edit phi.ini file:
...
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
...
Restart web-server in your case: Apache
$ /etc/init.d/apache2 restart
According to what you have posted:
Installing Netbeans on Ubuntu 12.04 LTS.
I have used the installation method "apt-get" for distributions ".deb".
If you are using a distribution ".rpm" can do the same with "yum"
Many of these commands are surely simplified within the xampp.
But if you running this commands from console will not affect the final result.
Another important note about Windows's machines and Linux's machines,
You should check that your firewall rules are allowing to establish a connection from netbeans to xdebug.
I know this is old but for people using Ubuntu this might help.
OS Version = Ubuntu 14.04.3 LTS; Codename: trusty
PHP Version = PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul 2 2015 15:17:32)
Apache Version = Server version: Apache/2.4.7 (Ubuntu)
Procedure
Install xdebug for php5
sudo apt-get install php5-xdebug
Open php.ini and add the following lines below (usually sudo vim /etc/php5/apache2/php.ini)
xdebug.remote_enable=On;
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000;
xdebug.remote_handler="dbgp";
Restart apache and your good to go
sudo service apache2 restart
Note 1: I have not tried doing this without firefox add-on for xdebug, so if after doing the procedure above and still to no avail, download the add-on for firefox Easy Xdebug
Note 2: I did not touch the PHP Configuration of Netbeans
Note 3: I did not touch xdebug.ini

Resources