.htaccess: Options not allowed here Centos 7 - php

I am facing this error when deploy my laravel website on server centos 7
.htaccess: Options not allowed here
[Sat Oct 18 09:38:43.336180 2014] [core:alert] [pid 13593] [client 182.186.240.3:7034] /home/test/public_html/.htaccess: Options not allowed here
[Sat Oct 18 09:38:43.727177 2014] [core:alert] [pid 13589] [client 182.186.240.3:7123] /home/test/public_html/.htaccess: Options not allowed here

You need to provide this line in <Directory...> section of Apache config and restart Apache server in order to use Options directives in .htaccess:
Options All
As per Apache docs:
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.

Related

Trouble configuring custom folder for site (Apache)

I'm trying to configure httpd on fedora, but my two day effort has gotten me nowhere.
I installed httpd and php, added the configuration file for the site, everything is fine. I try to load it and see "access denied." but I have already granted to the apache user and apache group 755 rights (on every folder along the path).
Errors in apache log:
[Mon Jun 06 20:25:18.088420 2022] [negotiation:error] [pid 12656:tid
12758] (13)Permission denied: [client 127.0.0.1:45920] AH00686: cannot
read directory for multi: /home/concasse_master/Desktop/sample/public/
[Mon Jun 06 20:25:18.089421 2022] [proxy_fcgi:error] [pid 12656:tid
12758] [client 127.0.0.1:45920] AH01071: Got error 'Unable to open
primary script: /home/concasse_master/Desktop/sample/public/index.php
(Permission denied)'
localhost.conf:
<VirtualHost *:8080>
ServerName localhost
DocumentRoot /home/concasse_master/Desktop/sample/public
ErrorLog logs/error.log
CustomLog logs/access.log combined
<Directory /home/concasse_master/Desktop/sample/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Invalid command 'location', perhaps misspelled or defined by a module not included in the server configuration

Currently, I am setting my local environment for a project.
Project runs on production environment with nginx server. But in the local development, using apache server. I've installed LAMP stack on my ubuntu machine. There is already a virtual host file provided and I have setup it. So far I've created xxx.conf file under /etc/apache2/sites-available.
The file includes:
<VirtualHost *:80>
ServerName xxx
DocumentRoot /home/ubuntuser/Downloads/xxx-master/public
<Directory "/home/ubuntuser/Downloads/xxx-master/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/xxx-error.log
CustomLog ${APACHE_LOG_DIR}/xxx-access.log combined
SetEnv ENVIRONMENT "development"
</VirtualHost>
I also created .htaccess file under /home/ubuntuser/Downloads/xxx-master/public. The content of this file downloaded from production environment.
The content of .htaccess file is:
RewriteEngine On
RewriteBase /
location ~ ^/site { rewrite ^/site(.*)$ https://local.xxx.com/$1 redirect;}
So, when I type local.xxx.com in browser, it gives 500 Internal Error.
So, I was defined xxx-error.log in virtual host config file. I've opened it. The content is:
[Tue May 28 22:23:33.231851 2019] [core:alert] [pid 5677] [client 127.0.0.1:56504] /home/ubuntuser/Downloads/xxx-master/public/.htaccess: RewriteBase takes one argument, the base URL of the per-directory context
[Tue May 28 22:23:33.254608 2019] [core:alert] [pid 5678] [client 127.0.0.1:56506] /home/ubuntuser/Downloads/xxx-master/public/.htaccess: RewriteBase takes one argument, the base URL of the per-directory context, referer: http://local.xxx.com/
[Tue May 28 22:33:22.300863 2019] [core:alert] [pid 6326] [client 127.0.0.1:56740] /home/ubuntuser/Downloads/xxx-master/public/.htaccess: Invalid command 'location', perhaps misspelled or defined by a module not included in the server configuration
[Tue May 28 22:33:22.317420 2019] [core:alert] [pid 6327] [client 127.0.0.1:56742] /home/ubuntuser/Downloads/xxx-master/public/.htaccess: Invalid command 'location', perhaps misspelled or defined by a module not included in the server configuration, referer: http://local.xxx.com/
So, I understand there is problem in the .htaccess but i don't know how to solve it.
You are using apache and in your .htaccess using the convention of Nginx.
Refer to latest documentation of apache2.4
To me it seems like you want to redirect use this
RewriteRule ^/site(.*)$ https://local.xxx.com/$1 or maybe this
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

apache is crashing not working for a php framework

ServerAdmin webmaster#localhost
DocumentRoot /home/sachin/neuu-dashboard/Telemetry_Backend/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /home/sachin/neuu-dashboard/Telemetry_Backend/www>
Options FollowSymLinks
AllowOverride All
#Order deny,allow
#Allow from all
Require all granted
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
my apache is keep on crashing when am setting up a php framework
apache is working fine when it is pointing to a default var/www/html
after changing the path it asked enmod and rewrite that also i did but still it is crashing
as soon as i restarted on the very 1st request it crashed
the error code is below from error.log
[Sun Dec 09 13:04:31.953572 2018] [mpm_prefork:notice] [pid 24209] AH00169: caught SIGTERM, shutting down
[Sun Dec 09 13:04:32.048381 2018] [mpm_prefork:notice] [pid 24328] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sun Dec 09 13:04:32.048453 2018] [core:notice] [pid 24328] AH00094: Command line: '/usr/sbin/apache2'
help me out to set up the php framework

Serve php RESTful server with apache2 (ubuntu)

