Xampp - Ubuntu - cant access my project in lampp/htdocs - php

I have installed xampp to Ubuntu 12.04. I have put my project in the folder /opt/lampp/htdocs/project_is_here
When I type in the browser localhost/soap/php (soap/php is in my htdocs folder) which is where index.php I get the following error:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.3 (Unix) OpenSSL/1.0.1c PHP/5.4.7
Any ideas how to fix this? I think this is the right location to put the project, because I tried other places and it said location didnt exist and this error goes away here and I get this.
Any ideas?

In the linux terminal navigate to your lampp directory.
cd /opt/lampp
In the command line type:
sudo chmod 777 -R htdocs
The problem should be solved.
What you just did was:
Navigate to the directory containing the protected directory. Your problem was that it was a folder that was access protected by your system. When you commanded chmod 777 -R htdocs, you set the permissions for every user on your computer to "read/write/execute - allowed".
Each number from 0-7 sets a permission level. Here's a link explaining that in more detail.
http://www.pageresource.com/cgirec/chmod.htm
The '-R' makes the command recursive and will affect htdocs as well as all subdirectories of htdocs and all subdirectories of those etc.

i've experinced the same problem and this is my solution :
1.in the terminal
cd /opt/lampp/etc/
if you have sublime text installed simply just type :
subl httpd.conf
3.when the configuration file opened in sublime you have to check if these three blocks are as follow :
<Directory />
AllowOverride All
Require all granted
</Directory>
================================
<Directory "/opt/lampp/htdocs">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Require all granted
</Directory>
================================
User your username
Group your group name
for example :
my username is mhmd also my group name is mhmd
User mhmd
Group mhmd
and i hope it will help you ..

One possible reason is that you are using Virtual host.
In that case, use this command in your terminal
sudo nano /opt/lampp/etc/extra/httpd-vhosts.conf
Then add this block of code at the end of the file
<VirtualHost *:80>
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error_log"
CustomLog "logs/localhost-access_log" common
</VirtualHost>
Finally restart XAMPP
sudo /opt/lampp/lampp restart

I had given all the permission , still got the error message.
Go to -> /etc/apache2/sites-available/000-default.conf
set : DocumentRoot to /opt/lampp/htdocs
All solved for me.
Change the "DocumentRoot" to whichever folder your project is.

it'll useful,
0 -> No permission
1 -> Execute
2 -> Write
3 -> write and execute(2 +1)
4 -> Read
5 -> Read and execute
6 -> Read and write
7 -> read,write and execute
Then What about three decimal
1st-digit Owner
2nd- digit Group
3rd- digit Others
test#test:~$ sudo chown -R test:test /var/www/html/folder
test#test:~$ sudo chmod -R 666 /var/www/html/folder //-system user
test#test:~$ sudo chmod -R 777 /var/www/html/folder // -browser with full
What is this 777 ? --> 7: you, 7: us, 7: them.

Related

MacOS XAMPP Access Forbidden Error 403 - You don't have permission to access the requested directory

