I´m trying to explain he problem I have.
I usually use XAMPP or MAMP for this but I want to use the Apache Server that comes with OS X High Sierra by default installed.
So, OS X has apache server and php installed for default and they work great without a problem, and the localhost works fine with many other projects I have like angular and php.
My issue is this...
I tried to install a dev environment on my computer for php-laravel projects so after I installed laravel with homebrew and do some changes in the files:
/private/etc/apache2/extra/httpd-vhosts.conf
/private/etc/apache2/httpd.conf
/etc/hosts
httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "~/Sites"
#VirtualDocumentRoot "~/Sites"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "~/Sites/cms/public"
ServerName cms.test
ServerAlias *.test
</VirtualHosts>
httpd.conf
ServerRoot "/usr"
<IfDefine SERVER_APP_HAS_DEFAULT_PORTS>
Listen 8080
</IfDefine>
<IfDefine !SERVER_APP_HAS_DEFAULT_PORTS>
Listen 80
</IfDefine>
User myusername
ServerName localhost:80
DocumentRoot "/Users/myusername/Sites"
<Directory "/Users/myusername/Sites">
Options All
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 cms.test
After this I restarted the server and when I tried to go to:
localhost I just wrote on chrome browser localhost
If I tried localhost/info.php localhost/info.php
As you can see inside the Sites folder there are an info.php file folder Sites is where ServerDirectory is and as you can see there are an info.php file
when I tried localhost/cms/public/index.php the result is the same
I execute $ whereis httpd and the result is /usr/sbin/httpd
then I executed $ /usr/sbin/httpd -V and the result is
Server version: Apache/2.4.28 (Unix)
Server built: Oct 9 2017 19:54:20
Server's Module Magic Number: 20120211:68
Server loaded: APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_FLOCK_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/usr"
-D SUEXEC_BIN="/usr/bin/suexec"
-D DEFAULT_PIDLOG="/private/var/run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
-D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
I also executed the command apachectl -S and the result is
VirtualHost configuration:
ServerRoot: "/usr/local/opt/httpd"
Main DocumentRoot: "/usr/local/var/www"
Main ErrorLog: "/usr/local/var/log/httpd/error_log"
Mutex rewrite-map: using_defaults
Mutex default: dir="/usr/local/var/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/usr/local/var/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="_www" id=70
Group: name="_www" id=70
I can see two different configurations and I do not know what I can do to fix this.
So that is why I am asking for help, I really don´t know what else I can do to fix this.
1) It looks like you have apache installed in multiple locations. Check to make sure. Do:
find /usr -name apachectl
If you get more than one result, then it is likely you have installed one version from Homebrew (which will install apachectl in /usr/local/bin, and set the PidFile directive for it's configuration file to /usr/local/var/run/httpd/httpd.pid) and, have another version that comes with Sierra, which will install in /usr/sbin, your system binary folder (and in my experience with this problem, set the PidFile to run in /etc/var/run/).
"Whereis" does not return the apachectl which has precedence (ie, which one you are calling when you execute the command). A better command is:
which apachectl
Which will reveal which apachectl you are currently using when you type in apachectl.
If it turns out you have multiple installations, you will need to set precedence for the version of apachectl you want in your ~/.bash_profile.
The reason why you are seeing two different configurations is because you are checking one's configuration with /usr/sbin/httpd - the apache that comes native with Sierra, and checking the other's configuration files with apachectl -S, which is likely calling the httpd installed by Homebrew.
2) Preventing access to a directory can be a problem that results from not having the correct permissions on the files themselves. Often you will need to
chown -R user:group dir_name
the the directory, where user and group are what the user is listed as in your configuration file. On my machine, this is _www for both in the configuration file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.