403 Forbidden Error on MAMP - mamp

I try to run my local applications on MAMP PRO. Since now i run MAMP and everything works fine. Now i've changed to MAMP PRO because of the possibilities to generate more hosts and send email from local applications.
Now i have the problem that i can't access files in a directory. I have checked indexes under Hosts->Extended which should solve this problem. But it doesn't. I've found many articles but not anyone that solves my problem. I'm also not a specialist on server, but i think there must be a easy solution even in MAMP it works.
I've read something over Web-sharing but this was not clear described enough.
MACOSX: 10.11.2
MAMP PRO: 3.5
One failure in the log was:
"Permission denied: file permissions deny server access: /folder/file.js"
But where i can change it generally.
Thanks for your Help. I'm very confused.
codeFragment

This worked for me.
Create an index file in the directory, by default Apache is looking for such a file
If you want to access the directory (the list of your files or folders in the directory), just go in Mamp Pro to Hosts >> Advanced and check Indexes.
So simple, no need to go configure any file.

In MAMP PRO you can check the option INDEXES in Apache tab.
After restart server will work.

Sounds like a permission problem. Set the parent folder to "read only" for all and assign it to all folders/files below.
Greetings,
Peter

I had this happen to me after a cloud restore. I traced the problem to the fact that the site folder hadn't been fully restored and was mostly empty.
The solution was to repeat "Save to Cloud" from the remote computer and then repeat "Load from Cloud" on the computer I was currently using.

