Laravel 5.1 project deployement permissions issues - php

I am trying to deploy my laravel project. I have installed apache, mysql, php, composer and laravel and pulled my project into /home/spark and ran composer install. Now when I surf to my ip I only see the apache test page.
When I take a peek in my log files I see these 2 errors:
[Sun Nov 22 17:37:54.598627 2015] [core:error] [pid 16141] (13)Permission denied: [client 78.20.130.157:50142] AH00035: access to /index.html denied (filesystem path '/home/spark/public/index.html') because search permissions are missing on a component of the path
[Sun Nov 22 17:37:54.598708 2015] [core:error] [pid 16141] (13)Permission denied: [client 78.20.130.157:50142] AH00035: access to /index.php denied (filesystem path '/home/spark/public/index.php') because search permissions are missing on a component of the path
I have no idea how to fix the permessions. Anyone can help me out?
Thanks in advance!
Here's my spark.conf file for my virtualhost maybe it's not good either:
<Directory "/home/spark/public">
Require all granted
</Directory>
<VirtualHost *:80>
ServerName myurl
DocumentRoot "/home/spark/public"
ErrorLog "/var/log/httpd/spark-error"
CustomLog "/var/log/httpd/spark-customlog" Common
</VirtualHost>
the permissions on my files in /home/spark/public
drwxr-x--- 5 root root 4096 Nov 22 16:33 .
drwxr-x--- 13 spark apache 4096 Nov 22 16:35 ..
drwxr-x--- 2 root root 4096 Nov 22 16:33 css
-rwxr-x--- 1 root root 0 Nov 22 16:33 favicon.ico
-rwxr-x--- 1 root root 412 Nov 22 16:33 .htaccess
drwxr-x--- 2 root root 4096 Nov 22 16:33 images
-rwxr-x--- 1 root root 1786 Nov 22 16:33 index.php
-rwxr-x--- 1 root root 24 Nov 22 16:33 robots.txt
drwxr-x--- 3 root root 4096 Nov 22 16:33 uploads

Make apache the owner of all your application folders and files like so :
sudo chown -R apache:apache .
your current folder should be the application folder before running this command

Related

How to solve PHP RuntimeException "Could not open log file" for Typo3

