Configuring Codeigniter framework on Linux - php

I've installed Codeigniter on Linux CentOS.
I extracted everything to my web directory, set everything up, and everything worked fine.
Next I moved my application/ and system/ folders outside the web directory, and then provide full path to them in index.php. The folders I provided resolve fine from the command line, but I continue to get the error:
Your application folder path does not appear to be set correctly. Please open the following file and correct this: index.php
Here are the full path locations:
$system_path = '/data/utilities/codeigniter/system/';
$application_folder = '/data/utilities/codeigniter/application/';

First, is utilitities a typo only here, or in your index.php, too?
Second, does Apache have full access to /data, utilities, and codeigniter?

What are the permissions of the folders? The Apache user might not have access to those folders. You can find out the permission by using the command ls -la and then set the owner or group to the Apache user chown www-data:www-data -R /data/utilitities/codeigniter/system/
and chown www-data:www-data -R /data/utilities/codeigniter/application/ (Assuming that the Apache user is www-data).

Permissions were not set correctly... silly mistake. I did this to fix it:
sudo chmod -R 755 /data/utilities/codeigniter/

Related

give access to file outside www/html folder

I have LAMP server
Server version: Apache/2.4.29 (Ubuntu)
PHP: PHP 7.2.5-0ubuntu0.18.04.1
I need to give an php SQLITE3 access to db outside www/html folder.
Right now my filesystem looks this way.
/root
./database
user.db
/var
./www
./html
index.html
reg.php
user.db must be located in /root/database, so just putting it inside var/www/html isn't solution for me.
So I need to give access to this folder for Apache or php.
I found some information here https://httpd.apache.org/docs/2.4/urlmapping.html, but didn't get how this works and where I need to put this?
The problem here is Linux permissions, not URL mapping, as PHP is running in the server, in the backend.
If you run PHP as an Apache module, (mod_php or something like that), it will run with the Apache user and group (usually www-data:www-data or nobody:nogroup, it depends of the LAMP configuration).
So, you should give permissions and change ownership to the user.db file and its tree, something like:
chmod o+x /root
chmod o+x /root/database
chown www-data:www-data /root/database/user.db
You can read more about permissions here.

permission for var/www/html directory

I installed ubuntu server 14.04 then (apache,php and mysql).
I uploaded my website to /var/www/html and nuzip it and linked it to database.
When I request my ip in the browser i get the home page, but when click on any url in the site it returns 404 not found error - not from my website- but from the server.
I searched but problem not solved
this is what i tryed
chmod -R g+w /var/www/html
chown -R $user:$user /var/www/html/
chown -R www-data:www-data /var/www/html/
but non of this works.
any idea ?
If you are using Laravel, please keep in mind that you have to separate "public" folder and the app itself.
First of all, go to /var/www and create folder called "app".
Put everything in here excluding public folder.
Contents of public folder goes to /var/www/html.
Now, edit routes in /var/www/html/index.php
From __DIR__.'/../bootstrap/app.php to ../app/bootstrap/app.php
Do the same with other routes in here.
Don't forget to change the permissions. The easiest way would be to set it to 777 for the whole /var/www using sudo chmod -R 777 /var/www
Good luck.
I solved the problem by running this command
a2enmod rewrite
then restart apache server.
Thanks to everybody tryed to help me :)

Laravel root permission messed up

I have this Laravel project on my Ubuntu machine, and i accidentally gave chmod -R 777 to Ubuntu root. I did manage to cancel it, but it was to late. Now, like half of my root is green.
I have nothing useful on this machine except that Laravel project, and I have no problem with re-installing it. Is there a way to rebuild it? If not, when i backup my project, how to give it normal permission?
I've been through this before
Just run
sudo chmod 0644 -R * in your application's root directory
it will set the default permission level to -rw-r--r-- (0644). As new laravel application comes with this permission level.
and you need to give write permission to storage folder and its files so run
sudo chmod 0755 storage and sudo chmod 0755 storage/* -R
You are good to go now. and for more about file and its permission level, I would recommend you to go through this https://askubuntu.com/questions/638796/what-is-meaning-of-755-permissions-in-samba-share it will help.
When you reinstall the project it will gain the regular permissions. Remember that you only have to give 777 permissions to the "storage" folder.
And as far as I know, there is no way to set your Ubuntu files as they were before.
Just change and update permissions of public/ folder inside your Laravel app/ folder to 0775, and then change permissions of files inside public_html/ folder to 0644. Also what is worth of noticing is user:group. What server and how do you run PHP handler?

Allow creation of folder on apache2 in Ubuntu Server

I'm creating a site which I'm going to host on an Ubuntu Server. I have a user registration form on my site, which creates a user and a folder for that user (if filled out correctly). The form in handled by PHP and I'm running Apache 2 on the server. When I run the code on my laptop the folder is created, but when I run the same code on the server the folder is not there. I guess that it has something to do with permisssion. How can I tell apache that the code should have write permission in a specific folder called "users" located in /var/www/mysite/public/users/ ???
Try using chmod command that provides folder permission. Something like
chmod 777 -R foldername
If security is not an issue I would suggest:
chmod 775 -R /var/www/
chown -R [your_user]:www-data /var/www/
So both apache2 (www-data) and you can edit folders and files inside /var/www (or /var/www/html if this is your folder).
Notice that this may have issues with git and other tools that capture folder permissions (eg with git you may commit files with 775).

CakePHP chmod question

I downloaded CakePHP and put it in my www directory. I enabled mod-rewrite and all that and changed my document root. But I still get permission denied errors in my apache error log because Cake can't require the files from other directories. It's almost as if I need to chmod every single directory to 777 in order to make this work. I know that's not right but can someone tell me if I did not install it correctly or what to CHMOD. Because so far it's literally every folder I'm going through CHMODing right now.
Try
chown -R <webserver_user> <cake_dir> #set the owner of your cake dir recursively to your webserver
chmod -R 755 <cake_dir> #set the permissions recursively
you can get the webserver user with
ps -aux | grep apache #or whatever your web server is

Categories