FastCGI using apache - not a script or wrong permission? - apache

I compiled my fcgi for apache like this:
g++ fcgistart.c -lfcgi
I got a a.out and configure it for apache using
a2enmod fastcgi
Now i read the manual
Any program assigned to the handler fcgid-script is processed using the FastCGI protocol;
Does that mean the binary is a script? Wreid! Anyway I place the a.out to /var/www/html.
Because the handler (/etc/apache2/mods-enabled/fastcgi.conf) binds to .fcgi I copy a.out to a.fcgi. Now i browse to http://localhost/a.fcgi and a 403-forbidden occourse.
xx#xx:/var/www/html$ ls -la
drwxr-xr-x 2 root root 4096 Feb 6 13:44 .
drwxr-xr-x 3 root root 4096 Feb 6 12:56 ..
-rwxr-xr-x 1 root root 8696 Feb 6 13:44 a.fcgi
-rwxr-xr-x 1 root root 8696 Feb 6 13:16 a.out
-rw-r--r-- 1 root root 11321 Feb 6 12:57 index.html
What is wrong?

I got it:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
is wrong, I had to add the ExecCGI option:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options +ExecCGI
</Directory>
</VirtualHost>

Related

I can’t configure virtual hosts in Apache, although I do everything according to the instructions. What is the reason?

I can’t configure virtual hosts in Apache, although I do everything according to the instructions. What is the reason?
I'm trying to configure virtual hosts in Apache, and it fails. I carry out the instruction without problems, but this does not work for me.
Ubunttu 18.04. The root directory is /var/www/html
There is an index.html and it is accessible from the network.
Now, if you just type the address of the site in the browser, then it still displays, /var/www/html/index.php, and not the index.html from the virtual host. That is, it turns out that virtual hosts do not work at all.
I did the following:
sudo mkdir -p /var/www/xxxxxx.xx/html
sudo chown -R $USER:$USER /var/www/xxxxxx.xx/html
sudo chmod -R 755 /var/www/xxxxxx.xx
nano /var/www/xxxxxx.xx/html/index.html
Added page code here.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/xxxxxx.xx.conf
sudo nano /etc/apache2/sites-available/xxxxxx.xx.conf
I inserted into xxxxxx.xx.conf:
<VirtualHost *:80>
ServerAdmin host1#gmail.com
ServerName xxxxxx.xx
ServerAlias www.xxxxxx.xx
DocumentRoot /var/www/xxxxxx.xx/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DirectoryIndex index.php
</VirtualHost>
sudo a2ensite xxxxxx.xx.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2
The directory permissions:
user1#host1:/var/www$ ls -l
total 12
drwxr-xr-x 3 root root 4096 Nov 14 11:05 xxxxxx.xx
drwxr-xr-x 13 www-data www-data 4096 Nov 13 16:14 html
drwxr-xr-x 4 user1 user1 4096 Nov 12 11:03 html-bk
user1#host1:/var/www/xxxxxx.xx$ ls -l
total 4
drwxr-xr-x 2 user1 user1 4096 Nov 14 11:08 html
user1#host1:/var/www/xxxxxx.xx/html$ ls -l
total 4
-rw-rw-r-- 1 user1 user1 177 Nov 14 11:08 index.html
What's wrong? I’m setting up Apache for the first time, yet according to the instructions, there were no errors during execution.
Just make the following change, add index.html instead of index.php
<VirtualHost *:80>
ServerAdmin host1#gmail.com
ServerName xxxxxx.xx
ServerAlias www.xxxxxx.xx
DocumentRoot /var/www/xxxxxx.xx/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DirectoryIndex index.html
</VirtualHost>

incorrect redmine installation

I am trying to install redmine 3.2.0 like in the following article.
The point 2.4 Test Redmine works fine, i.e. I am able to open redmine using http://MY_IP:3000.
After this, I did:
sudo chown -R www-data files log tmp public/plugin_assets
sudo chmod -R 755 files log tmp public/plugin_assets
sudo ln -s /opt/redmine/redmine-3.2.2/public/ /var/www/html/redmine
Added Listen 89 into /etc/apache2/ports.conf.
Created the following sudo vim /etc/apache2/sites-available/redmine.conf:
<VirtualHost MY_IP:89>
ServerAdmin email#example
DocumentRoot /var/www/html/
<Location /redmine>
RailsEnv production
RackBaseURI /redmine
Options -MultiViews
</Location>
</VirtualHost>
Enabled redmine.conf: sudo a2ensite redmine.conf.
Added PassengerUser www-data into /etc/apache2/mods-available/passenger.conf. Now passenger.conf contains the following:
<IfModule mod_passenger.c>
PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
PassengerDefaultRuby /usr/bin/ruby
PassengerUser www-data
</IfModule>
And restarted apache: sudo service apache2 restart.
So /var/www/html/ contains:
drwxr-xr-x 2 root root 4096 Jan 25 09:32 .
drwxr-x--x 7 root root 4096 Jan 22 07:21 ..
-rw-r--r-- 1 root root 11104 Jan 22 02:57 index.html
lrwxrwxrwx 1 root root 34 Jan 25 09:32 redmine -> /opt/redmine/redmine-3.2.0/public/
Now if I am going to http://MY_IP:89 then /var/www/html/index.html is opened instead of redmine home page.
Could you please advise where I did an error?
Thanks in advance!
UPDATE:
If I use the following redmine.conf:
<VirtualHost MY_IP:89>
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
AllowOverride None
RailsEnv production
Options -MultiViews
</Directory>
</VirtualHost>
Redmine won't start, only shows index of (/var/www/html/redmine/).
I SOLVED THE ISSUE:
I did gem install passenger. And I use the following redmine.conf:
<VirtualHost MY_IP:89>
DocumentRoot /var/www/html/redmine
<Directory /var/www/html/redmine>
RailsBaseURI /
PassengerResolveSymlinksInDocumentRoot on
AllowOverride None
RailsEnv production
Options -MultiViews
</Directory>
</VirtualHost>
From passenger 5.2.0 which was released in January 2018 "PassengerResolveSymlinksInDocumentRoot on" is no longer supported
in your /etc/apache2/sites-available/xxx.conf
make the following changes:
# Not supported from passenger 5.2.0 on wards
# PassengerResolveSymlinksInDocumentRoot on
PassengerAppRoot /opt/redmine/redmine-3.2.0/public/
My redmine works on apache with this config.
LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.21/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p551/gems/passenger-5.0.21
PassengerDefaultRuby /usr/local/rvm/gems/ruby-1.9.3-p551/wrappers/ruby
</IfModule>
<VirtualHost redmine.domain:80>
ServerName redmine.domain
ServerAlias redmine
DocumentRoot /opt/redmine/redmine-3.2.0/public/
<Directory /opt/redmine/redmine-3.2.0/public/>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
allow from all
</Directory>

