Invalid Command 'RewriteEngine' but mod_rewrite is enabled - apache

I am setting up a gitlab site with this conf file
But this error arise:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
I have install apache 2.4.20 from source. And forgot that I have installed 2.4.7 with apt-get. Right now apache -v shows 2.4.7 though.
I have followed a lot of solutions but they do not work:
Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line)
Apache2 ProxyPass for Rails App Gitlab
I have check the rewrite modules and it is there; a2enmod rewrite is enabled and service apache2 restart worked without the gitlab.conf file.
But with gitlab.conf, this error appear Invalid command 'RewriteEngine'?

I am having the same issue using Vagrant to setup a VM.
I finally resolved this by setting the ip for the client in the Vagrantfile configs:
config.vm.network :private_network, ip: "192.168.68.8"
Then adding to the local /etc/hosts file:
192.168.68.8 namespace.dev

Related

Amazon EC2 hide phpmyadmin route [duplicate]

I am wondering how to change the default URL for phpMyAdmin. I am using the latest version (4.0.4.1) on my CentOS 6 VPS. I am wanting to change it from /phpmyadmin to something more secure. I am unsure how to do this or where to even find my apache.conf file if there is one?
Thanks!
For ubuntu (i used ubuntu 12.04), the default phpmyadmin apache configuration can be found at /etc/phpmyadmin/apache.conf
You can open it by type sudo nano /etc/phpmyadmin/apache.conf and change the third
Alias /yournewalias /usr/share/phpmyadmin
Do not forget to restart apache service,
sudo service apache2 restart
phpMyAdmin default Apache configuration
Alias /phpmyadmin /usr/share/phpmyadmin
Change that to
phpMyAdmin default Apache configuration
Alias /anyname /usr/share/phpmyadmin
Then make sure to restart Apache
sudo /etc/init.d/apache2 restart
Edit this file
/etc/apache2/conf-available/phpmyadmin.conf
line 3: change the line to be
Alias /whateveryouwant /usr/share/phpmyadmin

How to include UserDir paths to ProxyPass - Apache 2.4.7 on Ubuntu 14.04

I have this configuration:
Ubuntu Server 14.04
Apache 2.4.7 with proxy_module
PHP 5.5.9 + PHP5-FPM
I am passing all request for PHP files, with the php file extension, to the PHP wrapper through FastCGI with the following command:
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
Now the problem is that when I am accessing the server with the following URL http://127.0.0.1/~myuser/phpinfo.php I receive File not found
If I am accessing it like this http://127.0.0.1/phpinfo.php it's working.
My question is how can I get rid of File not found error when I want to access the url with the user in it?
You have to add following lines to your httpd configuration
ProxyPassMatch ^/~myuser/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/path/to/myuser/public_html/$1

How do I configure SSL on Apache on Ubuntu?

I tried to enable SSL on my Apache server on Ubuntu, but when I restart the Apache server it shows the following error:
Syntax error on line 3 of /etc/apache2/sites-enabled/000-default:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
That is complaining about mod_rewrite not your ssl cert.
Try
sudo a2enmod rewrite
sudo service apache2 restart

setting up passenger: keeps showing apache default page instead