I have some PHP web apps running off XAMPP 7.4.1 on macOS 10.15. XAMPP has worked for me in the past. I got my dev environment screwed up because 32 bit apps sh*t the bed with Catalina, and my old XAMPP installation didn't open. I got my VirtualHosts set back up, but now when I try to access one of my sites I get the following error.
Access forbidden!
You don't have permission to access the requested directory. There is
either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
My virtual hosts look like the following:
# localhost
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
#####################
# PERSONAL PROJECTS #
#####################
# Dunsparce.net
<VirtualHost *:80>
ServerName dunsparce.net
DocumentRoot "/Users/danielschnoll/Documents/Projects/Dunsparce.net"
<Directory "/Users/danielschnoll/Documents/Projects/Dunsparce.net">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/dunsparce-error_log"
</VirtualHost>
I have more VirtualHosts listed and they all follow the same format. I have Require all granted on each one, as well as the Allow Override All and the Options... line. Like I said at the start of the post, they all worked in the past. I also have the # Include uncommented in my httpd.conf file, though I'm pretty sure Access Forbidden error is completely unrelated to it.
Any ideas?
I wound up having to edit httpd.conf again. There’s a section for User group permissions. By default it says
User daemon
Group daemon
Change the User from daemon to your macOS Username. For me, my User group now looks like
User danielschnoll
Group daemon
If you landed here after an Upgrade to MAC OS my problem was solved when I moved the web files out of the /Documents/ folder.
How to Fix XAMPP Error 403
Step 1: Open the Volumes tab in the XAMPP app
First, open the XAMPP app on your Mac and navigate into the Volumes tab
Step 2: Click on 'Mount'
Next, you're going to mount the opt/lampp directory onto your computer.
Step 3: Click on 'Explore'
Step 4: Open the 'etc' folder
By clicking on explore your app should have opened the lampp directory. In it you'll see many folders and files. Click on the one named 'etc'.
Step 5: Open the 'extra' folder
Step 6: Open the 'httpd-xampp.conf' file
Step 7: Find the AuthConfig requirements code
Search for 'phpmyadmin' in the httpd-xampp.conf code and find the following section:
httpd-xampp phpmyadmin require local
Step 8: Change 'Require local' to 'Require all granted'
This is the step that will fix the 403 error. Change the line of code to replace 'Require local' with 'Require all granted'. Then save your file.
Step 9: Restart all services
Navigate back to the XAMPP app and click on 'Services', then 'Restart all'. This will restart all of the services. You'll notice the status lights turn yellow and eventually return back to green.
Step 10: Refresh the phpMyAdmin page
The last step is to refresh the phpMyAdmin page you had open earlier.
If you closed it, no problem, just return to the General tab on your XAMPP app and click 'Go to Application'. That will open the dashboard in your browser where you can again navigate to the phpMyAdmin page.
Changing the User group permissions didn't work for me, but creating a Symbolic link to my working directory worked:
cd /opt/lampp/htdocs
ln -s /home/user/Projects/www www
Then in /opt/lampp/etc/httpd.conf
DocumentRoot "/opt/lampp/htdocs/www"
Follow below steps:
Go to htdocs folder
Right click on the folder and get info
Go to Sharing & Permissions: and >>> add your user
Your user : read & write

PHP errors written to wrong log

My Linux server is running PHP 7 as a CGI on Apache2. In php.ini I have
error_log = /var/log/apache2/php.log
Now, I have two problems:
1) All PHP errors go to /var/log/apache2/error.log instead of php.log. I have edited the right php.ini because ini_get('error_log') returns the full path of php.log in PHP.
2) When I try to open either of those files in PHP, I get permission denied. I have chmod'd both files to 777, but PHP is still unable to access them.
The server has been restarted multiple times so the configuration changes apply. My Apache configuration is this:
ErrorLog ${APACHE_LOG_DIR}/error.log
ScriptAlias /local-bin /usr/bin
AddHandler application/x-httpd-php7 php
Action application/x-httpd-php7 /local-bin/php-cgi7.0
<Directory "/usr/bin">
Require all granted
AllowOverride All
</Directory>
How can I redirect PHP errors to the right file, and also make it readable for PHP? Thanks in advance!
You need to change the owner and the group of the log directory and the log file/s (if already exist/s) to www-data:
sudo chown -R www-data:www-data /path/to/log/directory
Dont change the directory permissions to 777 as it might cause security issues, use 775 instead. For the log files use 664.
You might also want to add your system user to the group www-data if not already a member (use groups command to check for your existing groups), a system reboot is required after that for the changes to take effect:
sudo adduser user www-data #change 'user' to your

403 Forbidden Error on Apache2 server

Just backed up a site to my local computer using CPanel.
I unzipped the file then placed it in /var/www.
Now my problem is that when I try to access HTML/PHP files from the public_html folder for the site via a browser (localhost/ndovucard/public_html/modules/contact_us.php), I get the 403 Forbidden Error by Apache2 server, and yes I did sudo chmod 755 /var/www.
Thanks.
There are can be several reasons why you are getting **403 Forbidden Error **
First check out weather you are denying permission to an .htaccess file and
that your apache2 is configured to allow htaccess file overide.
Check out your apache2 sites-available by using this command
in order to make your .htaccess files ( if you have any) work as expected, you need to edit this file:
sudo gedit /etc/apache2/sites-available/default
and then Look for a section that looks like this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None // change **`None`** to **`All`**
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
. You need to reload Apache in order this change to have an effect:
sudo /etc/init.d/apache2 reload
OR
sudo service apache2 restart
If that is not the case, you have have permission set not correctly as you have said .
sudo chmod 775 /var/www/yourProjectFolderHer* -R
Hope that may help
sudo chmod 755 -R /var/www
and show your /var/log/

