Apache2 not serving php scripts - php

I have searched the web for days now, taking what I have found and applying it to my configuration and still cannot work with php on my local machine. I am at a total loss and frustrated to say the least!
Running on Linux Mint 18 Cinnamon 64-bit and pretty sure that Ive went over all configuration files that otherwise need to be edited in order to get php configured, I'm at a stand still! The following are my Apache2 files.
apache2.conf
ServerRoot "/etc/apache2"
The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
Mutex file:${APACHE_LOCK_DIR} default
PidFile: The file in which the server should record its process
identification number when it starts.
This needs to be set in /etc/apache2/envvars
PidFile ${APACHE_PID_FILE}
Timeout: The number of seconds before receives and sends time out.
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory /srv/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
And,
dir.conf
<IfModule mod_dir.c>
Directory Index index.php index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
I keep reading references to the httpd.conf file however this file does not exist. Am I suppose to manually create my own following an installation?
All I get is the following error when navigating to http://localhost/
**Error**
Not found: vhost: localhost
In the past I never bothered creating separate sites/vhosts. All I am interested in is getting php served up when navigating to my /var/www/html directory.
Any help would be greatly appreciated!#

Related

Set up a local server on an external hard drive - Forbidden error

I have a Mac OSX El Capitan operating system. Since my laptop has limited space, I am trying to set up a local server on my 1TB external hard drive with the url http://media.database/, and that uses PHP. I have set it up the best I know how, but when I go to the page, it says "Forbidden You don't have permission to access /index.php on this server."
I have set apache and host files as best I know how, but I'm still pretty new to this sort of thing. I have listed my updates to those files below and restarted the apache server using sudo apachectl restart, which has gotten me this far. Can someone enlighten me on what I might be missing. All help is greatly appreciated.
/etc/apache2/httpd.conf
<VirtualHost *:80>
ServerName media.database
DocumentRoot "file:///Volumes/DBTARA/media/"
<Directory "file:///Volumes/DBTARA/media/">
DirectoryIndex index.php index.html
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/hosts
127.0.0.1 media.database
/etc/apache2/users/vmbmacintosh.conf
<Directory "file:///Volumes/DBTARA/media/">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
/etc/apache2/httpd.conf
I attempted to add the following DocumentRoot after the one I already have, but that made my other local servers inaccessible and kept the external one as forbidden.:
DocumentRoot "file:///Volumes/DBTARA/media"
<Directory "file:///Volumes/DBTARA/media">
Options FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride None
Require all granted
</Directory>
Thanks again in advance for any assistance.

PHP-FPM requires restart to access generated file when visiting webpage

As part of a web-based project I work on, we generate new "sites" which are accessed by passing in a different parameter to $_GET. All of the sites live in /usr/local/sites. None of the sites are owned (either user or group) by the user we use (hwphp, www-data is the default apache user still), but the user is in the group so can read all files in the directories.
I have a python script that generates sites and after running it, half the time when I try and visit it by going to http://localhost/index.php?site=newsite I get File not found: /var/local/sites/newsite/config/config.ini though running PHP CLI it can find the file and hwphp user can read it just fine, just when I go through PHP-FPM/Apache it fails.
Here's my pool configuration:
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[submitty]
user = hwphp
group = hwphp
listen = /run/php/php7.0-fpm-submitty.sock
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
and my apache configuration:
<VirtualHost 192.168.56.101:80>
AddDefaultCharset utf-8
ServerAdmin ADMIN#DOMAIN.HERE
ServerName 192.168.56.101
DocumentRoot /usr/local/submitty/site/public
DirectoryIndex index.html index.php index.htm index.cgi
SuexecUserGroup hwphp hwphp
<IfModule mod_fastcgi.c>
AddHandler php7-fcgi .php
Action php7-fcgi /php7-fcgi
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm-submitty.sock -pass-header Authorization
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler php7-fcgi
</FilesMatch>
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
</IfModule>
<Files .*>
Order allow,deny
Deny from all
</Files>
<Files *~>
Order allow,deny
Deny from all
</Files>
<Files #*>
Order allow,deny
Deny from all
</Files>
<Directory />
AllowOverride None
</Directory>
<Directory /usr/local/submitty/site/public>
Require all granted
Order allow,deny
Allow from all
</Directory>
LogLevel error
ErrorLog ${APACHE_LOG_DIR}/submitty.log
CustomLog ${APACHE_LOG_DIR}/submitty.log combined
</VirtualHost>
as soon as I do:
service php7.0-fpm restart
and it works fine and the file is found. Not sure why this might be as it makes no sense (and why a simple restart is what fixes it).
Server is Ubuntu 16.04, using PHP 7 and Apache 2.4, everything from the stock apt-get installs.
The issue ended up being that PHP was doing some caching of the file read which was causing the issues when trying to open the files. Doing a restart of php-fpm flushed the cache and made things just work.