I am trying to get passenger to work but i keep seeing the apache default page instead. I am using centos 6.3 on an inmotion VPS. Here is what I've done so far:
gem install passenger.
rvmsudo passenger-install-apache2-module
pasted the following code into /usr/local/apache/conf/includes/post_virtualhost_global.conf (this gets loaded into httpd.conf)
LoadModule passenger_module /home/username/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17/ext/apache2/mod_passenger.so
PassengerRoot /home/username/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.17
PassengerRuby /home/username/.rvm/wrappers/ruby-1.9.3-p194/ruby
<VirtualHost 123.123.123.123:80>
ServerName http://XXXXXX.inmotionhosting.com
# !!! Be sure to point DocumentRoot to 'public'!
DocumentRoot /home/username/rails/current/public
<Directory /home/username/rails/current/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
edit: not sure why this isnt formatting properly. its lined and tabbed fine in the text editor.
in etc/hosts there is the line:
123.123.123.123 XXXXXX.inmotionhosting.com XXXXXX
i restarted apache via sudo service httpd restart in /etc/init.d
still shows apache default page
Any ideas? thanks
I stumbled upon this 1 year old post for the similar problem but none of the comment worked for me. So I'm just adding my 2 cents for those who are looking for some help.
If you are seeing Apache default page, it means that phusion passenger is probably not running. You might have seen a warning message when you started/stopped/restarted the apache server that says the phusion passenger module is already loaded, skipping.
So Apache has skipped the most recent LoadModule line you added in the conf file.
Then check the error.log which is in the directory set for error log in apache config file. (httpd.conf for centos)
In my case, it was complaining that it couldn't find the watchdog in the directory set in PassengerRuby. This confirms that the passenger module loaded is NOT what I just added. This might have happened because I am using RVM now but also installed an old version of Passenger a while ago as a root. So I looked at the config.d directory under Apache root, there was a file "passenger.conf" that was loading the old version of Passenger.
I deleted the file, kept the new LoadModule as is - copied from the instruction Phusion Passenger gave me while installing apache2-module, restarted the apache server, no warning message, and passenger worked.

How to install mod_ssl for Apache httpd?

Ok
So I installed Apache httpd a while ago and have recently come back to it to try setup SSL and get it serving several different tomcat servers.
At the moment I have two completely separate Tomcat instances serving up to slightly different versions (one for dev and one for demo say) my web app to two different ports:
example.com:8081
example.com:8082
I've successfully (back in Jan) used mod_jk to get httpd to serve those same Tomcat instances to http://www.example.com:8090/dev and http://www.example.com:8090/demo (8090 cos I've got another app running on 8080 via Jetty at this stage) using the following code in httpd.conf:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel debug
<VirtualHost *:8090>
JkMount /devd* tomcatDev
JkMount /demo* tomcatDemo
</VirtualHost>
What I'm not trying to do is enable SSL.
I've added the following to httpd.conf:
Listen 443
<VirtualHost _default_:443>
JkMount /dev* tomcatDev
JkMount /demo* tomcatDemo
SSLEngine on
SSLCertificateFile "/opt/httpd/conf/localhost.crt"
SSLCertificateKeyFile "/opt/httpd/conf/keystore.key"
</VirtualHost>
But when I try to restart Apache with apachectl restart (yes after shutting down that other app I mentioned so it doesn't toy with https connections) I continuously get the error:
Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration. httpd not running, trying to start
I've looked in the httpd/modules dir and indeed there is no mod_ssl, only mod_jk.so and httpd.exp.
I've tried using yum to install mod_ssl, it says its already installed. Indeed I can locate mod_ssl.so in /usr/lib/httpd/modules but this is NOT the path to where I've installed httpd which is /opt/httpd and in fact /usr/lib/httpd contains nothing but the modules dir.
Can anyone tell me how to install mod_ssl properly for my installed location of httpd so I can get past this error?
I found I needed to enable the SSL module in Apache (obviously prefix commands with sudo if you are not running as root):
a2enmod ssl
then restart Apache:
/etc/init.d/apache2 restart
More details of SSL in Apache for Ubuntu / Debian here.
Are any other LoadModule commands referencing modules in the /usr/lib/httpd/modules folder? If so, you should be fine just adding LoadModule ssl_module /usr/lib/httpd/modules/mod_ssl.so to your conf file.
Otherwise, you'll want to copy the mod_ssl.so file to whatever directory the other modules are being loaded from and reference it there.
Try installing mod_ssl using following command:
yum install mod_ssl
and then reload and restart your Apache server using following commands:
systemctl reload httpd.service
systemctl restart httpd.service
This should work for most of the cases.
I used:
sudo yum install mod24_ssl
and it worked in my Amazon Linux AMI.
I don't know if it is still of interest and if things have changed ever since the thread has been posted, but the /etc/apache2/apache2.conf on my system says:
Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
directories contain particular configuration snippets which manage modules,
global configuration fragments, or virtual host configurations,
respectively.
They are activated by symlinking available configuration files from their
respective *-available/ counterparts. These should be managed by using our
helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
their respective man pages for detailed information.
And on my system the modules are installed in /usr/lib/apache2/modules.
I am running Ubuntu 20.04.2 LTS.