Unable to install self-signed SSL Cert. Apache Error - apache

I am trying to install a self signed cert I generated using these instructions here:
http://www.akadia.com/services/ssh_test_certificate.html
I have the cert ready and have reread the instructions several times. However, the one difference is that I'm putting mine in /etc/apache2/conf.d/security/
I get the following error from apache.
Syntax error on line 1 of /etc/apache2/conf.d/security/server.crt:
Invalid command '-----BEGIN', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
Any clues? I'm in Ubuntu 11.04 running the latest lamp installation from tasksel. (vhosts in sites-available and such). I also have also made sure that ssl is enabled using a2enmod ssl. It said that it was already enabled.
------------VHOST---------------
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.cmp.me
SSLEngine on
SSLCertificateFile /etc/apache2/conf.d/security/server.crt
SSLCertificateKeyFile /etc/apach2/conf.d/security/server.key
DocumentRoot /var/www/sites/www.cmp.me
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/sites/www.cmp.me>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
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 /var/www/errors/cmp-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
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>

Related

apache invalid command 'ScriptAlias'

I am trying to get apache2 running but no matter what I do, localhost comes up as 404 not found.
There has been so many errors that Debian doesn't even think Apache2 is installed, but it is functional, and running. But I cannot remove it with --purge or otherwise.
When I start apache I get
root#debian:/tmp# /etc/init.d/apache2 restart
Syntax error on line 16 of /etc/apache2/sites-enabled/000-default:
Invalid command 'ScriptAlias', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
failed!
Here is site file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I've tried various configurations. My goal is to utilize multiple IPs for different virtual hosts on port 80, but I haven't even gotten it to work after my last disaster and re installation.
ScriptAlias is provided by mod_alias. On debian based distributions, use a2enmod to make sure mod_alias is loaded:
sudo a2enmod alias

mod_rewrite wasn't working so while fixing it getting 403 forbidden

On ubuntu 13.10 I am using apache 2.4.x . I was having problem with mod_rewrite. I enabled that module and and restarted the server but .htaccess file wasn't still working so I after some search, I read an answer from stackoverflow pointing towards: http://smarttips.in/htaccess-redirect-not-working-apache/
I was missing point 2 in the above link. So I put that code in my 000-default.conf file.
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
As I am using apache2.4+ so as told here: http://httpd.apache.org/docs/current/upgrading.html
Order allow, deny
Allow from all
to
Require all granted
Here is code in my 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 /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
# 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>
But after entering that code from that link, now server is giving 403 forbidden, saying:
You don't have permission to access /mysite/ on this server.
Apache/2.4.6 (Ubuntu) Server at localhost Port 80
So not sure if that mod_rewrite problem is solved or not but also getting now permissions error.
Let me know if I need to put .htaccess code here too.
So any idea what am I doing wrong ?
I simply removed:
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
and put this instead:
DocumentRoot /var/www
<Directory /var/www>
AllowOverride All
</Directory>
And now that permission error is gone and mod_rewrite is working as expected.
Adding this to <Directory /var/www/html>
Options +SymLinksIfOwnerMatch
helped me.

Connecting Apache to Tomcat with AJP

I am trying to launch a localhost application on Ubuntu with Apache and proxy it to Tomcat so that I can use .jsp pages in my application. It seems that this is possible and I think that I am pretty close, but I can't seem to get it quite right. Any help is greatly appreciated! I've never used apache or tomcat before, so please don't hate me if any of this seems stupid.
I've got Apache hosting a site at localhost with this code for the host:
<VirtualHost *:80>
ServerName localhost
ServerAlias test.com
DocumentRoot /var/www/test.com/helloworld
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/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>
This allows me to successfully navigate to my page hello.html by typing localhost/hello.html in the URL. I have read that from this point, I need to insert some code such as:
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /(appname) ajp://localhost:8009/(appname)
ProxyPassReverse /(appname) ajp://localhost:8009/(appname)
and then Tomcat should get the requests. In this case, what would the appname be? My page is located at /var/www/test.com/helloworld/hello.html, so I thought it would be "helloworld", but that does not work. When I leave the appname blank, I see the Tomcat "Congratulations, you've successfully installed Tomcat." when I navigate to localhost, but cannot find my page.
Please help. This is slowly becoming a nightmare. Thanks!
I figured it out. This is super dumb, but I was trying to load the application from /var/www rather than housing it within the tomcat directories. /facepalm
The proxy code I posted in the original question is the only code needed in the virtualhost. Thanks everyone.

