I am trying to migrate a web application from a Slackware config of Apache to a CentOS 7 one. DocumentRoot set to /home/STORAGE and there is a simple index.html file in it for testing. Both /home/STORAGE and index.html have 777 permissions set, yet Apache reports :
access to /index.html denied ... because search permissions are missing on a component of the path.
On the other hand, phpMyAdmin works fine, configured with a separate .conf file in /etc/httpd/conf.d . I tried using their example to make a .conf file for my app, but it still reports the same error. I don't even know where to start looking here.
EDIT:
I think this has something to do with the user of Apache. It is set to a local user in httpd.conf not to root, but the only pages the server serves are those in directories owned by root.
It was not a permission error but a Selinux issue. I decided to use the default /var/www/html for the application but still, had to allow write access to some dirs. Here is what I typed:
sudo chcon -t httpd_sys_rw_content_t /some/dir/in/var/www/html -R
The first time I typed it without -R and the permissions didn't change (check with ls -Z /dir/path). Now it is fine.
Related
Running wordpress locally on a centOS 7 server running the latest apache, PHPmyadmin and mariadb-server.
IP/wordpress and IP/phpmyadmin on systems within the local network yields "403 forbidden" "you dont have permission to access (directory) on this server."
How can I fix this to allow the website to be seen on the public internet?
Could be a lot of things.
In your main Apache configuration file (e.g. /etc/httpd/conf/httpd.conf on Arch Linux), confirm your DocumentRoot path. The files you want to serve must reside there, or in sub-directories from there (If not, you might want to use an Alias to specify another path). Since you call IP/wordpress and IP/phpmyadmin, then you probably have directories called wordpress and phpmyadmin under your DocumentRoot path.
You also want to check the Directory groups in your Apache configuration file. Under those, the main culprit would be the Require directive set to all denied or something else too much restrictive like ip your_ip.
Finally, PHP can restrict path access with the open_basedir directive. Look for it in your php configuration file (e.g. /etc/php/php.ini on Arch Linux). If the line is commented, you're fine. But if a path is specified, your wordpress and phpmyadmin files must reside there.
Depending on your setup, any directive mentioned above could be in another Apache configuration file (e.g. /etc/httpd/conf/extra/* on Arch Linux).
Take a look at Apache and PHP online documentation for information about those directives.
Probably there is an issue with your directory privileges.
Use the follwing command to check it:
cd your_site_directory
ls -l
You can have a look to have a better understanding on directory privileges here.
As mentioned here apache runs under "apache" user.
Have a look at this post here to fix the issue.
All files should belong at least to apache group. To do it you can use
cd your_site_directory
chgrp -R apache ./*
I'm running dev server on Centos 6.4 with Apache 2.2. I just moved a site from the production to dev to perform upgrades. I modified file owner to apache:apache (httpd user) and set all directories to 755 and files to 644. I have few other sites in the DocumentRoot folder with similar settings and they run fine (using same CMS, PHP, MySQL versions etc).
I have no virtual hosts defined and Allow all on everything. httpd.conf is default.
I'm not able to make site working from the folder I just moved from the production. I'm getting 403 every time.
As suggested in
https://serverfault.com/questions/272947/apache-on-centos-5-6-gives-me-permissions-denied-error/272956#272956
Usually that comes from Selinux not giving access to the folder. do
ls -alZ /var/www
and if the html folder doesn't have the context system_u:object_r:httpd_sys_content_t, fix it with chcon
chcon -v -R --type=httpd_sys_content_t /var/www/html
http://wiki.centos.org/HowTos/SELinux
I am getting the following error:
Forbidden: You don't have permission to access [directory] on this server.
I need direct access to this directory and sub folders on that directory so that my Android Application can communicate with it.
I tried putting folders on a Hosting Server and everything works fine.
But, I am doing an academic project and I need to store these folders and scripts on a University Web Server which can talk to localhost locally.
1.
If you have the possiblity and your server is a linux server, you can change the permissions with something like
sudo chmod -R 777 /var/www/folder
Or completely change the owner with
sudo chown -R user /var/www/folder
2.
Look into the apache configuration files and also the .htaccess, if the directory is blocked by
Deny from all
Or simply not allowed. You could allow the directory by creating a .htaccess file and enter
<Directory yourdirectory>
Order allow,deny
Allow from all
</Directory>
I am using this guide:
http://codingthis.com/platforms/linux/how-to-host-simple-content-with-amazon-elastic-cloud-computing-ec2/
I have a folder named public_html in my /home/ec2-user directory with a test.html file.
What I have done so far:
sudo yum -y install httpd php
sudo chkconfig httpd on
chmod 755 /home/ec2-user (I HAVE NO IDEA WHAT THIS DOES)
sudo nano /etc/httpd/conf/httpd.conf
(changed DocumentRoot to DocumentRoot /home/ec2-user/public_html)
TLDR: How do I make it load my content (my html file) instead of the apache test page
EXTRA:
I have a security group enabled for my instance with rules:
ICMP Allow ALL
TCP Allow ALL
UDP Allow ALL
TCP port 80 (Http)
isnt your document root public_html instead of www? so why did u put ur pages under www directory?
If you have no content in the DocumentRoot that you configured then the default Apache install will show you that page instead of yours. Also, check the DirectoryIndex configuration to make sure that if you're using index.php or default.html or something else that this is configured as well. It defaults to index.html
Chmod755/directory/directory/etc.. Will give access to that directory. So if your website is in the folder *home/ec2-user/public_html* you would then need to give access to that directory.
Example: chmod 755 home/ec2-user/public_html
I was having the same issue. I fixed it by changing the permissions on the ec2-user directory like so:
chmod +x home/ec2-user
This give execution permissions to everyone on your user directory.
I had the same problem. All I have to do was just restarting the ec2 to apply the changes. - takes me 2h :(
I am interested in setting up a local php testing / development environment using the lamp stack.
I would like to use the php plugin for eclipse (I typically work with java and am very familiar with eclipse).
First of all, is it proper practice to develop my site locally directly within the apache /var/www directory?
If this is ok, can somebody describe how to properly set the permissions of the www directory so that eclipse (not being run as root) has access to read/modify php files within that directory?
This is strictly for local development so I assume security isn't as high of an issue.
It doesn't matter, I personally placed it in /var/www/ and put it under the www-data group, and placed my username into the www-data group.
You add yourself into the group with:
sudo usermod -a -G www-data <username>
Change the group to www-data just in case you haven't:
sudo chgrp -R www-data /var/www
Get new files to inherit the permissions (750)
sudo chmod -R 2750 www-data /var/www
Some people prefer to put it in /home/username/www/ which would be easier.
If you prefer to put it somewhere else, like your Eclipse workspace directory, you can change Apache's DocumentRoot (or create a VirtualHost with a different DocumentRoot). Edit Apache's httpd.conf file, and add this at the end:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mytestserver.localhost
DocumentRoot /path/to/project/dir
</VirtualHost>
The *s can be left as-is; that means they will work regardless of your IP address.
The ServerName can be anything you want, as long as you add a corresponding entry in your /etc/hosts file, e.g.:
127.0.0.1 mytestserver.localhost
I often make all my local servers end in ".localhost", just as a convention.
Finally, restart Apache. Then you can access the server at http://mytestserver.localhost. Repeat as necessary to use multiple virtual hosts, each pointing to a different project.
As long as the files can be read by everyone, which is usually the default, you should be fine.
It's definitely possible to work on your site directly in your server's /var/www/ directory. however, it's probably better practice to setup a local environment (using something like XAMPP) to edit your website on a development machine and then upload it to your live server when it's ready. that way you don't introduce any bugs or errors into the live site temporarily.