laravel and apache mod_status - php

I have enabled Apache mod_status on my server:
OS: centos 6
Server version: Apache/2.2.15 (Unix)
php version 7.1
I get a 404 error page for example.com/server-status as i dont know how can i serv this route, with laravel(5.2) route api or any other way?
my configuration in httpd.conf:
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1 ::1
Allow from .example.com
Allow from xxx.xxx.xxx.xxx #my ip address
</Location>
and in .htaccess
RewriteCond %{REQUEST_URI} !=/server-status

I use the following code on my .htaccess to server-info and server-status:
RewriteRule ^(server-info|server-status) - [L]
Make sure first you get server-info and server-status working.
Them, read the logs about permission issues (mostly are because of order from rules).
My system:
Laravel 6
Apache 2.4.1
FreeBSD 12.1

Try placing it inside the virtualhost tag
<VirtualHost *:80>
ServerAdmin tecmint#example.com
DocumentRoot /var/www/html/example.com
ServerName example.com
ErrorLog logs/example.com-error_log
CustomLog logs/example.com-access_log common
<Location /server-status>
SetHandler server-status
Order allow,deny
Deny from all
Allow from example.com
</Location>
</VirtualHost>

Related

domain without www redirects to xampp dashboard

My domain originally had a www (https://www.my-domain.com) i changed it recently to redirect to non www.
Now when i go to my-domain.com on my browser, it goes to my localhost XAMPP dashboard (https://localhost/dashboard/). and when i turn xampp off, i get a "Unable to connect" on firefox.
I've tried the site on my mobile and my mac, it works fine and points to the server. I've also reinstall xampp on my PC, and still get the same result.
Not sure if this is the issue, but my current .htaccess is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
</IfModule>
and my virtual host on my ubuntu server is
<IfModule mod_ssl.c>
<VirtualHost *:433>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/frontend/www
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName my-domain.com
Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias www.my-domain.com
SSLCertificateFile /etc/letsencrypt/live/my-domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/my-domain.com/privkey.pem
</VirtualHost>
<Directory /var/www/html/frontend/www>
Options Indexes FollowSymLinks MultiViews
AllowOvereride All
Order allow,deny
allow from all
Require all granted
</Directory>
</IfModule>
Any idea what's going on?
My server is running ubuntu 18 on AWS.
The usual problem here is that you have no matching virtualhost set up to handle your new servername.
When that happens on a server, it "redirects" you to first matching virtualhost (which is probably xampp dashboard).
You have probably changed the application and it's .htaccess, but you didn't modify your virtualhost for the domain.
if you DID modify yourvirtualhost, please make sure to restart xampp, otherwise xampp won't consider changes made.

XAMPP Access Forbidden

I have just downloaded the latest version of XAMPP with PHP version 7.2.4. I have made a very simple PHP validation for a HTML form and when I press submit it comes up with the following:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
I'd don't know what the problem is as I have tried changing Require none to Require all granted.
Please Help!
I have experienced this problem and found out that localhost link is not configured in
httpd_vhosts.conf.
So I added this line at the bottom part of httpd_vhosts.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName localhost
</VirtualHost>
Well, probably this must be happening because the localhost link is not configured in your xamp vhost, try to look for the vhosts configuration file and add the same one there. Just add this block of code making the appropriate path changes until your repository so that you can access the localhost:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#hcode.com.br
DocumentRoot "C:\ecommerce"
ServerName www.hcodecommerce.com.br
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\ecommerce">
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>
</VirtualHost>
By default in httpd.conf your entire system directory "/" is secured and not allowed access
in httpd.conf:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
Add the below additional under the above
<Directory /home>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
Change /home to your hosted installation public directory - e.g. /projects or /devsite.local etc...
For more info on Apache see here: https://httpd.apache.org/docs/current/mod/core.html#directory
The 'Options' are typical .htaccess directives - change as needed
The 'AllowOverride All' gives access to the /home folder and everything under it
The 'Require local' makes sure only localhost / 127.0.0.1 has access to folder and files under /home
Hope this helps :D

Apache is not redirecting to index.php in Arch Linux

I am trying to configure a Wordpress project on my localhost, but when I open the browser on localhost I only see the files in the root of my wordpress project.
If I click on index.php or access localhost/index.php it executes the PHP as expected.
I have installed apache 2.4, php 7.2 and php-apache 7.2.
My project is in /srv/http/mysite:
The relevant lines in /etc/httpd/conf/httpd.conf file:
LoadModule rewrite_module modules/mod_rewrite.so
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Note: Since httpd.conf is very big I showed only the lines I know to be relevant. If this is not enough I can upload the entire file on pastebin.
The file /etc/httpd/conf/extra/httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster#test.localhost
DocumentRoot "/srv/http/mysite/"
ServerName test.localhost
ServerAlias test.localhost
ErrorLog "/var/log/httpd/test.localhost-error_log"
CustomLog "/var/log/httpd/test.localhost-access_log" common
<Directory "/srv/http/mysite/">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
The file /srv/http/mysite/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
My /etc/hosts file:
127.0.0.1 localhost
127.0.1.1 mycomputer_name
127.0.2.1 test.localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
About this last file I noticed that if I remove the <IfModule ...> and </IfModule> site it works and redirects to index.php, but I would prefer not to change this file since it works the way it is on the remote server that uses ubuntu.
The main question is why this is not working but I would be also happy to know what the <IfModule mod_rewrite.c> is doing and why it is being ignored even though LoadModule rewrite_module modules/mod_rewrite.so is enabled.
I know this is not an easy question but I have not found anyone with this same problem on the web. I will be very grateful for any help.
Apache needs to be setup to recognize your index files (in this case index.php)
Do you have the following in your Directory
DirectoryIndex index.php
So
<Directory "/srv/http/mysite/">
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
In httpd.conf you should have something like...
<IfModule dir_module>
DirectoryIndex index.php index.htm index.html
</IfModule>
This would be your catch-all fall-back.
And then in your httpd-vhosts.conf one of many site descriptions might look something like...
<VirtualHost *:8080>
ServerAdmin admin#siteName.com
DocumentRoot "e:/Stack/Sites/siteName/web"
ServerName siteName
ServerAlias siteNameUser
<Directory "e:/Stack/Sites/SiteName/web">
DirectoryIndex index.php
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/siteName.error.log"
CustomLog "logs/siteName.access.log" common
</VirtualHost>
Note: The DirectoryIndex index.php in httpd-vhosts.conf site declaration is unnecessary if you included the fall-back defaults in httpd.conf
If you are not wanting to use default port 80 then in either file have something like: Listen 8080
For localhost I use: in httpd.conf... Listen 127.0.0.1:8080 and in httpd-vhosts.conf Listen 8080
In your hosts file you will need to define something like...
127.0.0.1 siteName siteNameUser www.siteName.com
Currently using: Apache/2.4.33 (Win64) PHP/7.2.4 ~ MySql 5.7.22 homebrew stack.
The httpd-vhosts.conf example portion is for Drupal 8.x - For WP your DocumentRoot and Directory will differ.
You can listen on multiple ports such as 8080 for dev, 8081 for test, 8082 for prod. Also you can have many different site definitions in your httpd-vhosts.conf file.
I prefer to define all sites in httpd-vhosts.conf, but you could just place them in httpd.conf

kerberos apache php partialy working

have a problem with kerberos authentication on apache php
Setup = RHEL 7
apache 2.4 from rhscl
php7 from rhscl configured with php-fpm
Kerberos is working perfectly on http://site.domain/
but not on http://site.domain/index.php
The same problem occurs for all sub directories when accessing a .php file.
There is a rewrite for php to fcgi in the vhost setup.
index.php => $_SERVER['REMOTE_USER']
vhost setup
<VirtualHost *:443 >
## Vhost docroot
DocumentRoot /opt/code70
<Directory /opt/code70>
Options Indexes MultiViews
Options FollowSymLinks
IndexOptions FancyIndexing HTMLTable VersionSort IgnoreCase
IndexOrderDefault Descending Date
IndexIgnore *.php
AuthType Kerberos
AuthName "Kerberos"
KrbMethodNegotiate On
KrbMethodK5Passwd On
KrbAuthRealms ....
....
KrbVerifyKDC Off
KrbSaveCredentials Off
KrbLocalUserMapping On
KrbAuthoritative On
Order allow,deny
Allow from all
Require valid-user
</Directory>
## SSL directives
SSLEngine on
SSLCertificateFile ......
SSLProtocol -ALL +TLSv1
SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM
SSLHonorCipherOrder On
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://localhost:9000/opt/code70/$1
</VirtualHost>

HHVM FastCGI configuration issues - ProxyPass fails

I am on Ubuntu 12.04 running on Vagrant. Apache 2.2.22
I have been trying to test my app on hhvm. I configured everything following this: https://github.com/facebook/hhvm/wiki/fastcgi
After adding fastcgi module part in my vhost config, I started getting 404 not found error. Then I found out I needed to use ProxyPassMatch. After adding ProxyPassMatch line, I started getting 500 Internal Error. My apache log shows this:
[warn] proxy: No protocol handler was valid for the URL /index.php. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
All the modules are enabled.
Here is my vhost config:
ServerAdmin webmaster#localhost
DocumentRoot /opt/myapp/www/
ServerName myapp.demo
ServerAlias myapp.demo
ErrorLog /var/log/apache2/myapp.demo-error_log
CustomLog /var/log/apache2/myapp.demo-access_log common
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/opt/myapp/public/$1
<IfModule mod_fastcgi.c>
<FilesMatch \.php$>
SetHandler hhvm-php-extension
</FilesMatch>
<FilesMatch \.hh$>
SetHandler hhvm-hack-extension
</FilesMatch>
Alias /hhvm /hhvm
Action hhvm-php-extension /hhvm virtual
Action hhvm-hack-extension /hhvm virtual
FastCgiExternalServer /hhvm -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 300
</IfModule>
Thanks!

Categories