Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
220 views
in Technique[技术] by (71.8m points)

lamp - ERR_CONNECTION_REFUSED on files outside of project root directory

Im having an issue accessing directories in a legacy project that I’ve pulled locally. I also recently did an update to my apache since updating my OS. When I have apache use the project as its root directory

DocumentRoot "/Users/brendan/Sites/UK_Libraries_Site"
<Directory "/Users/brendan/Sites/UK_Libraries_Site">

All the root files work fine, they utilize files in directories deeper in the project (e.g. /shared/libs/db/connections.php) to render the code on screen and I can view the project like normal.

So localhost/index.php, localhost/page.php, localhost/etc… render just fine

When I try to render a page that’s in a different directory than the root of the project (e.g. localhost/staff/stafflogin.php) I get the classic “This site can’t be reached ERR_CONNECTION_REFUSED” error.

I’ve never seen this before, I checked some other questions on stack overflow like Unable to see folder directory in localhost but they seem unrelated.

There are no .htaccess files in any of the directories that I’m utilizing and I even created a special directory called “/test” with simple index.php, index.html, and 777 permissions to see if there was something I was missing but I still received the same ERR_CONNECTION_REFUSED result.

Now when I go to apache and update the path one directory above

DocumentRoot "/Users/brendan/Sites"
<Directory “/Users/brendan/Sites">

Then visit those directories I couldn’t access before like the ones above http://localhost/UK_Libraries_Site/staff/stafflogin.php, http://localhost/UK_Libraries_Site/test/index.php, http://localhost/UK_Libraries_Site/etc in the project, I no longer get the ERR_CONNECTION_REFUSED issues that I had before, the pages render fine.

I’m not certain why this behavior is happening though it seems like an apache issue to me. I have to keep the apache settings with the project as my Document Root in order to give an accurate representation of the production environment.

Hopefully, the active loadmodule's I'm including are relevant, but please request anymore information that would aid you with the issue.

LoadModule mpm_event_module lib/httpd/modules/mod_mpm_event.so
LoadModule mpm_prefork_module lib/httpd/modules/mod_mpm_prefork.so
LoadModule authn_file_module lib/httpd/modules/mod_authn_file.so
LoadModule authn_core_module lib/httpd/modules/mod_authn_core.so
LoadModule authz_host_module lib/httpd/modules/mod_authz_host.so
LoadModule authz_groupfile_module lib/httpd/modules/mod_authz_groupfile.so
LoadModule authz_user_module lib/httpd/modules/mod_authz_user.so
LoadModule authz_core_module lib/httpd/modules/mod_authz_core.so
LoadModule access_compat_module lib/httpd/modules/mod_access_compat.so
LoadModule auth_basic_module lib/httpd/modules/mod_auth_basic.so
LoadModule reqtimeout_module lib/httpd/modules/mod_reqtimeout.so
LoadModule filter_module lib/httpd/modules/mod_filter.so
LoadModule deflate_module lib/httpd/modules/mod_deflate.so
LoadModule mime_module lib/httpd/modules/mod_mime.so
LoadModule log_config_module lib/httpd/modules/mod_log_config.so
LoadModule env_module lib/httpd/modules/mod_env.so
LoadModule headers_module lib/httpd/modules/mod_headers.so
LoadModule setenvif_module lib/httpd/modules/mod_setenvif.so
LoadModule version_module lib/httpd/modules/mod_version.so
LoadModule unixd_module lib/httpd/modules/mod_unixd.so
LoadModule status_module lib/httpd/modules/mod_status.so
LoadModule autoindex_module lib/httpd/modules/mod_autoindex.so
<IfModule !mpm_prefork_module>
</IfModule>
<IfModule mpm_prefork_module>
</IfModule>
LoadModule dir_module lib/httpd/modules/mod_dir.so
LoadModule alias_module lib/httpd/modules/mod_alias.so
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so

What is causing this behavior? How do I view files like localhost/staff/stafflogin.php?

Edit: User and Group have been verified as matching those set in httpd.

question from:https://stackoverflow.com/questions/65647320/err-connection-refused-on-files-outside-of-project-root-directory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...