I'm trying to get two Ruby apps to work from the same port. I don't know server technology at all, so forgive my ignorance. I've tried to follow this doc:
http://www.modrails.com/documentation/Users%20guide%20Apache.html
sections 4.1 - 4.3, but I keep messing something up. I've tried to simplify a little, so here is my situation. I have two simple rackup apps here:
/Users/dan/webapps/test1
/Users/dan/webapps/test2
They each have the "config.ru" file, the public/ folder, and the tmp/ folder with "restart.txt", as directed. They both work on their own.
I have the following in my httpd.conf file:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/dan/webapps
<Directory /Users/dan/webapps>
Allow from all
</Directory>
RackBaseURI /test1
<Directory /Users/dan/webapps/test1>
Options -MultiViews
</Directory>
RackBaseURI /test2
<Directory /Users/dan/webapps/test2>
Options -MultiViews
</Directory>
</VirtualHost>
I start apache, and then put this in my browser: http://localhost/test1. I get:
Forbidden
You don't have permission to access /test1 on this server.
I'm not surprised it doesn't work, because I am supposed to set up a symlink but I don't know how to apply that to my setup. Here is the example from the doc:
ln -s /webapps/rackapp/public /websites/phusion/rack
Can you tell me how to set up the symlinks, and let me know if you see anything else wrong? Please give the "for dummies" answer, this stuff boggles my mind. Thanks!
To create the symlinks, try this:
ln-s /Users/dan/webapps/test1 /Users/dan/webapps/test1/public
ln-s /Users/dan/webapps/test2 /Users/dan/webapps/test2/public
However, as chris polzer mentioned, you should also check that your apache user can read from those directories.
If you don't know how to do that, then post the output of these commands:
ls -l /Users/dan/webapps/test1
ls -l /Users/dan/webapps/test2.
ps -aux | grep http
ps -aux | grep apache
You may also need to check the permissions of all parent directories. I.e. /Users, /Users/dan, and /Users/dan/webapps. See: http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_to_a_virtual_host_8217_s_root_2
phylae, I think you may have the paths reversed in the symbolic link. To get it working, I changed the link names for clarity:
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/dan/webapps
<Directory /Users/dan/webapps>
Allow from all
</Directory>
RackBaseURI /test1link
<Directory /Users/dan/webapps/test1>
Options -MultiViews
</Directory>
RackBaseURI /test2link
<Directory /Users/dan/webapps/test2>
Options -MultiViews
</Directory>
</VirtualHost>
and then, the symbolic links:
ln -s /Users/dan/webapps/test1/public /Users/dan/webapps/test1link
ln -s /Users/dan/webapps/test2/public /Users/dan/webapps/test2link
Then these urls work as expected in a browser.
http://localhost/
http://localhost/test1link
http://localhost/test2link
Related
Running a project in dev server run perfectly but I try to move on a live server, I got "The requested URL /icons/create was not found on this server."
i got that just in 1 route in : .../icon/create
but any route works fine.
this is my htaccess :
I try to composer dump-autoload in local but don't get any error"
or something problem in my htaccess file?
mod_rewrite already enable in the apache web server.
Very thank you, if someone wants to help me :)
as u r saying u have "mod_rewrite already enable"
try this editing /etc/apache2/sites-enabled/000-default or /etc/apache2/apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Change the AllowOverride None to AllowOverride All
Comment Alias in /etc/apache2/mods-available/alias.conf.
<IfModule alias_module>
# Aliases: Add here as many aliases as you need (with no limit). The format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL. So "/icons" isn't aliased in this
# example, only "/icons/". If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings. If
# you do not use FancyIndexing, you may comment this out.
# Alias /icons/ "/usr/share/apache2/icons/"
# <Directory "/usr/share/apache2/icons">
# Options FollowSymlinks
# AllowOverride None
# Require all granted
# </Directory>
</IfModule>
After Comment these lines check apache conf using this command:
sudo apache2ctl -t
Then reload apache2:
sudo systemctl reload apache2
I have a simple bash script which should generate Apache site.conf file and then run a2ensite site.name
Everything works fine but a2ensite does not generate log files automatically. Then when I run sudo systemctl reload apache2 it throws me an error Cannot access directory '/var/log/apache2/www/site.name/' Bash file looks like:
#!/bin/bash
read -p 'Write url without www and http prefixes: ' url
template=$(</home/Camo/custom-scripts/apache/site-template.conf)
# Next line is string substitution
template=("${template//__URL__/$url}")
configFile=${url}'.conf'
configDirPath="/etc/apache2/sites-available/"
wwwDirPath="/var/www/html/$url"
mkdir $wwwDirPath
chown -R www-data:www-data $wwwDirPath
chmod 644 -R $wwwDirPath
echo "$template" > $configDirPath$configFile
sudo a2ensite ${configFile}
sudo systemctl reload apache2
and here is site.cong file created by previous script
<VirtualHost *:80>
ServerAdmin xxxxx.xxxxx#gmail.com
ServerName camo.publicvm.com
ErrorLog ${APACHE_LOG_DIR}/www/camo.publicvm.com/error.log
CustomLog ${APACHE_LOG_DIR}/www/camo.publicvm.com/access.log combined
DocumentRoot /var/www/html/camo.publicvm.com
<Directory /var/www/html/camo.publicvm.com/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
everything looks ok so why are log files missing? Thanks for any help.
Log files are not generated automatically, so you will have to create them manually:
touch ${APACHE_LOG_DIR}/www/camo.publicvm.com/error.log
touch ${APACHE_LOG_DIR}/www/camo.publicvm.com/access.log
And don't forget changing its ownership:
chown root.adm ${APACHE_LOG_DIR}/www/camo.publicvm.com/error.log
chown root.adm ${APACHE_LOG_DIR}/www/camo.publicvm.com/access.log
Then check if everything looks fine and if it does, reload apache2 service:
apachectl configtest
systemctl reload apache2
Recently, I downloaded and installed mooshak in Ubuntu 14.04. I followed all the steps given in the requirements and installation page.
When I try to access http://localhost/~mooshak, I'm being redirected to http://localhost/~mooshak/cgi-bin/execute and the following content is being displayed :
#!/bin/sh
# the next line restarts using tclsh \
PATH=$PATH:/usr/local/bin:/usr/contrib/bin ; exec tclsh "$0" "$#"
#-*-Mode: TCL; iso-accents-mode: t;-*-
cd ../..
lappend auto_path packages
source .config
execute::command_line
Can anyone point me in the right direction? This is the content of my /etc/apache2/mods-enabled/userdir.conf file :
<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Require all granted
</Limit>
<LimitExcept GET POST OPTIONS>
Require all denied
</LimitExcept>
</Directory>
<Directory /home/*/public_html/cgi-bin>
Options +ExecCGI -Includes -Indexes
SetHandler cgi-script
Order allow,deny
Allow from all
</Directory>
</IfModule>
Thanks in advance!
Make sure you have the modules userdir and suexec are enabled in Apache2. If needed execute the following commands
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/userdir.conf
sudo ln -s ../mods-available/userdir.load
sudo ln -s ../mods-available/suexec.load
You will need to restart Apache to activate the configuration.
sudo apache2ctl graceful
i'm trying to execute .cgi file on my server but return the following error
403 Forbidden
You don't have permission to access /run/test.cgi on this server.
Apache/2.0.64 (Win32) Server at localhost Port 80
server conf:
windows 7
apache 2
activeperl
i tried various solutions but none working
Set the permissions on /run/test.cgi to readable and executable > not working
tried to change Options indexes > not working
<Directory "E:/Apache/Apache2/htdocs">
# Options Indexes FollowSymLinks Includes ExecCGI
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AllowOverride None
Order allow,deny
Allow from all
</Directory>
my directory is under "E:/Apache/Apache2/htdocs/run/test.cgi"
the script:
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "testing...\n";
use CGI;
use CGI::Carp 'fatalsToBrowser';
#print qq`Perl_version: $]\n`;
#print qq`CGI::VERSION: $CGI::VERSION\n`;
foreach my $var (sort keys %ENV)
{
# print "$var: $ENV{$var}\n";
}
#print "\nExecuting 'which convert':\n";
#print "\n";
#print "\nExecuting 'find / -name convert':\n";
#print `find / -name convert`;
can anyone help?
thanks
I have just created my first Rightscale ServerTemplate and Deployment using a bunch of Rightscripts. One of the scripts I created was to add a virtual host to apache.
#!/bin/bash -e
if [ $RS_DISTRO = ubuntu ]; then
export apache=apache2
export apache_extra_conf_dir=/etc/apache2/conf.d
elif [ $RS_DISTRO = centos ]; then
export apache=httpd
export apache_extra_conf_dir=/etc/httpd/conf.d
fi
server_name=$SERVER_NAME
echo "Adding virtual hosts to ${apache_extra_conf_dir}/vh-${server_name}.conf"
cat > $apache_extra_conf_dir/vh-${server_name}.conf <<EOF
NameVirtualHost $SITE_IP:$SITE_PORT
<VirtualHost $SITE_IP:$SITE_PORT>
ServerName $SERVER_NAME
ServerAlias $SITE_DOMAIN *.$SITE_DOMAIN
UseCanonicalName Off
ServerAdmin $ADMIN_EMAIL
DocumentRoot $APACHE_WWW_DIR
<Directory "$APACHE_WWW_DIR">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EOF
service $apache restart
exit 0
My question is can I use the same Rightscript twice on the ServerTemplate but set different inputs for each (IP, Port, www dir and Servername)? eg.
ServerTemplate:
Execute Rightscript vhost: *:80 /www-x/ x.com
Execute Rightscript vhost: *:80 /www-y/ y.com
OR do I have to create a special Rightscript just for this server deployment that has both virtual hosts defined in the same script?
Execute Rightscript vhost: *:80 /www-x/ x.com | *:80 /www-y/ y.com
You can use the same RightScript with different inputs only if you put that script in the "Operational Scripts" section of your ServerTemplate. Then if you leave the inputs blank, you can execute that operational script with different inputs many times.
If you want that behavior in the "Boot Scripts" section, you'll have to either create a single script which handles two sets of inputs (for two vhosts) or create a clone of the RightScript with a different name and different input names.
You might consider taking a look at the Chef based tools. You can create a Chef recipe which takes an array of vhost names as input, then executes the "apache_site" resource that sets up a vhost. You can see an example in the RightScale Chef code linked below.
https://github.com/rightscale/cookbooks_public/blob/master/cookbooks/web_apache/recipes/setup_frontend_http_vhost.rb