This case is occur when you run Mamp with the Server Nginx and nginx server needed configuration of each working folder/directory.
for the nginx configuration you can go in nginx.conf file on path
C:\MAMP\conf\nginx\nginx.conf
and write this script.
http {
.....
server {
location ~* /test(.*)$ {
root C:/MAMP/htdocs/test;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9100;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
}
note: in this script test is my working directory. you can replace this name.

Whenever you are setting up a new server on a Mac, whether it be MAMP, MAMP PRO or just straightforward Nginx/Apache, always set the right permissions on the root folder. Permissions are used for security reasons, not a bad thing in any way although it adds layers to get things done good or bad. Nginx/Apache usually uses _www to read and write on your folder. So you must grant _www access access.
To do this for example on a folder located at /MacHD/Sites...
open up a console
sudo chown -R _www Sites
sudo chmod -R g+w Sites```
restart your server
References:
- https://ss64.com/osx/chmod.html
- https://ss64.com/osx/chown.html

Related

three ways to let PHP and a regular user edit the same files

I am a web developer, and for some upcoming projects I would like to use a file-based CMS. This means that many of the files I create at the start must be editable by the PHP user later, but also remain editable for my user (and also the other way around). My PC runs Debian 9, which I love but am not super knowledgeable about, and I have also just set up a local network server with Debian 9 for backups and possibly file sharing. (I'm using Webmin to configure this, which reflects my level of command line skills).
On my online shared hosting server, the PHP user and the FTP user seem to be the same, and 644/755 permissions work fine, this is also recommended by the CMS I'm using. I would like to mimic this on my computer so I don't have to fiddle with permissions all the time. But how do I do this? Currently, my regular user (anna) does not have access to www-data's files and vice versa. Putting them in the same group still means changing file permissions. Making anna the PHP user is a Bad Idea (as far as I understand it) because anna has sudo permissions.
So far I have researched three possible solutions that I don't really know very much about, and I would like to know which is the best route to take.
Develop locally on my computer and use apache-mpm-itk or suPHP to let PHP edit the files (I got that idea from this question on ServerFault).
Develop locally on my computer and rsync the files to my server with grunt-rsync, and somehow get rsync to set the ownership to www-data (another ServerFault thread helping here).
Mount the project's server directory, which is owned by www-data, on my computer with SSHFS and then either edit the files on the server directly or copy them over from my local directory with grunt-copy.
What do you think: from a security and ease of use perspective, which is the best way? Or do you know an even better one?
Thank you for taking the time to read and think about this!
Anna~
I figured it out! I finally ended up reading about running PHP as CGI instead of as an Apache module, and that this would solve my permissions problem. Plus, as far as I understand it, there are no extra security precautions to take when I'm the only one working with it on my local computer.
In case someone comes across this who might find it helpful, here's what I did (basically following these instructions):
I installed php7.0-fpm
Edited /etc/apache2/sites-enabled/000-default.conf and put the following just before </VirtualHost>:
DirectoryIndex index.php
<LocationMatch "^(.*\.php)$">
ProxyPass fcgi://127.0.0.1:9000/var/www/html
</LocationMatch>
I activated the Apache module proxy_fcgi (via Webmin, which apparently does an automatic Apache restart)
In /etc/php/7.0/fpm/pool.d/www.conf I commented out a listen line and put another below like this:
; listen = /run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000
I then restarted PHP-FPM with this command: /etc/init.d/php7.0-fpm restart (a little different from the instructions, I'm on Debian 9). After that, phpinfo() gave me the Server API "FPM/FastCGI".
And finally, I changed the user and group from www-data to anna in three places, twice in /etc/php/7.0/fpm/pool.d/www.conf and then once more in /usr/lib/tmpfiles.d/php7.0-fpm.conf (this last bit may be Ubuntu/Debian specific, my thanks go to Keith for a comment on StackExchange).
And that was it! :-)

Localhost messed up

I work with my WAMP local web server for half a year now, but when I started it today it didn't work anymore. It says: "Service offline", but when I click "Put Service Online" it says it has already started.
I didn't know what to do so I just tried all services, did some tutorials and I changed the configuration of, well, my computer...
I want everything that has to do with my localhost to be gone, so also the settings in the IIS to be removed, how can I do this or does anyone of you guys know a good tutorial about it?
Thanks!
Open file httpd.conf through wamp tray icon
Find:
# onlineoffline tag
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Change to:
# onlineoffline tag
Order Deny,Allow
Allow from all
and restart

Shared folder with vagrant cause invisible characters appending

I have a few invisible characters (�) that appear at the end of a javascript document that cause the "illegal character" error in FF or Chrome. I saw different topics about this error, but nothing works for me, and i can't see anything wrong in my document (displaying invisible characters, open it with a hexadecimal editor). This is just driving me crazy.
I use Vagrant with a nginx web server. The document looks clear in the server too (vi + :set list).
Plus, when I get back a clear document from my Git repository, everything works(normal). But each time I want to edit it (like create a new variable at the top of document), I got this error again.
If someone can helps me, thank you.
If you're using the VirtualBox provider, then VirtualBox shared folders are the default synced folder type. These synced folders use the VirtualBox shared folder system to sync file changes from the guest to the host and vice versa.
There is a VirtualBox bug related to sendfile which can result in corrupted or non-updating files. You should deactivate sendfile in any web servers you may be running.
In Nginx:
sendfile off;
In Apache:
EnableSendfile Off
See vagrant docs: http://docs.vagrantup.com/v2/synced-folders/virtualbox.html
It seems that you're using Vagrant.. please take a look at your _Vagrantfile and check the way files are written on the VM filesystem.
cat ~/.vagrant.d/boxes/[YOUR VM NAME]/include/_Vagrantfile
Maybe you are using config.vm.synced_folder try to use NFS:
config.vm.synced_folder "/home/myuser/shared", ".", :nfs => true

Where is httpd.conf file of a domain? (Plesk, Apache, CentOS, Dedicated Server.)

I'm trying to disable access logging (access_log) for domains. I can't find a way to do it yet, I thought if httpd.conf file exist of a domain maybe I can look into that. So do you know where is httpd.conf file of a domain?
Try
locate httpd.conf
on the commend line.
Note that in newer Apache setups, the configuration is spread across multiple files, but they won't be far from where you find httpd.conf.
I had the same problem, but reading #user1055645 comment in the question, about follow the file:
/etc/httpd/conf.d/zz010_psa_httpd.conf
I found the configuration file here:
/etc/httpd/conf/plesk.conf.d/vhosts/domain.com.conf
If you want to disable access_log you can edit this file and comment with an # the beginning of this line:
CustomLog /var/www/vhosts/system/giornalone.it/logs/access_log plesklog
At the end restart apache server to make the changes take effect.

How to configure MAMP to serve perl CGI scripts (NOT localhost!)

I'm using MAMP-pro to serve my domain to the outside world.
I'm not a very experienced sys-admin, though I've slogged my way through a few basic things. I know what apache is, and I can read-most-of but not generate-without-guide related .conf files.
I've got a perl script which I've tested from the command line and it works (outputs as desired.)
When I try to access said script from the browser, I get 404.
I've tried placing the script at:
/Users/me/Sites/mydomain.com/htdocs/mycgi.pl
/Users/me/Sites/mydomain.com/cgi-bin/mycgi.pl
/Users/me/Sites/mydomain.com/htdocs/cgi-bin/mycgi.pl
and accessing it as:
http://www.mydomain.com/mycgi.pl
http://www.mydomain.com/cgi-bin/mycgi.pl
and all the various combinations, all to no avail (404.)
The script and its container directory have permissions 755.
So, what other steps am I missing? Are there any good set-up guides? I tried the MAMP-Pro manual, but it is filled with such information as "the cancel button cancels the current operation" and not really anything useful. Google turned up several hits that all seem to talk about how to make this work on localhost, but I'm trying to serve this to the outside world.
Any hints?
Thanks!
The official online documentation has a section on virtual hosts. When creating a host for www.mydomain.com you can choose the DocumentRoot which is called "Disk location" within MAMP PRO. If you still get a 404 error, take a look into the error_log for a more specific reason (i.e., where Apache tries to find the file in question).