I have a ubuntu machine on which I want to run a php rest server. Here is my default config file:
ServerName localhost
<VirtualHost *:80>
DocumentRoot /var/www/html/otherSite
ServerName www.vlio20_paka.com
Alias /otherSite /var/www/html/otherSite
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/lbserver/public
ServerName www.vlio20_lb.com
Alias /lbServer /var/www/lbserver/public
<Directory /var/www/lbserver/public>
AllowOverride all
DirectoryIndex index.php
Require all granted
</Directory>
</VirtualHost>
In my public directory I have .htaccess file:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
When I try to access the server http://MACHINE_IP/lbServer
I am getting Not Found error.
How can I make it work
(I am doing apache restart after each change in the config file)?
Update:
apache2 -t produced:
[Sun Jun 28 12:00:00.789522 2015] [core:warn] [pid 22089] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Sun Jun 28 12:00:00.789835 2015] [core:warn] [pid 22089] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Sun Jun 28 12:00:00.789970 2015] [core:warn] [pid 22089] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Sun Jun 28 12:00:00.790088 2015] [core:warn] [pid 22089] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Sun Jun 28 12:00:00.790240 2015] [core:warn] [pid 22089] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sun Jun 28 12:00:00.794721 2015] [core:warn] [pid 22089:tid 140102153521024] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sun Jun 28 12:00:00.795136 2015] [core:warn] [pid 22089:tid 140102153521024] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sun Jun 28 12:00:00.795200 2015] [core:warn] [pid 22089:tid 140102153521024] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
note: the first site is loading fine but the second gives a 404 error.
First this as almost nothing to do with a REST problem. It is a simple configuration error.
Second, for apache2 -t you should run . /etc/apache2/envvars before, because you need some envs variables loaded.
Then the configuration problem.
Your are defining 2 named based Virtualhosts, 1 with the name www.vlio20_paka.com and one with the name www.vlio20_lb.com. The first one is defined first, so if you use an unknown name it will be used, by default.
When you make a query this way:
http://MACHINE_IP/lbServer
the Host header used in your HTTP query is MACHINE_IP, so it's not www.vlio20_paka.com and not www.vlio20_lb.com. If you have no other default virtualhost (something you would find using apache2 -S) the first one will be used.
Let's have a look at the first one:
<VirtualHost *:80>
DocumentRoot /var/www/html/otherSite
ServerName www.vlio20_paka.com
Alias /otherSite /var/www/html/otherSite
</VirtualHost>
If we fall here the path searched on your disk will be DocumentRoot+url, so /var/www/html/otherSite/lbServer. You have a 404, chances are this path does not exists.
Note that your Alias instructions here simply tells Apache that a request to http://www.vlio20_paka.com/ and a request to http://www.vlio20_paka.com/otherSite would both point to the /var/www/html/otherSite/ directory, maybe not what you wanted to do.
Alias is simply a way to define some sort of url symlinks on the url-to-filesystem maps.
Let's now look the second VirtualHost, that you can only reach if you use the right name in your HTTP request, that is not requesting http://MACHINE_IP/lbServer but http://www.vlio20_lb.com/lbServer (for that you could an entry in your /etc/hosts file, on the machine running the http query).
<VirtualHost *:80>
DocumentRoot /var/www/lbserver/public
ServerName www.vlio20_lb.com
Alias /lbServer /var/www/lbserver/public
<Directory /var/www/lbserver/public>
AllowOverride all
DirectoryIndex index.php
Require all granted
</Directory>
</VirtualHost>
So here you set a DocumentRoot at /var/www/lbserver/public but also, via Alias, you tell Apache that a request to http://www.vlio20_lb.com/lbServer/ point to the same entry as http://www.vlio20_lb.com/.
Your best fix would be to add an entry in /etc/hosts a request your test websites with real names, so that you can use Name based VirtualHosting. Or use only one VirtualHost and try things with aliases, but that's usually far from the production settings.
The only thing I think of without seeing more of your config.
Change:
<Directory /lbserver>
DirectoryIndex index.php
</Directory>
To:
<Directory /lbserver>
DirectoryIndex index.php
Require all granted
</Directory>
In ubuntu there is no binary httpd, apache2 used instead:
ricardo#zeus:~$ httpd -t
No se ha encontrado la orden «httpd», quizás quiso decir:
La orden «xttpd» del paquete «xtide» (universe)
La orden «https» del paquete «httpie» (universe)
La orden «http» del paquete «httpie» (universe)
httpd: no se encontró la orden
ricardo#zeus:~$ apache2 -t
Now , paste the command output ;-)

can't execute php files after changing default directory

I'm new to LAMP and running into some troubles trying to install it on Ubuntu 14.04. I changed the DocumentRoot in 000-default.conf to a new folder instead of var/www and now it can't execute .php files.
Below is my etc/apache2/sites-enabled/000-default.conf file:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot "full path to folder"
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Here is the error I get from /var/log/apache2/error.log
[Fri Oct 17 16:43:19.787413 2014] [core:notice] [pid 2433] AH00094: Command line: '/usr/sbin/apache2'
[Fri Oct 17 16:54:55.754101 2014] [mpm_prefork:notice] [pid 2433] AH00169: caught SIGTERM, shutting down
[Fri Oct 17 16:54:56.851627 2014] [mpm_prefork:notice] [pid 2943] AH00163: Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.4 configured -- resuming normal operations

Categories