Have only one Apache running on macOS Big Sur - macos

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!

Related

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.

Why doesn't homebrew apache start at startup?

I’m trying to figure out why my apache doesn’t start at startup… (I would like for it to).
My OS: OSX Mojave
Impressions I’m under: that I’m running homebrew’s apache
Upon a fresh boot…
If I hit http://localhost in a browser I get
Unable to connect
Firefox can’t establish a connection to the server at localhost.
Fire up terminal…
$brew services list
returns
httpd started bigpimpin /Users/bigpimpin/Library/LaunchAgents/homebrew.mxcl.httpd.plist
php started bigpimpin /Users/bigpimpin/Library/LaunchAgents/homebrew.mxcl.php.plist
(That first line makes me think httpd is running and I should be able to hit localhost).
$which -a apachectl
returns
/usr/local/bin/apachectl
/usr/sbin/apachectl
then
$apachectl configtest
returns
Syntax OK
then
$sudo apachectl -V
returns (among other things)
-D SERVER_CONFIG_FILE="/usr/local/etc/httpd/httpd.conf"
(Isn’t this brew’s httpd.conf?)
There's a brew command (which I forget) that I already ran that is supposed to run httpd at startup.
Once I run
$sudo apachectl start
everything is jake. So it’s a low-priority question, but one I would like to solve and understand.
I had the same issue with Homebrew NGINX.
Running the brew services command with sudo solved the problem for me.
It appears that the Homebrew web-server packages require sudo to start | stop | restart.
Try running:
sudo brew services start apache2

Can't change document root for apache 2.4

I want to set up local web server using Apache and PHP on my Mac running Sierra. I followed this tutorial:
https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions
And I am stuck at changing the document root from httpd.config, for whatever reason this change does not take effect at all. If I type http://localhost it still says "It works", it still uses the original html file.
Another weird thing is that apparently I can't stop apache at all. I tried running
$ sudo apachectl stop
but I still can’t access http://localhost
if I run
$ brew services list
httpd24 is stopped. What gives? What am I doing wrong?
There is an instance of apache pre-installed with macOS. So you have now two versions of apache installed. If you check:
which apachectl
you will probably obtain:
/usr/sbin/apachectl
which is the official macOS version of apachectl. Stop it with:
sudo apachectl stop
Disable the auto-loading of the pre-installed apache with (as explained in the tutorial you mentioned):
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
To run the homebrew version do:
brew services run httpd24
to stop it:
brew services stop httpd24
to register it to launch at login:
brew services start httpd24

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