Not knowing that my Mac came with Apache2.4 and did not check which OS I worked on, I followed this guide to get Apache / MySQL / PHP on my machine using Homebrew: https://echo.co/blog/ os-x-109-local-development-environment-apache-php-and-mysql-homebrew
This led to the fact that I had two versions of Apache2 running on my machine: 2.2 and 2.4. When asked in the terminal for which apache was running, the answer was 2.4, but when I tried to open an instance of my program on my virtual host, I could not reach the page. What happened after that was confused because I have other people working on it, trying to solve it, and they changed and moved the files, so when I returned my computer, I did not even know where to begin to understand where I was, so I tried to uninstall both versions of apache and reinstall 2.4.
Since I could not find a guide that helped me remove apache, and the brew command failed, I went to erase the apache folders and I looked for something in my directories containing the words "apache" or "httpd" (all that I could find, which means that I could also skip some files because I just did not know where to look for them).
After that, I reinstalled apache 2.4 after this other guide https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions until installing PHP (which I did not complete).
After installing apache again, I inserted the data for my virtual host into httpd-vhost.conf as follows:
<VirtualHost *:80> ServerAdmin personal@mail.com DocumentRoot "/Users/username/apache_vh/myApp" ServerName myApp.username.com ErrorLog "/usr/local/var/log/apache2/myApp-error_log" CustomLog "/usr/local/var/log/apache2/myApp-access_log" common <Directory /> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </Directory> </VirtualHost>
and then I changed the httpd.conf file in the / usr / local / etc / apache 2 / 2.4 folder as follows (I skip the commented lines):
ServerRoot "/usr/local/opt/httpd24" Listen 80 LoadModule authn_file_module libexec/mod_authn_file.so [...] LoadModule authn_core_module libexec/mod_authn_core.so LoadModule authz_host_module libexec/mod_authz_host.so LoadModule authz_groupfile_module libexec/mod_authz_groupfile.so LoadModule authz_user_module libexec/mod_authz_user.so [...] LoadModule authz_core_module libexec/mod_authz_core.so LoadModule access_compat_module libexec/mod_access_compat.so LoadModule auth_basic_module libexec/mod_auth_basic.so [...] LoadModule reqtimeout_module libexec/mod_reqtimeout.so [...] LoadModule filter_module libexec/mod_filter.so [...] LoadModule mime_module libexec/mod_mime.so LoadModule log_config_module libexec/mod_log_config.so [...] LoadModule env_module libexec/mod_env.so [...] LoadModule headers_module libexec/mod_headers.so [...] LoadModule setenvif_module libexec/mod_setenvif.so LoadModule version_module libexec/mod_version.so [...] LoadModule unixd_module libexec/mod_unixd.so [...] LoadModule status_module libexec/mod_status.so LoadModule autoindex_module libexec/mod_autoindex.so [...] <IfModule mpm_prefork_module> #LoadModule cgi_module libexec/mod_cgi.so </IfModule> <IfModule !mpm_prefork_module> #LoadModule cgid_module libexec/mod_cgid.so </IfModule> [...] LoadModule dir_module libexec/mod_dir.so [...] LoadModule alias_module libexec/mod_alias.so LoadModule rewrite_module libexec/mod_rewrite.so <IfModule unixd_module> User _www Group staff </IfModule> ServerAdmin you@example.com ServerName localhost <Directory /> AllowOverride none Require all denied </Directory> <Directory "/Users/username/Sites"> MultiViews Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> <IfModule dir_module> DirectoryIndex index.html </IfModule> <Files ".ht*"> Require all denied </Files> ErrorLog "/usr/local/var/log/apache2/error_log" LogLevel warn <IfModule log_config_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule> CustomLog "/usr/local/var/log/apache2/access_log" common </IfModule> <IfModule alias_module> ScriptAlias /cgi-bin/ "/usr/local/var/apache2/cgi-bin/" </IfModule> <Directory "/usr/local/var/apache2/cgi-bin"> AllowOverride None Options None Require all granted </Directory> <IfModule mime_module> TypesConfig /usr/local/etc/apache2/2.4/mime.types #AddType application/x-gzip .tgz #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz AddType application/x-compress .Z AddType application/x-gzip .gz .tgz #AddHandler cgi-script .cgi #AddHandler type-map var #AddType text/html .shtml #AddOutputFilter INCLUDES .shtml </IfModule> # Virtual hosts Include /usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf [...] <IfModule proxy_html_module> Include /usr/local/etc/apache2/2.4/extra/proxy-html.conf </IfModule> <IfModule ssl_module> SSLRandomSeed startup builtin SSLRandomSeed connect builtin </IfModule>
Subsequently, I added the following to the hosts file in the / etc folder (which does not match / usr / local / etc, this one is in the root, one level up / usr up):
127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost 127.0.0.1 myApp.username.com
And I hope that "it works!" on localhost: 8080 and myApp on localhost: 80. I see that "it works!" on localhost: 8080, but if I refresh the page, I get "This site cannot be reached / localhost refused to connect." I started, stopped, restarted apache, but I get the same behavior all the time. On localhost: 80, I get myApp instead, but I cannot run it, PHP is not parsed, and I only see the tree structure of the folder.
I ran apachectl configtest and got the OK syntax. I ran php -v and I got PHP 5.4.45 (cli) (built: Nov 23, 2016 11:12:05), so everything works.
Checking the httpd.conf file that I inserted above, I noticed that I did not have a php module, so I added LoadModule php5_module libexec/libphp5.so
I'm still having the same problems.
What I really don’t understand is the folder structure of all of this, because I try to follow other manuals, but they seem to point to the apache2 folder, which I should delete, but I should not have tried to delete the old versions and, by Apparently, it was not recreated during reinstallation (/ etc / apache2 / users). I do not have the apache2 folder in my etc folder, which I have at the root level, so I assume that I need to search for / users in / etc / apache 2, which I have under / usr / local, but in this folder I only have a directory of 2.4.
The organization of all these directories and files is very confusing, and I seem to be unable to understand if they were moved by people who tried to help me if I accidentally deleted this / etc / apache 2 / users while uninstalling these previous versions or if I just messed up with a few too different guides.
So my question is:
Can I fix this somehow to show myApp on port 80 in the local PHP correct parsing?
If not, how can I remove apache in a clean way, making sure that I do not delete important files that should not be touched, and at the same time I take away all those that will create a conflict with the recently installed version?