I just got a VPS and it's running CentOS 6.8 with WHM 58.0. I really don't want the WHM, I only want to add one site to the server. So I just installed an FTP server and uploaded the files to the Apache root dir at /usr/local/apache/htdocs and gave all files chmod 777.
All works good, but when I go to PHP or ajax to PHP I get "403 Forbidden". I suppose the problem is in the http.config but I really have no idea. Here is my http.conf file and I don't have any .htaccess files.
Among other things, you want to make sure that the Linux user that is running Apache has permission to read and execute the PHP files where they are on the server.
This is a good guide for transferring PHP files and setting the permissions using PHP: https://www.digitalocean.com/community/tutorials/how-to-use-sftp-to-securely-transfer-files-with-a-remote-server
There's also a guide here to setting up the server and checking that PHP is set up correctly here, but I assume you have done this already: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04
I just replace this
<Directory "/usr/local/apache/htdocs">
Options Includes Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
With this
<Directory "/usr/local/apache/htdocs">
Options Indexes
Order allow,deny
Allow from all </Directory>
Related
I've created a blog, it's a homework of my web application class. The teacher asked us to host it. I'm the only one who have decided to host the server at my own PC, which is always switched on.
I'm running this server in Windows 10. I'm using XAMMP.
I've created a domain name at no-ip.com. After hours of fighting against the configurations, I've got the website working in my computer, in my LAN and finally, the whole Internet too.
I know the worst have been over. So it's just a silly thing I want to fix. I have my website inside this directory: C:\xampp\htdocs\wordpress
If I want to access to it, I must write http://IP/DNS.ddns.net/wordpress
I want to get rid of the "/wordpress"
I would like to access to my website with the specific ddns I have created without having to type /wordpress at the end.
I'm sure this have a name but I can't guess it right now, and I don't know how to configure this for Windows 10. I'm still learning it in another subject, but it's for Linux and Windows Server (IIS). The most alike is Linux (Apache) but the files and directories are different.
Can you help me, please? Thanks in advance!
You should set DocumentRoot variable]1 in apache to the proper path.
For example if you have
DocumentRoot "c:/www"
<Directory "c:/www">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
You should edit it to be
DocumentRoot "c:/www/wordpress"
<Directory "c:/www/wordpress">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
And restart apache
My localhost was working without issue when I tried to follow this guide (https://davidsword.ca/development/setting-up-localhost-apachephp-on-icloud-drive/#comment-1974) to set iCloud as the localhost folder instead of /User/myusername/Sites. To be safe I copied the httpd.conf and username.conf files just in case. I didn't get iCloud working as localhost so deleted the updated httpd.conf and username.conf files and reverted to old ones.
Since then I can only get onto my localhost via http://localhost/~myusername/ and get a 403 error when accessing http://http://localhost (which always worked previously)
The phpinfo file is still showing the DOCUMENT_ROOT to be the iCloud one from the guide, even though in the httpd.conf file it shows the following:
DocumentRoot "/Users/myusername/Sites/"
<Directory "/Users/myusername/Sites/">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
I've restarted Apache and the macbook several times but it won't update. Is there somewhere else this is stored or a cache of something I can clear to force it to update?
I understand I can set up a virtual host to work around this but I'd rather update the documentroot if possible - thanks
I upgraded a digital ocean box from 14.04 to 16.04 and ran in to some issues. The .htaccess file is not being parsed. I can throw garbage at the top of the file which normally breaks a server and it does not matter, leading me to believe it is not being parsed. My ultimate goal is to parse html files as php.
Virtual host settings were not changed after upgrade and worked before.
You can see an instance of the test droplet here: http://162.243.70.81/
I spent about 3 hours digging through other solutions including:
Checking conf file:
//Part of conf file
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
Checking if rewrite module is enabled
Module rewrite already enabled
service apache2 restart
Review .htaccess file (this is the first few lines and the random chars should result in a 500 if working)
kldlkldfg
AddType application/x-httpd-php .html .inc
editing mime types and looking if some php extensions are not commented out.
When I did the upgrade I did keep old conf files when it said the previous were modified and offered to overwrite or keep. I kept the defaults. Keep in mind everything worked before the upgrade and can be seen at www.pylamdyes.com
When I upgraded to php7 I had to disable php5.
That is all of the relevant info I can think to give, happy to try anything or post specific info as requested. Thanks for looking at this.
Define your virtualhost correctly by removing the <Directory /> entry and use this instead:
<Directory /var/www/www.pylamdyes.com>
Require all granted
Options FollowSymLinks
AllowOverride all
</Directory>
About Directory / it should be in server config (outside virtualhosts) like:
<Directory />
Require all denied
AllowOverride none
</Directory>
Also note: if you have access to the server configuration, there is no reason to use .htaccess files. .htaccess files are meant for people without admin rights to configure the web server.
If you need access for another directory, such as the target for that Alias, then define it in the same fashion as the documentroot Directory entry I defined. Policy is and should always be, deny all to /, and give access to the specific directories from where you serve files.
I am trying to use PHP within my WAMP environment to create new directories (checking if they exists first) on a local drive (U:) which is mapped to a media server (\tr-svrwc-fms)- with no success: I receive a 403 error.
I've tried creating directory Aliases:
Alias /vid "tr-svrwc-fms//"
<Directory "tr-svrwc-fms//">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
and also:
Alias /vid "U:"
<Directory "U:">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow, Deny
Allow from all
</Directory>
I've even tried modifying the root directory settings in httpd.conf to "Allow from all".
my WAMP server version is 2.2 with Apache version 2.2.21
thank you in advance for your help
It is recommended to only use only UNC paths for network resources in httpd.conf
The syntax should look something like this:
Alias /vid "//laptop1/vid"
<Directory "//laptop1/vid">
...
</Directory
Where laptop1 of course will be different in your case.
I've learned that with WAMP installed on my local hard drive, the Apache server (as configured) does not allow for communication outside of the WAMP root folder due to permissions.
This type of communication can however be accomplished via a PHP shell script on the Command Line which doesn't route through the Apache Server.
I am not sure why this is happening as I am not very knowledgeable when it comes to Apache. Below is a copy of my VirtualHost.
If this gives any extra help as to how to get it to work, I am trying to run a CakePHP site. I know the site itself has no issues as I have another location I manage the code from and can get it running locally through Apache there.
<virtualhost *:80>
DocumentRoot "C:/sites/sitename"
ServerName dev.sitename.com
ErrorLog "logs/sitename.com-error.log"
CustomLog "logs/sitename.com-access.log" common
<directory "C:/sites/sitename">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</directory>
</virtualhost>
I am running this on Apache 2.0 and Win7sp1
UPDATE
I never found the real solution using the route I was on. I downloaded a fresh copy of WAMP and was soon able to get everything up and running, no problem.
In order to prevent apache from showing the directory listing, you need to disable indexes. Also, it's best to disable MultiViews as that will enable content-negotiating, which may produce unwanted side-effects
Change the options to;
Options -Indexes FollowSymLinks
Then, check that the .htaccess file is present inside your webroot (C:/Sites/Sitename), as that file is used to enable mod_rewrite
Additional pointers/hints
First of all, make sure that the DocumentRoot is pointing to the right directory of your application;
The standard directory structure of CakePHP looks like this;
app
/Config
/Controllers
/Views
......
/webroot
lib
/Cale
plugins
The DocumentRoot should point to your `app/webroot' directory, which contains all 'public' files.
Change the paths/directories in your virtual host to that directory and restart Apache.
If you're still getting a 403 error, change the URL you're visiting in your browser to this;
http://mywebsite.com/index.php
If this does work, check if the .htaccess file is present in that directory and mod_rewrite is installed in your Apache.
According to the answer from "thaJetzah" (sorry, can't comment yet:) )
403 Forbidden is better than having the index of the folder, because now you can see the logs/sitename.com-error.log log and hopefully it tells you, why it gives 403.
Just to make sure: The index.php is in the folder "C:/sites/sitename"?
If you can't isolate the error like this, it would be great to post here the output of the error.log when you try to access the page and it gives you 403.
Check this If you are running Ubuntu.