I tried to install Typo3 11 with Composer on an Ubuntu 20 with Apache2 as a webserver. PHP 7.4 and MariaDB are running, but PHP has problems to read and write in the Typo3 folder. (PHP Fatal error: Uncaught RuntimeException: Could not open log file
I installed Typo3 with Composer in a directory in home with
composer create-project typo3/cms-base-distribution:^11 project
composer install --no-dev
The directory now looks like this:
-rw-rw-r-- 1 sudoUser sudoUser 1371 Nov 13 20:36 composer.json
-rw-rw-r-- 1 sudoUser sudoUser 271237 Nov 13 20:36 composer.lock
drwxrwsr-x 3 sudoUser sudoUser 4096 Nov 13 20:36 config/
drwxrwxr-x 6 sudoUser sudoUser 4096 Nov 13 20:31 project/
drwxrwxrwx 6 sudoUser sudoUser 4096 Nov 14 09:00 public/
drwxrwsr-x 7 sudoUser sudoUser 4096 Nov 13 20:36 var/
drwxrwxr-x 24 sudoUser sudoUser 4096 Nov 13 20:36 vendor/
public looks like this:
-rw-rw-r-- 1 sudoUser sudoUser 815 Nov 13 20:36 index.php
drwxrwxr-x 3 sudoUser sudoUser 4096 Nov 13 20:36 typo3/
drwxrwxr-x 3 sudoUser sudoUser 4096 Nov 13 20:36 typo3conf/
drwxrwsr-x 3 sudoUser sudoUser 4096 Nov 13 20:36 typo3temp/
Then I created symlinks in /var/www/html for Apache2, so there are these symlinks to typo3:
lrwxrwxrwx 1 root root 25 Nov 14 14:49 index.php -> typo3src/public/index.php
lrwxrwxrwx 1 root root 31 Nov 14 14:48 typo3src -> /home/sudoUser/t3newProject//
Now if I go the start page, I don't get a typo3 landing page, I get a http response 500 (Internal Server Error). So I made a tail for /var/log/apache2/error.log and this is the result:
[Mon Nov 14 14:53:47.615281 2022] [php7:warn] [pid 81236] [client 188.102.130.86:55812] PHP Warning: fopen(/home/sudoUser/t3newProject/var/log/typo3_3a57bb40f2.log): failed to open stream: Permission denied in /home/sudoUser/t3newProject/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php on line 181
[Mon Nov 14 14:53:47.615336 2022] [php7:error] [pid 81236] [client 188.102.130.86:55812] PHP Fatal error: Uncaught RuntimeException: Could not open log file "/home/sudoUser/t3newEFFORT/var/log/typo3_3a57bb40f2.log" in /home/sudoUser/t3newProject/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php:183\nStack trace:\n#0 /home/sudoUser/t3newProject/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php(113): TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter->openLogFile()\n#1 /home/sudoUser/t3newProject/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php(72): TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter->setLogFile()\n#2 /home/sudoUser/t3newProject/public/typo3/sysext/core/Classes/Utility/GeneralUtility.php(3221): TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter->__construct()\n#3 /home/sudoUser/t3newProject/public/typo3/sysext/core/Classes/Log/LogManager.php(145): TYPO3\\CMS\\Core\\Utility\\GeneralUtility::makeInstance()\n#4 /home/sudoUser/t3newProject/public/typo3/sysext/core/Classes/Log/LogManager.php(106): TYPO3\\CMS\\Core\\Log\\LogManager->setWritersForLogger()\n#5 /home/sudoUser/t3newProject/public/typo3/sysext/cor in /home/sudoUser/t3newProject/public/typo3/sysext/core/Classes/Log/Writer/FileWriter.php on line 183
So I guess it has something to do with system file rwx permissions, but I don't know which folders or files or services I have to give which permissions, because there is no /home/sudoUser/t3newEFFORT/var/log directory. What do I have to change?
you said in a comment that permissions are read and write for everyone. But (for security reasons) the apache server should not be everyone. Normaly the apache user is more restricted than everyone.
Therefore it is important to have the correct user or at least usergroup for folders and files. Otherwise TYPO3 (or any script) can not work correct.
In general the apache user has it's own group (like www) and if you want to work in the folders of the webserver you should use this group and assign all files and folders to this group.
The usual right mask would be 664 for files and 2775 for folders. in combination with the group www.
You can assign these rights with these commands in the root folder of the instances
(something like srv/www/htdocs/instance1/):
chown webuser:www -R *
find . -type d -exec chmod 2775 "{}" \;
find . -type f -exec chmod 664 "{}" \;
If TYPO3 can access all files and folders can be checked in the 'Install-Tool' (either with the stand alone script webdomain/typo3/install.php or with the backend modules if your user is maintainer for the installation):
Admin Tools-> Environment -> Directory Status

Laravel 5.1 CentOs7 deployement Not Found The requested URL was not found on this server

I am trying to deploy my laravel project, I have installed Apache, MySQL, PHP, composer and laravel. I have pulled in my project via git and ran composer install, php artisan migrate --seed. When I go to my site I see the homepage of my app great! When I try to go to an other page let's say /auth/register I get the error The requested URL was not found on this server.
Here are my permissions on my files:
drwxr-xr-x 12 root root 4096 Nov 22 16:33 ..
drwxr-x--- 10 apache apache 4096 Nov 22 16:33 app
-rwxr-x--- 1 apache apache 1646 Nov 22 16:33 artisan
-rwxr-x--- 1 apache apache 320 Nov 22 16:33 behat.yml
drwxr-x--- 3 apache apache 4096 Nov 22 16:33 bootstrap
-rwxr-x--- 1 apache apache 1665 Nov 22 16:33 composer.json
-rwxr-x--- 1 apache apache 143064 Nov 22 16:41 composer.lock
drwxr-x--- 2 apache apache 4096 Nov 22 16:33 config
drwxr-x--- 5 apache apache 4096 Nov 22 16:33 database
drwxr-x--- 3 apache apache 4096 Nov 22 16:33 features
drwxr-x--- 8 apache apache 4096 Nov 22 16:33 .git
-rwxr-x--- 1 apache apache 135 Nov 22 16:33 .gitignore
-rwxr-x--- 1 apache apache 503 Nov 22 16:33 gulpfile.js
-rwxr-x--- 1 apache apache 159 Nov 22 16:33 package.json
-rwxr-x--- 1 apache apache 87 Nov 22 16:33 phpspec.yml
-rwxr-x--- 1 apache apache 899 Nov 22 16:33 phpunit.xml
drwxr-x--- 5 apache apache 4096 Nov 22 16:33 public
-rwxr-x--- 1 apache apache 1928 Nov 22 16:33 README.md
drwxr-x--- 5 apache apache 4096 Nov 22 16:33 resources
-rwxr-x--- 1 apache apache 567 Nov 22 16:33 server.php
drwxr-x--- 5 apache apache 4096 Nov 22 16:33 storage
drwxr-x--- 2 apache apache 4096 Nov 22 16:33 tests
-rwxr-x--- 1 apache apache 494 Nov 22 16:33 Vagrantfile
drwxr-x--- 39 apache apache 4096 Nov 22 16:42 vendor
My virtual host file:
<Directory "/home/spark/public">
Require all granted
</Directory>
<VirtualHost *:80>
ServerName myurl
DocumentRoot "/home/spark/public"
ErrorLog "/var/log/httpd/spark-error"
CustomLog "/var/log/httpd/spark-customlog" Common
</VirtualHost>
Fixed it by adding:
Allowoverride All
My virtual host file looks like this now
<Directory "/home/spark/public">
Require all granted
Allowoverride All
</Directory>
<VirtualHost *:80>
ServerName myurl
DocumentRoot "/home/spark/public"
ErrorLog "/var/log/httpd/spark-error"
CustomLog "/var/log/httpd/spark-customlog" Common
</VirtualHost>
Try:
<VirtualHost *:80>
ServerName myurl
DocumentRoot "/home/spark/public"
<Directory "/home/spark/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/httpd/spark-error"
CustomLog "/var/log/httpd/spark-customlog" Common
</VirtualHost>
and sudo restart apache2

Cannot run index.html from /var/www/html - 403 forbidden

I copied a few files from a local folder to the apache server folder /var/www/html, which includes an index.html as well.
I created a test file to check php version inside the folder and it gave the correct result of phpinfo().
But I cannot run localhost/index.html from the browser. I get the error-
Forbidden
You don't have permission to access /index.html on this server.
Apache/2.4.7 (Ubuntu) Server at localhost Port 80
I checked the owner info by running ls -l inside /var/www/html, and this is the result-
drwx--S--- 4 root www-data 4096 Mar 26 22:28 ch01
-rw-r--r-- 1 root www-data 20 Mar 26 22:16 check.php
-rw------- 1 root www-data 36911 Mar 26 22:28 fang.jpg
-rw------- 1 root www-data 2060 Mar 26 22:28 index.html
-rw-r--r-- 1 root www-data 19 Mar 26 22:28 pp.php
-rw------- 1 root www-data 1261 Mar 26 22:28 report.php
-rw------- 1 root www-data 77 Mar 26 22:28 style.css
I am trying to run the example code from head first into php and mysql.
I installed apache and php using this guide - https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu
-rw------- 1 root www-data 2060 Mar 26 22:28 index.html
The file is
owned by root (who can read and write to it (rw-))
a member of the www-data group (which can't do anything with it (---))
can't be touched by the public (---)
Your webserver is almost certainly running as www-data, so you need to either:
Change the ownership of the file: chown www-data index.html or
Give the group permission to edit it: chmod 660 index.html
You have similar issues with other files.
NB: The current ownership and permissions suggests that you are using the root account to manage the files for the website. Don't do that. Create an account with more limited access for that purposes. Only run as root when you really have to.
the default location is
/var/www/
and not '
/var/www/html/
you can access the index.html at
http://localhost:80/html/index.html

How do I resolve this 403 forbidden error

I have a vhost on a Centos machine (Linux i-8941-35408-VM 2.6.18-308.11.1.el5xen #1 SMP Tue Jul 10 09:29:47 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux). My Vhost config file is as follows
<VirtualHost *:80>
ServerAdmin myemail#gmail.com
ServerName subdomain.domain.biz
ServerAlias sudomain.domain.biz
DocumentRoot /home/myfolder/public_html/subdomain.domain.biz/public
LogLevel warn
ErrorLog /home/myfolder/public_html/subdomain.domain.biz/log/error.log
CustomLog /home/myfolder/public_html/subdomain.domain.biz/log/access.log combined
<Directory /home/myfolder/public_html/subdomain.domain.biz/public>
Options FollowSymLinks -Indexes -Includes
#What about Multiviews for Options above
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I do not have a .htaccess file.
The directory listing of the "public" folder is as follows
-rw-r--r-- 1 root root 2763 Jan 22 07:11 FailedTRAN.php
-rw-r--r-- 1 root root 11890 Jan 22 18:54 GetHandleRESponse.old
-rwxrwxrwx 1 root root 12024 Jan 23 17:14 GetHandleRESponse.php
drwxr-xr-x 2 root root 4096 Jun 9 2012 images
-rw-r--r-- 1 root root 2562 Jan 22 07:11 Index.html
-rw-r--r-- 1 root root 9556 Jan 23 18:21 SendPerformREQuest.php
-rw-r--r-- 1 root root 3396 Jan 22 07:11 StatusTRAN.php
I am able to access the Index.html from my browser, However any attempt to access GetHandleRESponse.php results in a 403 Forbidden error. So when I send out a request to another server the other server has to post its responses by accessing the GetHandleRESponse.php page. This fails. I am unable to figure out why this is the case. Any help would be appreciated.
The directories should have the x permission (x doesn't mean execution when we work with dirs, x means access permission).

PHP5.3 (as Apache module) unable to write into /var/www/<project-name>/<document-root>/cache

Please, be patient while reading, because the problem is seems to be transparent but just only seems.
The situation is:
1.
OS: fedora-16 (latest),
httpd: apache-2.2.21,
php: php-5.3.8 (works as apache's module)
2.
host information:
DOCUMENT_ROOT: /var/www/[site-name]/public_html
Kohana-3.2.0 (latest stable) installed this way:
$ pwd
/var/www/<site-name>
$ ls -alp
drwxr-xr-x. 6 apache apache 4096 Jan 7 20:35 ./
drwxr-xr-x. 8 apache apache 4096 Jan 7 20:08 ../
drwxr-xr-x. 9 apache apache 4096 Jul 25 03:26 application/
drwxr-xr-x. 10 apache apache 4096 Jul 25 03:26 modules/
drwxr-xr-x. 2 apache apache 4096 Jan 7 20:35 public_html/
drwxr-xr-x. 11 apache apache 4096 Jul 25 03:26 system/
$ cd application/; ls -alp
drwxr-xr-x. 9 apache apache 4096 Jul 25 03:26 ./
drwxr-xr-x. 6 apache apache 4096 Jan 7 20:35 ../
-rwxr-xr-x. 1 apache apache 3612 Jul 25 03:22 bootstrap.php
drwxrwxrwx. 2 apache apache 4096 Jan 8 20:14 cache/
drwxr-xr-x. 4 apache apache 4096 Jul 25 03:26 classes/
drwxr-xr-x. 2 apache apache 4096 Jul 25 03:26 config/
drwxr-xr-x. 2 apache apache 4096 Jul 25 03:26 i18n/
drwxrwxrwx. 2 apache apache 4096 Jul 25 03:26 logs/
drwxr-xr-x. 2 apache apache 4096 Jul 25 03:26 messages/
drwxr-xr-x. 2 apache apache 4096 Jul 25 03:26 views/
Command `top` says that Apache is really starts under `apache` user privileges.
So how can I have that application/cache and application/logs directories are unwritable? - I've checked them also with
var_dump(fopen($_SERVER['DOCUMENT_ROOT'] . '/../application/cache/something.txt', 'w+'));
Same result. Have no idea how it could be. No symlinks, no mounted drives etc.
Have anyone met such a situation?
Disable selinux (http://www.crypt.gen.nz/selinux/disable_selinux.html).
BTW from security standpoint, it's a very bad idea to make apache owner of .php files

Categories