Apache and vsftp file permission

I have setup apache according to this article
https://help.ubuntu.com/community/ApacheMySQLPHP
and I have created a new site config in /etc/apache2/sites-available/mysite
and changed the document root and directory to :
DocumentRoot /home/gapton/public_html
<Dictory />
..
..
</Directory>
<Directory /home/gapton/public_html/>
...
...
...
...
</Directory>
and I sudo a2dissite default && sudo a2ensite mysite to disable and enable them, restarted apache2 and things are working.
I then setup vsftpd and config the vsftpd.conf file to :
local_enable=YES
write_enable=YES
connect via Notepad++ with the user 'gapton' and I created a file called test.php under home/gapton/public_html. It would not be readable by Apache it seems. I did sudo chmod -R 755 ~/public_html and it would load alright.
However any subsequent files created via vsftpd will not be readable.
Since I have logged in to the only account gapton when connecting via FTP, then any newly created file should be owned by gapton right? What happens when apache tries to access a file/folder location, what credentials does it access it by?
How do I config it so that all files created by gapton can be read by apache? (Also, is it at all advisable?)
Thanks.
I found the problem.
In older version of vsftpd, the umask they apply when writing file was by default 022.
In the current version, such default value has been changed to 077. This mask read 4 write 2 and execute 1 for everyone except the owner.
Changing the umask value in the vsftpd.conf file back to 022 has solved my problem. Hope this help future users of vsftpd facing the same issue.

Change Apache rootdir to symlink, getting 403 Error

I'm new to .php and servers and all this craziness (and StackOverflow) but I've downloaded Apache and I'm trying to symlink a PHP code folder to the Apache root directory. My Apache root was var/www/html and my PHP code folder is Documents/PHPStuff. I renamed var/www/html to var/www/html2 and I made a symlink in var/www/ called 'html' which links to Documents/PHPStuff, thinking if I renamed the symlink to the name Apache is looking for then it would work.
It doesn't.
When I try to access my test file in Documents/PHPStuff called 'helloworld2.php' in my browser with 'localhost/helloworld2.php' I get a 403 Forbidden Error.
I've been messing with permissions on the symlink and in the PHPStuff directory, changing them to 777 and stuff but it hasn't worked. I also changed my httpd.conf file by changing FollowSymlinks None to FollowSymlinks All. Nothing has worked yet so this was my last resort.
Try to don't touch your http.conf. Instead, edit files from conf.d path.
To grant access to your home paths, edit your /etc/http/conf.d/userdir.conf to activate user dir option, like:
<IfModule mod_userdir.c>
#UserDir disabled
UserDir public_html
</IfModule>
<Directory "/home/*/public_html">
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
</Directory>
then, restart your apache.
Now, you have to create a directory /home/$USER/public_html and create into it the symlink to your ~/PHPStuff, like
ln -s ~/PHPStuff ~/public_html/PHPStuff
You can move PHPStuff to ~/public_html/ instead create the symlink.
Ensure that your homedir have 711 permissions, public_html have 755 and the dirs and files inside PHPStuff are readable by everyone.
Finally, type into your web browser
http://localhost/~user ('user' is your system username)
and you will see your PHPStuff listed. You can type
http://localhost/~user/PHPStuff
to view the PHPStuff content directly.
Good luck!
You shouldn't need to do all of that.
This is how I set up my symlinks.
When I install apache, it's web directory is located at /var/www/html which doesn't really need to be changed.
Then, I create a folder called public_html, you can call it PHPStuff, doesn't matter. What matters is that the folder is inside your home directory, so /home/your_username/PHPStuff
Then link that directory to /var/www/html
sudo ln -s ~/PHPStuff /var/www/html/$USER
You can then access ~/PHPStuff by going to your browser, and typing:
http://localhost/your_username
Which will give you access to ~/PHPStuff
After you do that, set proper permissions:
sudo chmod -R 777 ~
Then make sure apache allows symlinks by going to /etc/httpd/conf/httpd.conf and editing this portion Directory "/var/www/html"
And make sure you have these:
Options Indexes FollowSymLinks
AllowOverride All
Restart apache and everything will work.
You need to make sure apache has access to the folder that the symlink is pointing to, try running:
chmod a+x /home/your-username /home/your-username/Documents/PHPStuff

Categories