Squirrelmail apache forbidden page

I am using PHP 7.0.5 and Apache 2.4.20 and I would like to run Squirrelmail.
I am getting a 403 Forbidden error when I try to access any of the squirrelmail pages like HostName/squirrelmail, HostName/squirrelmail/src/login.php or HostName/squirrelmail/src/configtest.php ect.
In my httpd.conf I have:
Alias /squirrelmail /usr/local/squirrelmail/www
<Directory /usr/local/squirrelmail/www>
Options None
AllowOverride None
DirectoryIndex index.php
Order Allow,Deny
Allow from all
</Directory>
This is due to httpd 2.4 access control has changed from the previous version
the solution is as follows
Order allow,deny Allow from all
should be replaced by:
Require all granted
then restart httpd
systemctl restart httpd
You must check the log of Apache to solve the problem, in centos 7 the logs will be in tow pathes:
/var/log/httpd/error_log
Or
/var/log/httpd/ssl_error_log
In generally Apache vhost.conf file must contain this lines:
Alias /webmail /usr/share/squirrelmail
<Directory "/usr/share/squirrelmail">
Options Indexes MultiViews
Require all granted
AllowOverride none
Order allow,deny
Allow from all
Options +SymLinksIfOwnerMatch
DirectoryIndex index.php index.html index.htm
</Directory>

You don't have permission to access / on this server. Centos

I have a Centos server, and I'm trying to configure php and apache, but I just can't get anything to work.
I'm have the next relevant info on my httpd.conf:
Listen 8088
Listen 8089
ServerName 192.168.124.243:8088
DocumentRoot "/var/www/html"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
NameVirtualHost *:8089
<VirtualHost *:8089>
ServerAdmin webmaster#bitacora.com
DocumentRoot /root/bitacora/public
ServerName bitacora.com
ServerAlias www.bitacora.com
DirectoryIndex index.php
ErrorLog /root/bitacora/log/bitacora-error_log
CustomLog /root/bitacora/log/bitacora-access_log common
<Directory "/root/bitacora/public">
Options Indexes FollowSymLinks
AllowOverride None
Require All
</Directory>
</VirtualHost>
My /var/www/html folder is empty, I only have remote access to the server, and I'm modifying configuration files through ssh and adding files through ftp.
When I type http://192.168.124.243:8088/ I get the default apache page, since I have nothing inside my html folder.
But if I try to access my virtualhost through http://192.168.124.243:8089/ I get the You don't have permission to access / on this server error and I get the Directory index forbidden by Options directive: /var/www/html/
error on my log file.
I read many post about this error and they mostly suggest adding Indexes to the /var/wwww/html directory, but it is there, and I have added the ports to the firewall exception, I've been trying to configure this thing for hours without success.
I have tried many many things, mainly many differents attempts on the httpd.conf file, but nothing seems to work.
Any ideas?
EDIT:
So it seems that the Directory index forbidden by Options directive: /var/www/html/ has no relation, I added an empty index.html to the /var/www/html folder and the error is gone, BUT I still get the You don't have permission to access / on this server error.

Getting a 403 error after upgrading to php5.5

OK I am new to ASKING questions on stackoverflow, but I need to get this figured out. I have a VPS with Apache installed Running Ubuntu 12.04 LTS. I downloaded a php script which required php 5.4+ but I had 5.3 installed. Then I followed the instructions located at this link.
While doing the upgrade, the installer told me that my php.ini file was manually changed. I believe I did this in order to view the errors on screen with the "display_errors=on" variable a long time ago. I therefore selected the option to KEEP and USE the old version of php.ini. Once the installation was done and the apache server restarted. I went to my chrome browser and pressed "refresh" and to my dismay, "403 Forbidden".
Here is the conf file for the virtual server:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /home/{usr}/Public/
# Indexes + Directory Root.
DirectoryIndex index.html index.shtml index.php
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory /home/{usr}/Public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/{usr}/Public/log/{server}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/{usr}/Public/log/{server}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
I obscured the username to {usr} and the folder to {server} to keep anonymity. This file was created BY ME, by putting it together with some other example file. I'm not sure if this is correct, all I know is that before this upgrade, everything was working fine!
I also "LL"'d the "Public" folder and here's what I found:
drwxrwxrwx 28 {usr} {usr} 4096 Sep 4 01:09 Public/
It seems that all the folders under it have the same permission. Please help and if there are any questions, feel free to ask. I've been doing this for many years but by no means would I call myself an "expert".
Thanks in advance.
Did you also upgrade Apache 2 ?
Apache 2.4 has a new user rights policy system : http://httpd.apache.org/docs/2.4/upgrading.html#run-time

Categories