More than one virtual host in Apache2 Ubuntu

I have tried to configure a new virtual host in apache. I have copied the default. Updated the paths. The conf looks like this
<VirtualHost *:8081>
ServerAdmin webmaster#localhost
DocumentRoot /home/ubuntu/video
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /home/ubuntu/video>
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/ubuntu/video/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/ubuntu/video/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 ran the command
sudo a2ensite video
which gave messaage that virtual host successfully added and will run upon reload. But i am not able to access the same. I have checked the path /home/ubuntu/video where error.log, access.log files are also created. I am not able to find the solution as well as problem. I searched in the internet if anyone have same problem.
The following blog post: Adding virtual hosts to Ubuntu Apache, says in its update the we cannot create more than one virtual host. I have already a virtual host installed. Does this mean 2nd virtual host cannot be configured in Ubuntu for apache?
Read these instructions.
If you try using <VirtualHost name:port> without the NameVirtualHost name:port or you try to use the Listen directive, your configuration will not work.
So make sure you have these directives outside the <VirtualHost> tag:
Listen 8081
NameVirtualHost *:8081
You can also add:
ServerName www.example.com
to your VirtualHost section.

virtually hosted typo3 site returns a 503 after backend logout

I am trying to host multiple typo3 managed sites on my remote webserver but whenever I logout from a brand new install I get a 503 error and can't get past that. but I can re-install a typo3 site from the same link. but the default typo3 installed which can be referenced via <www.mydomain_name.com/typotest> works fine. below is my default site setup:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /srv/www/
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /srv/www/>
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/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>
############### All other demo sites ################
<VirtualHost *:80>
DocumentRoot /srv/www/site1/
ServerName www.site1.typotest.net
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /srv/www/WFS>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#ErrorLog ${APACHE_VHOST_LOG_DIR}/site1/error.log
#Loglevel warn
#CustomLog ${APACHE_VHOST_LOG_DIR}/site1/access.log combined
</VirtualHost>
######## Site2 ########
<VirtualHost *:80>
DocumentRoot /srv/www/site2/
ServerName www.site2.typotest.net
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /srv/www/Monassier>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#ErrorLog ${APACHE_VHOST_LOG_DIR}/site2/error.log
#Loglevel warn
#CustomLog ${APACHE_VHOST_LOG_DIR}/site2/access.log combined
</VirtualHost>
######## site 3 ########
<VirtualHost *:80>
DocumentRoot /srv/www/site3/
ServerName www.site3.typotest.net
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /srv/www/HandP>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#ErrorLog ${APACHE_VHOST_LOG_DIR}/site3/error.log
#Loglevel warn
#CustomLog ${APACHE_VHOST_LOG_DIR}/site3/access.log combined
</VirtualHost>
I will also say that I tried copying the .htaccess from the working site to the virtually hosted site but got no results. At this point I am at a loss as to what could be causing this.
Server OS is Debian Lenny and apache 2.2.16.
I would like to add that I have checked the error logs (php ones included) and all I see are access errors
As you are not getting a Apache error log entry, I presume you have got the maintanence mode enabled.
Check your localconf.php for the entry:
$GLOBALS['TYPO3_CONF_VARS'][BE][adminOnly] = 1;
and change it to
$GLOBALS['TYPO3_CONF_VARS'][BE][adminOnly] = 0;
Slight misunderstanding of the framework caused this. It turns out that I had installed a blank package instead of the introduction package. So I was getting the 503 due to there not being any frontend pages created in the blank, and I was trying to access the backend via the front end address.