How to configure mod_wsgi so that RockMongo is accessible in a subdirectory (404 error)?

Desired Behaviour
I want to be able to access RockMongo at localhost/rockmongo.
Current Behaviour
I am getting:
Error: 404 Not Found
Sorry, the requested URL 'http://localhost/rockmongo' caused an error:
Not found: '/rockmongo'
Environment
Linux Mint 17 Cinnamon
Apache
Server version: Apache/2.4.7 (Ubuntu)
Server built: Jul 22 2014 14:36:38
mod_wsgi
virtualenv
/etc/apache2/sites-available/000-default.conf
WSGIPythonHome /var/www/html/ENV
WSGIPythonPath /var/www/html:/var/www/html/ENV/lib/python2.7/site-packages:/var/www/html/wsgi
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIScriptAlias / /var/www/html/wsgi/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Directory Permissions
/var/www
drwxr-xr-x 3 root root 4096 Nov 23 08:58 www
/var/www/html
drwxr-xr-x 10 me me 4096 Nov 26 23:46 html
/var/www/html/rockmongo
drwxr-xr-x 5 me me 4096 Jun 6 23:04 rockmongo
Apache Error Log
There are no errors relating to this.
I got it working, but I'd love confirmation that this is the right way to do it and doesn't create any security issues for RockMongo or interfere with other aspects of mod_wsgi functionality.
I added the Alias line and the Directory block below.
/etc/apache2/sites-available/000-default.conf
WSGIPythonHome /var/www/html/ENV
WSGIPythonPath /var/www/html:/var/www/html/ENV/lib/python2.7/site-packages:/var/www/html/wsgi
<VirtualHost *:80>
# for all content in static folder - css, js, img, fonts
Alias /static/ /var/www/html/wsgi/static/
# for rockmongo
Alias /rockmongo /var/www/html/rockmongo
<Directory /var/www/html/rockmongo>
Order deny,allow
Allow from all
</Directory>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
WSGIScriptAlias / /var/www/html/wsgi/application
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable multiple webroot for apache2 on Ubuntu

I'm using apache2 on my ubuntu 13.10 machine, I have added another config file named paul under /etc/apache2/sites-available directory to make my file under /home/paul/public_html/ accessible on internet:
root#localhost:/etc/apache2/sites-available# ls -ltr
-rw-r--r-- 1 root root 950 Feb 7 2012 default
-rw-r--r-- 1 root root 978 Jun 23 10:54 paul
After than changes, my files under /var/www is not accessible on URL anymore, unless I change DocumentRoot from /home/paul/public_html to /var/www , but that would disable accessibility for /home/paul/public_html/
/etc/apache2/sites-available/paul :
DocumentRoot /home/paul/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
Is there any way of configuration to enable /var/www and /home/paul/pubilc_html as webroot at the same time? Is it required any setting on /etc/apache2/apache2.conf ? Any ideas would be appreciated, thanks.
You can accomplish this easily with an alias directive. In /etc/apache2/sites-available/default just add an Alias for the URL.
<VirtualHost *:80>
ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/
Alias /paul /home/paul/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now the contents of /home/paul/public_html should be available at www.example.com/paul

Apache not serving pages in /home, but correctly serving pages in /var

Consider the following Apache configuration:
$ cat /etc/apache2/sites-available/yair.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot /home/yair/code/business/public_html
<Directory /home/yair/code/business/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory />
AllowOverride None
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>
The public_html directory is configured such:
$ cat /etc/hosts
127.0.0.1 localhost
$ pwd
/home
$ ls -la | grep yair
drwxrwxrw- 49 yair www-data 4096 Mar 26 10:33 yair
$ cd yair/
$ ls -la | grep code
drwxrwxrw- 4 yair www-data 4096 Mar 26 09:10 code
$ cd code
$ ls -la | grep business
drwxrwxrw- 8 yair www-data 4096 Mar 26 09:11 business
$ cd business/
$ ls -la | grep public
drwxrwxrw- 6 yair www-data 4096 Mar 26 10:33 public_html
$ cd public_html/
$ ls -la | grep index.html
-rwxrwxrw- 1 yair www-data 4566 Mar 26 09:11 index.html
When I change the DocumentRoot to /var/www/ and put the files there, Apache serves them as expected. However, with the above configuration Apache complains:
You don't have permission to access /index.html on this server.
What might be the configuration error? This is on Ubuntu 13.10.
Try using this instead:
<VirtualHost *:80>
DocumentRoot /home/yair/code/business/public_html
<Directory /home/yair/code/business/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory />
AllowOverride None
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>