Pretty much a complete Linux/Apache newbie here, I am in the process of moving a site from a shared host to a Linode VPS. It's all been going smoothly until I starting trying to move my Moveable Type blog which runs using a series of CGI scripts. I am running Ubuntu 10.04 and Apache2. After hours of messing about I got a PERL hello world script (hello.cgi) to execute from a the web browser in the root HTML directory. Here's the script:
#!/usr/bin/perl -w
use strict;
print "Content-Type: text/html\n\nHello world!";
I got this working by adding the following to the /etc/apache2/sites-available/mysitename.com file.
<Directory /srv/www/mysitename.com/public_html/>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
But I want to execute CGI scripts in the /srv/www/mysitename.com/public_html/mt/ directory, so I changed the directory in the entry above to that path and when I view the hello world script in that folder via a browser I see the source for the hello.cgi script rather than the output. Clearly something isn't right. I've spent more than enough time trying to work this out myself and the time has come to ask for help. So, anyone got any suggestions? Please keep answers simple I really am just learning to tread water Linux/Apache2 wise here!
Solution Found:
<VirtualHost *:80>
ServerName www.sitename.com
ServerAdmin general#sitename.com
ServerAlias sitename.com
DocumentRoot /srv/www/mysitename.com/public_html/
ErrorLog /srv/www/mysitename.com/logs/error.log
CustomLog /srv/www/mysitename.com/logs/access.log combined
AddHandler cgi-script .cgi .pl
</VirtualHost>
<Directory /srv/www/mysitename.com/public_html/>
AllowOverride All
Order allow,deny
Allow from all
Options All +SymLinksIfOwnerMatch +FollowSymLinks +ExecCGI -Indexes -MultiViews
</Directory>
<Directory /srv/www/mysitename.com/public_html/mt/>
AllowOverride All
Order allow,deny
Allow from all
Options All +SymLinksIfOwnerMatch +FollowSymLinks +ExecCGI -Indexes -MultiViews
</Directory>
Have you added mod-perl?
Add these lines
AddType perl-script .pl
AddHandler perl-script .htm
specify a DirectoryIndex
(outside the Directory block)
Are you using vhosts too? I wouldn't normally do things the way you're doing them to be honest.
Related
I need to access video files on an external drive attached to my mac where I have a Laravel project hosted with laradock. I followed the instruction given in this tutorial.
So I put added the alias/directory lines in laradock/apache2/sites/default.apache.conf. Is that the correct file and location?
<VirtualHost *:80>
ServerName laradock.test
DocumentRoot /var/www/
Options Indexes FollowSymLinks
<Directory "/var/www/">
AllowOverride All
<IfVersion < 2.4>
Allow from all
</IfVersion>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
Alias "/video" "/Volumes/DiskX/video"
<Directory "/Volumes/DiskX/video">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Then following the instruction I change ownership of the folder content in Terminal.
sudo chown -R www-data:www-data /Volumes/DiskX/video
sudo chmod -R g+rw /Volumes/DiskX/video
But got an error chown: www-data: illegal group name. So what is the correct group name on my environment? And is that change of ownership necessary if I only need read access to the video files?
When I place a image.png file inside the DiskX/video folder and try to access that image in a blade.php page in the project, the image is not displayed (404 error).
I also want to add that I need full access to read any file in any of all the nested folders inside video folder.
I would appreciate some help.
I have my first server and i don't undeststand many things.
First, i've created one user called guillaume and create a specific folder in /home/web and put my website in there and it works BUT...
i've created a second website and it's work but only with chmod 777
i've made chmod -R guillaume:guillaume *
and chmod -R 777 *
but if i do
chmod -R 755 *
i've an error 500, file cannot be writed...
So i don't understand why i don't change permissons to 755, on my first domain it works well.
there is my vhosts:
<VirtualHost *:80>
ServerName bio.dev2prod.fr
ServerAdmin guillaume.batier#gmail.com
DocumentRoot /home/guillaume/web/bio.dev2prod.fr/public
<Directory />
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
<Directory /home/guillaume/web/bio.dev2prod.fr>
Options FollowSymLinks
Require all granted
Order allow,deny
allow from all
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
what am i doing wrong ?
PS: i put my user to www-data group ? it that good ?
Thanks and sorry for my bad english, i'm french..
PS: i'm using laravel 5 so the document root is in /public folder
The problem could be caused by several issues. So let me ask a few questions.
(if I'm not totally wrong) the first <Directory> directive points to the root directory. wich might not directly relate to your problem but are you sure to map any file? I guess it should be same as <DocumentRoot>
The <DocumentRoot> should be the base directory for the particular vhost. So the <Directory> path should normaly belong to a sub directory of the DocumentRoot.
If you wan't to use directories from outside the DocumentRoot mod_alias might be worth looking at.
Alias /somalias/ /path/to/somewhere/else
Hope this helps you a bit.
How to make prestashop to use prestashop.conf file which is a clone of 000.default.conf on my local server?
When I disable 000-default.conf, prestashop don't load.
When I enable that back, the web-page loads normally.
I've enabled prestashop.conf and reloaded/restarted Apache.
I use Apache2, prestashop 1.6.1, OS is Linux Mint.
Maybe someone can give me advice what else should I change. I haven't found solution so far.
P.S. prestashop.conf is complete clone of 000-default.conf.
Have you changed the paths to match these of your website?
<VirtualHost *:80>
ServerAdmin youradminlogin#yourwebsite.com
DocumentRoot "path/of/your/website"
ServerName website-name.com
Options All Indexes FollowSymLinks
<Directory "path/of/your/website">
DirectoryIndex index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require local
</Directory>
</VirtualHost>
Make shure it is in /etc/apache2/sites-enabled/ !
After modifying this, you'll need to restart the server (sudo apachectl restart)
I'm having no luck finding this question answered so I'm asking this myself.
To get my VHost working, I followed this answer. My (working) "httpd-vhosts.conf" file looks like this
<VirtualHost *:80>
ServerAdmin jesuscc1993#gmail.com
DocumentRoot "Z:/Projects/Web/MetalTxus Site"
ServerName metaltxus.test
ServerAlias www.metaltxus.test
<Directory "Z:/Projects/Web/MetalTxus Site">
#Options FollowSymLinks
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
As far as I know, I should change "Indexes" with "-Indexes" to make the web load "index.html" instead of the web directory.
However, when I did that, my WAMPServer wouldn't start. It would if I removed "FollowSymLinks" option but then all I got was a "403 - Forbidden" page ("you don't have permission to access "/" on this server").
As looking for a solution got me nowhere, I used this as my last resource.
I'm using latest WampServer version in Windows 8.1. I want to test an AngularJS application.
If you need any more information, go ahead and ask.
Try this :-
<VirtualHost *:80>
ServerAdmin jesuscc1993#gmail.com
DocumentRoot "Z:/Projects/Web/MetalTxus Site"
ServerName metaltxus.test
ServerAlias www.metaltxus.test
<Directory "Z:/Projects/Web/MetalTxus Site">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
The Require all granted is Apache 2.4 syntax where you were using Apache 2.2 syntax when using
Order deny,allow
Allow from all
Now all you need to do is place a file called index.html or index.php in the "Z:/Projects/Web/MetalTxus Site" folder.
I would suggest removing the space in the folder name MetalTxus Site its not absolutely necessary but it removes another possible complexity.
Also if you dont actually mean to give access to the site to The Universe try using
Require local
And if you want to be able to access the site just from other PC's on your internal network use
Require local
Require ip 192.168.1
ADDITIONAL SUGGESTION:
Also check httpd.con has thi sline uncommented
LoadModule dir_module modules/mod_dir.so
An has this
<IfModule dir_module>
DirectoryIndex index.php index.php3 index.html index.htm
</IfModule>
I develop projects that I've located in /home/user/projects directory. This directory is chmod 777. The problem is that I'm always getting Error 403 Forbidden when I try to access this directory or any subdirectory. This is how my /etc/apache2/sites-available/000-default.conf looks like:
<VirtualHost *:80>
ServerName localhost
ServerAdmin user#user.com
DocumentRoot /home/user/projects
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Options +FollowSymLinks
<Directory />
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /home/gtakacs/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
What's wrong with this? When I used /var/www as my document root, everything worked.
EDIT : try doing chmod -R 777 /home to make sure all your home is available (note that this solution is NOT RECOMENDED, having your project in /var/www would definitely be a better solution in my opinion)
(Can't comment so post reply)
Isn't there a config file in your project where you're supposed to set who can access the app? Check if you didn't forget to add your ip adress and domain name in this file.
When using Apache2 with Django framework (python), I had the same error, and it was because I forgot to add the domain name to authorized hosts.
You can also check access.log and error.log to have more detailed informations on what caused the error.
Command out:
#Order allow,deny
I had this issue before, the problem might be that your document root does not contain the described directories.