i use moodle ( is a learning management system ), and this cms need to .htaccess
with his content . content of my .htaccess file is :
deny from all
AllowOverride None
Note: this file is broken intentionally, we do not want anybody to undo it in subdirectory!
but when i see my site i face this message :
You need to create the directory mdldata19 with web server write access
there is .htaccess in 'mdldata19' directory.
is better content for this file?
The missing directory probably has nothing to do with .htaccess, but rather Moodle requires a writable directory called mdldata19.
Create a directory mdldata19 whereever the documentation specifies it be created, and make it writable by the web server user. On Apache systems, this is usually a user called www-data, apache, httpd, or others. You would need to find out the user Apache is running under by looking for the following directive in httpd.conf:
User <apacheusername>
Group <apachegroupname>
Then change the directory's group ownership to the Apache user and make it group-writable
chown yourusername:apachegroup mdldata19
chmod g+rwx mdldata19
Related
I am running my server on cPanel.
I have two users accounts:
/home/user1
/home/user2
From user2 I need to include /home/user1/public_html/config.php.
Is their anyway to apply this?
It is fully possible to access php files located in other parts of the hard drive than where the site is run. However, this depends on two things. First of, the web user needs read permissions for the file, and you need to define the root folder where that php file is located as a accessable folder for the website.
Setting file permissions for the file can be done with:
chmod +R 775 /home/user1/public_html/config.php
Defining the accessible folders for PHP depends on wether you are running Apache or Nginx.
In Nginx for example:
fastcgi_param PHP_ADMIN_VALUE "open_basedir =$document_root:/tmp:/usr/local/lib/php:/var/www/vhosts/yourdomain/httpdocs/:/home/user1/public_html";
In Apache:
Apache readme
Now you should be able to require the file like you normally would require any file:
require('/home/user1/public_html/config.php');
Why not just copy paste the /home/user1/public_html/config.php file to /home/user2/public_html/? If you don't have permissions to access or do any operation on the file, then you are simply not authorized to attempt this.
I'm using Apache 2 in Linux mint and I don't know where to store my files and projects. if I store it in var/www it is not accessible for me, I have to use command as super user. Are there any way to solve my problem?
- If I want to store in my home folder, what should I type in the address bar if I want to run my file?
- Are there any other good solution than these? (such as change the accessible to folder /var, or change the Root_Url of apache ...)
The easiest way to solve this provlem is by typing the following line in terminal:
sudo chmod -R 777 /var/www
and then enter your password. And now you are done. You can store all the PHP files in /var/www
You have to do a chmod, you can have more information in your terminal with comand man chmod to set the rights to write in that folder or else point the web-server elsewhere (the setting is in the https.conf file)
There is different solutions:
create a symlink from /var/www/link to your projet and set your project
create a virtualhost with the DocumentRoot to point to your project: http://httpd.apache.org/docs/2.2/vhosts/examples.html
in both cases your project must have gives permissions to the apache user (www-data?) to read/execute you project
You need to active the user_dir mod of apache and then run the content from your home folder.
To run a file in your hole directory you should go to localhost/~youruser/script.php of course after enabling user_dir
Everything depends on the use.
If you are looking for a configuration for a development server that is accessible only from limited host (such as localhost):
You can configure Apache (/etc/apache2/apache2.conf) to run with your user/group.
User myuser
Group mygroup
Store all your project in your user_dir (/home/myuser/projects/...)
Create a virtual host for any of your projects
All files generated by your server will be accessible to you and vice versa
One way to accomplish this is to edit the default virtualhost supplied with Apache 2. In Linux Mint 14 its configuration file is located at:
/etc/apache2/sites-enabled/
This directory should hold symlinks for all active sites, for me the default is named 000-default.
Change the lines with "DocumentRoot" and "Directory" to point wherever you like. The server should have read only privileges by default. If you are working on file manipulation then it will need permission to read and write files.
Once this is set, restart the server ("sudo service apache2 restart") and type localhost in your browser to access the directory you've set above.
For more advanced configs have a look at:
http://community.linuxmint.com/tutorial/view/853
http://community.linuxmint.com/tutorial/view/527
I have downloaded the CakePHP from it's site then I copied the files in srv/www/htdocs
renamed the folder to first_app
Here is the output(error and warnings that shows me):
Release Notes for CakePHP 2.0.0-dev.
Fatal error: Class 'Debugger' not found in /srv/www/htdocs/first_app/cake/libs/view/pages/home.ctp on line 26
also the tutorial tells me that I must have this:
Apache server with mod_rewrite
I didn't know how to find it and install it?
is that causing this problem?
I want to know how to add "another" root without having problem
I used this and no result:
<Directory /srv/www/htdocs/first_app/app/webroot>
Options None
AllowOverride All
Order deny,allow
Deny from all
</Directory>
also I changed the /etc/apache2/server-default.conf
I changed allow override None to Allow override All
in the part of this:
<Directory "/srv/www/htdocs">
chmod -R 0777 /srv/www/htdocs/first_app/app/tmp/
This makes the tmp dir writable for everybody (on your machine) so also for the web server. If you want to limit access, first try this, then browse to your CakePHP install, and then check in the cache dir which files have been created and what's the owner and group of those files.
The tmp dir contains more than just the cache dir, it also contains sessions and logs. Anything outside of /srv/www/htdocs/first_app/app/tmp/ does not need to be writable for the server, anything inside that folder should be writable.
The default CakePHP install comes with .htaccess files. You do need those files. They redirect every request to localhost/first_app (or any other dir your is installed in) into the webroot, so you don't have to do that yourself. You need to have AllowOverride All in your apache config. See here for instruction on how to enable that.
Please Go through these links
http://www.youtube.com/watch?v=9stiBWz71Ts
http://ubuntu-linux-apache-mysql-php.blogspot.com/2008/12/how-to-install-cakephp-on-linux-ubuntu.html
http://groups.google.com/group/cake-php/browse_thread/thread/3ba763933544ece
It may help you.
same problem on mac. on mac, i just right clicked on the directory it was concerned about and changed the permissions so that everyone could read/write, and clicked apply to enclosed files/folders.
I used to use linux but i'm not sure exactly how to do this, but hopefully this will get you on the right track? i assume that the command you posted changes the permissions of that folder, but maybe you need to change the permissions of the files and folders inside.
Seems it is a question about .htaccess, not sure what should I use.
How can I make files inside /data/ folder available to read and write only for scripts?
Users should not have access to them from browser window.
Simplest way to block access to non-scripts: move it outside the web server's document root. If your PHP files are served from /var/www/htdocs, put your data files in /var/www/data.
If that's not possible, the .htaccess solution looks like:
# don't let anyone access these files directly
Order allow,deny
Deny from all
You can change the ownership of the directory to the www or apache user, depending on what user your web-server is running as.
Then make sure that the permissions of the directory are set to 644 so that only the owner can write. If you want nobody else to be able to read, just make it 600.
I'm starting to unravel the mysteries of PHP and I configured the pre-installed Snow Leopard PHP and activated the Apache server in the system preferences. So far so good: it works if you put a PHP file in your ~/Sites directory.
Since I've my projects in a code/projects directory I created a symbolic link from the ~/Sites dir to the code/projects/one-project/php-dir and bang!, a 403 error: access forbidden.
I've been changing the permissions of the dirs to 777, but no luck.
Is anyone using the default Snow Leoapard configuration for PHP development and if so, how do you link to your codebase?
Thanks in advance,
Juan
Off the top of my head: it might be the FollowSymLink option in the Options directive of Apache (http://httpd.apache.org/docs/2.0/mod/core.html#options).
That might work if you set FollowSymLinks in your Apache config, but I suggest putting the PHP files under the web root directly.
One good method is to put the presentation files under the web root, and include/require any libraries directly from where they are in the code/projects directory (assuming that dir is readable by the web server user). The include dir shouldn't be writable by the web server, for security. Keep it owned by your user account, and set the permissions to 744.
I presume you have ~/code/projects/projectA/php-dir and ~/sites/php-dir
You need to make sure that the directory above the directory you're sym-linking is readable by the webserver. In this case you need to set the permissions on the folder to 755. Or at least that solved things for me.
you'll most likely need to add a Directory directive to your httpd.conf file as well...
<Directory code/projects/one-project/php-dir>
order allow,deny
allow from all
</Directory>
Above configuration allows access from all IP's, all hosts.
I myself use macports, I find it better since it isolates everything in the /opt directory. But it's a bit of work to get it running...