Canvas LMS Installation
https://github.com/instructure/canvas-lms/wiki/Production-Start
Configure Passenger with Apache
First, make sure Passenger is enabled for your Apache configuration. In Debian/Ubuntu, the libapache2-mod-passenger package should have put symlinks inside of /etc/apache2/mods-enabled/ called passenger.conf and passenger.load. If it didn't or they are disabled somehow, you can enable passenger by running:
sysadmin#appserver:/var/canvas$ sudo a2enmod passenger
In other setups, you just need to make sure you add the following lines to your Apache configuration, changing paths to appropriate values if necessary:
LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so
PassengerRoot /usr
PassengerRuby /usr/bin/ruby
If you have trouble starting the application because of permissions problems, you might need to add this line to your passenger.conf, site configuration file, or httpd.conf (where canvasuser is the user that Canvas runs as, www-data on Debian/Ubuntu systems for example):
PassengerDefaultUser canvasuser
I don't find the httpd.conf file (Using ubuntu 16.04)
and don't understand where to put (Path of the file, Which file)
Can anyone please help me with this, What i have to do in this section?
You don't need add those lines to apache configs if you have installed libapache2-mod-passenger (Ubuntu, Debian) and executing 'sudo a2enmod passenger' was OK (no reply that module don't exist)
You need create VirtualHost with something like
<VirtualHost IP:80>
ServerName canvas.yourdomain.net
DocumentRoot /home/canvas/public
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteCond %{REQUEST_URI} !^/health_check
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
ErrorLog /var/log/virtualmin/canvas_error_log
CustomLog /var/log/virtualmin/canvas_access_log combined
SetEnv RAILS_ENV production
<Directory /home/canvas/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
Related
I read a post which says Do this in the Apache config:
<VirtualHost *:80>
ServerName www.domain2.com
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:3001/$1 [P,L]
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
</VirtualHost>
The problem is that i am new to these things(server configuration). Can you please tell me where to find apache config and how to input these lines into it.. i have linux vps cpanel + centos6 running an apache server . because when i go to apache configuration in whm cpanel, i see global configuration,
DirectoryIndex Priority, and so on. .
Best I recommend is to ssh your Centos Server go to this default path (/etc/apache2/httpd.conf) and here you can make all possible changes .
So just ssh to server change to sudo nano /etc/apache2/httpd.conf you may use vi or gedit whatever you preferred and do the needful changes to the configuration .
For Cpanel you can do it in two ways either via WHM or with CLI
I recommend here to do with CLI :
To modify the Apache configuration's include files via the command line interface (CLI), edit the appropriate configuration files in the /usr/local/apache/conf/includes/ directory.
Afterward run service httpd/apache2 restart
You can do it by editing .htaccess file as well but again it's not the best practices to be follow.
Please let me know if you need more clear picture on this.
In my apache configuration I have a virtual host configured like this:
Alias /mediamanager /storage/files/mediamanager
<Directory /storage/files/mediamanager>
DirectoryIndex /mediaManagerIndex.php
DAV On
# ... And some authentication directives ... #
</Directory>
The idea is that someone can access the files both by a WebDAV-Client and also a simple web browser in which case some pretty directory view is generated by a PHP script.
That worked great in Apache 2.2, but recently I upgraded to Apache 2.4 and now it is broken. I highly suspect I I suffer from this bug which is already 2 years old and no fix in sight. The proposed workaround to add:
<Limit PROPFIND>
DirectoryIndex never-encounterable-file-name.html
</Limit>
Does not work for me. Probably because I still want to have a directory index. If I remove my DirectoryIndex altogether WebDAV works again (no index.html or similar files exists in this directory) but of course I loose the ability to use my PHP file as directory index. I tried to specify my DirectoryIndex in a <Limit GET> but this had no effect.
Is there any way to get both DAV and DirectoryIndex to work simultaneously in Apache 2.4 on Debian (if anyhow possible without changing the source code and recompiling)?
In order to fix this, disable directory indexing for the WebDAV site.
In your sites-available/site.conf file add DirectoryIndex disabled to the <Directory> declaration, like so:
<Directory /path/to/my/webdav/dir>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
DirectoryIndex disabled
</Directory>
Then just reload Apache and you will no longer have that issue:
sudo service apache2 reload
For me, the following configuration solved both problems:
WebDAV works again
directory indexing, if the user uses a web browser to access the repository
It works by manually implementing the directory-indexing feature with simple rewrite rules, which are applied only for the GET request method.
The following code has to be placed inside the server config or virtual host context in the apache configuration file.
# Turn off (automatic) Directory-Indexing
DirectoryIndex disabled
RewriteEngine On
# Rewrite rules for the root directory
RewriteCond "%{REQUEST_METHOD}" "(GET)"
RewriteRule "^/$" "/index.php" [L]
# Rewrite rules for other sub-directories
RewriteCond "%{REQUEST_METHOD}" "(GET)"
# The following line checks, if the index.php file exists
RewriteCond "%{DOCUMENT_ROOT}/$1/index.php" "-f"
RewriteRule "^/(.*)/$" "/$1/index.php" [L]
Don't forget to reload Apache!
This is the solution I am currently using, located in a .htaccess file at the root of the directory tree used by the WebDav service. In this case I do not use PHP, only html files, but it can be easily adapted:
# Turn off automatic directory indexing
Options -Indexes
DirectoryIndex disabled
# Redirect directory requests to index.html, only for GET requests
RewriteEngine On
RewriteCond %{REQUEST_METHOD} "GET"
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ $1index.html [L]
In order to launch always the requested PHP file, just replace "index.html" on the last line by the PHP file name:
RewriteRule ^(.*)$ $1mediaManagerIndex.php [L]
I just created a website with two environments as virtualservers - testing and production. As production server is open to everyone but I allowed only my IP to access testing environment:
<VirtualHost *:80>
DocumentRoot /home/xxx/www
ServerName testing.xxx.com
<Directory /home/xxx/www>
Order deny, allow
Deny from all
Allow from xxx.xxx.xxx.xxx
</Directory>
</VirtualHost>
The problem is that google has already indexed some of my testing environment pages and they are available in google results. I would like any IP but mine to be redirected to production server (xxx.com) while accessing testing.xxx.com. I would rather do it with apache.conf than .htaccess(because of git repositories conflicts). Is it possible to add a conditional redirect to apache config?
You can use mod_rewrite features in your httpd.conf Apache config file:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^123\.456\.788 [OR] # exclude your first IP
RewriteCond %{REMOTE_HOST} !^123\.456\.789 # exclude your second IP
RewriteRule ^(.*)$ http://production-env.com/$1 [R=301,L] # redirection to production site
</IfModule>
Or you can put these declarations into <Directory> section of your vhosts config file.
Generally you can take advantage of mod_rewrite module to manage URL routing policies for your web server. Before using it make sure that this module is installed and activated in your Apache.
I have a default Zend Framework application installed under /var/www/html/zend_example. The public directory is: /var/www/html/zend_example/public.
I also have other non-zend sites in /var/www/html. For example, /var/www/html/other_site.
How can I configure the ZF site to work under http://MYDOMAIN/zend_example while simultaneously allowing http://MYDOMAIN/other_site to work?
Here is my apache config file:
<VirtualHost *:80>
DocumentRoot /var/www/html/zend_example/public
SetEnv APPLICATION_ENV "development"
<Directory /var/www/html/zend_example/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Here is the .htaccess file in /var/www/html/zend_example/public:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I just want to get a development ZF site up and running, while also having other sites available (under the same base URL).
Right now, all requests redirect (or rewrite?) to the base URL (http://MYDOMAIN).
Thanks!
Edit #1
I edited the vhost for both zend_example and other_site so that each DocumentRoot is set to /var/www/html, rather than the subdirectories for each site. This made it possible to access both sites in their respective URLs - other_site: http://MYDOMAIN/other_site and zend_example: http://MYDOMAIN/zend_example/public. Now, I believe there is a problem with the .htaccess file that is in the /var/www/html/zend_example/public directory. I cannot access default "Zend" URLs such as http://MYDOMAIN/zend_example/public/index/index which should point to the IndexController. Instead I receive a 404 error.
Edit #2
If I disable all vhosts except for the zend_example one, and the zend_example vhost has DocumentRoot /var/www/html set, then I am able to run the Zend site under http://MYDOMAIN/zend_example/public, including specific default Zend routes, such as http://MYDOMAIN/zend_example/public/index/index. This breaks when I enable another vhost, although I am still able to access the main index page for Zend at http://MYDOMAIN/zend_example/public.
Edit #3
I ended up toying with this for hours. It seems that there is some unique configuration that needs to be done since my server is centos 6.0. I ended up setting up a Debian 6.0 server and was able to get my virtual hosts setup correctly, including the Zend site! I'd still like to come back and solve the issue on centos, though.
you're missing the ServerName option in your vhost. Also you may encounter some difficulties if you don't allow followSymlinks in your directory declaration, try something like:
//the ServerName is the name that would follow http:// (http://zend.example/module/controller/action)
<VirtualHost *:80>
DocumentRoot /var/www/html/zend_example/public
ServerName zend.example
SetEnv APPLICATION_ENV "development"
<Directory /var/www/html/zend_example/public>
DirectoryIndex index.php
Options Indexes FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I'm not a *nix user so I'm not sure if you have change anything that resembles a windows hosts file or not, but it might pay to investigate. (it looks like you will have to edit the hosts file, it should be at /etc/hosts add a line like 127.0.0.1 zend.example where zend.example = ServerName from your vhost)
P.S. you'll probably have to make a vhost (as the first one in the list if all of your vhost are in one file) for localhost if you need localhost available. I know I have to do this on windows.
I have a system with windows server 2008, Apache httpd 2.2 and trac 0.11 i'm using mod_wsgi so the apache server do the web server job.
Integration with Trac after read this site i found that the most suitable solution was
the following (i have in my httpd.conf the line Include conf/extra/httpd-trac.conf)
httpd-trac.conf
LoadModule wsgi_module modules/mod_wsgi.so
WSGIDaemonProcess tracs processes=3 threads=25 maximum-requests=1000
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/trac/([^/]+)
RewriteCond c:\Project\Services\Trac\%1\conf\trac.ini !-f
RewriteRule . - [F]
RewriteCond %{REQUEST_URI} ^/trac/([^/]+)
RewriteRule . - [E=trac.env_path:c:\Project\Services\Trac\%1]
WSGIScriptAliasMatch ^/trac/([^/]+) c:\Project\Trac\trac.wsgi
<Directory c:\Project\Trac>
WSGIProcessGroup tracs
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
the problem i encouter is the following:
C:\Project\Apache\bin>httpd.exe -k start
Syntax error on line 3 of C:/Project/Apache/conf/extra/httpd-trac.conf:
Invalid command 'WSGIDaemonProcess', perhaps misspelled or defined by a
module not included in the server configuration
The objective:
My objective is to have multiple trac projects with diferente authentication information.
If you have other solution than this please tell me =)
Thank you for your help.
Windows doesn't support daemon mode of mod_wsgi. Just try removing WSGIDaemonProcess/WSGIProcessGroup directives. This will result in all Trac instances running in same process. Most of the time doing that should be fine.