How to get Apache to follow symlink instead of downloading it? - apache

I am just using the standard apache config file which mentions that it follows symlinks, but when I hit the url http://localhost/test it downloads the symlink file instead of following it. What config do I need to change to get apache to follow the symlink instead of downloading it?
This is an ls on the directory:
$ ls -al
total 10
drwx------+ 1 SYSTEM SYSTEM 0 Oct 20 10:55 .
drwx------+ 1 SYSTEM SYSTEM 0 Aug 26 12:27 ..
-rw-r--r--+ 1 me None 47 Oct 20 10:14 index.html
lrwxrwxrwx 1 me None 29 Oct 19 17:10 test -> /home/me/projects/test
This is in my apache config file:
<Directory "D:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

I figured out the problem. The symlink I was using was made using cygwin and it crossed drives/volumes. I found out that's not allowed in windows so I had to move the files to the same drive as apache and the link is now working.

Related

Apache giving "No such file or directory" error when trying to run cgi

No such file or directory: AH01241: exec of '/usr/lib/cgi-bin/haml.cgi' failed
Is the main error I'm getting right now. Trying to run a custom CGI, the cgi currently works successfully on another server I have, but it seems I've overlooked some configuration option on this server.
I have the cgi-bin directory set to allow CGI execution:
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
I've set the perms of haml.cgi to 777, simply to eliminate any permission issue from being the problem:
root#jp:/usr/lib/cgi-bin# ls -lah
total 16K
drwxr-xr-x 2 root www-data 4.0K Aug 14 18:28 .
drwxr-xr-x 64 root root 4.0K Oct 28 2014 ..
-rwxrwxrwx 1 root www-data 505 Aug 14 18:20 haml.cgi
I have cgid enabled:
root#jp:/etc/apache2# ls mods-enabled/
access_compat.load alias.load authz_core.load autoindex.load deflate.load filter.load mpm_event.load setenvif.load
actions.conf auth_basic.load authz_host.load cgid.conf dir.conf mime.conf negotiation.conf status.conf
actions.load authn_core.load authz_user.load cgid.load dir.load mime.load negotiation.load status.load
alias.conf authn_file.load autoindex.conf deflate.conf env.load mpm_event.conf setenvif.conf
And my site itself is set up to exec cgi:
DocumentRoot /home/j/web/
DirectoryIndex index.haml index.html
<Directory "/home/j/web">
AllowOverride All
Allow from All
Options +ExecCGI
</Directory>
Am I missing anything here? Any idea why the CGI isn't running?
Ended up actually being my ruby installation that was giving me issues. Running the cgi directly showed me this:
root#jp:/usr/lib/cgi-bin# ./haml.cgi
bash: ./haml.cgi: /usr/bin/ruby: bad interpreter: No such file or directory

httpd does not open index.php in folder, mounted like tmpfs

I have a question:
I mount folder /var/www/html/testram
mount -t tmpfs -o size=5m,mode=0755 tmpfs /var/www/html/testram
And put file index.php with some text.
When I open site from web browser I don't see any text.
What I have:
drwxrwxrwx. 2 root root 60 May 25 17:42 testram
-rwxrwxrwx. 1 root root 132723 May 25 17:18 index.php
In logs i have errors:
PHP Warning:
Unknown: failed to open stream: Permission denied in Unknown on line 0
PHP Fatal error: Unknown: Failed opening required '/var/www/html/testram/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
I take an experiment and create just folder
drwxr-xr-x. 2 root root 22 May 25 17:25 testfolder
and create file
-rw-r--r--. 1 root root 132723 May 25 17:12 index.php
with the same text.
And when I open this index.php from web browser I see text.
Why I don't see any text from index.php mounted in tmpfs.
Thank you
chown apache.apache -R testram does any effect
You should have symlinks enabled in your httpd.conf or .htaccess:
Options +FollowSymlinks

can you help me out touchy wordpress debian install?

I have installed WordPress 3.6.1 on Debian 6.0.8 (alongside with other websites) by following this tutorial https://wiki.debian.org/WordPress.
I keep strugling with wordpress asking for ftp Connection Information for theme or plugin updates.
Could you please help me setting the rights correctly ?
Looking forward to read from you
What I can to do
install/delete plugin
install/delete themes
What I can't do
display theme nicely unless I manually create the symbolic link to the files.
Posts I have read :
Can I install/update WordPress plugins without providing FTP access?
How do I know which linux user Wordpress uses for plugin installation
WordPress can't install themes
A general linux file permissions question: Apache and WordPress
apache and sftp permissions for wordpress automatic update in ubuntu
What I have tried
Set FS_METHOD to direct
in /etc/wordpress/config-mydomain.fr.php
define('FS_METHOD', 'direct');
Re assigh permissions :
admin#server01:/usr/share/wordpress$ find -type d -exec sudo chmod 755 {} \;
admin#server01:/usr/share/wordpress$ find -type f -exec sudo chmod 644 {} \;
admin#server01:/usr/share/wordpress$ ls -l
total 144
-rw-r--r-- 1 root root 395 8 janv. 2012 index.php
-rw-r--r-- 1 root root 7155 14 sept. 2013 readme.html
-rw-r--r-- 1 root root 4616 21 janv. 2013 wp-activate.php
drwxr-xr-x 9 root root 4096 19 mars 13:00 wp-admin
-rw-r--r-- 1 root root 271 8 janv. 2012 wp-blog-header.php
-rw-r--r-- 1 root root 3513 16 juil. 2013 wp-comments-post.php
-rw-r--r-- 1 root root 2381 13 sept. 2013 wp-config.php
-rw-r--r-- 1 root root 3177 1 nov. 2010 wp-config-sample.php
drwxr-xr-x 5 root www-data 4096 19 mars 13:00 wp-content
-rw-r--r-- 1 root root 2718 23 sept. 2012 wp-cron.php
drwxr-xr-x 10 root root 4096 19 mars 13:00 wp-includes
-rw-r--r-- 1 root root 1997 23 oct. 2010 wp-links-opml.php
-rw-r--r-- 1 root root 2408 26 oct. 2012 wp-load.php
-rw-r--r-- 1 root root 29751 23 juil. 2013 wp-login.php
-rw-r--r-- 1 root root 7715 3 mars 2013 wp-mail.php
-rw-r--r-- 1 root root 9990 21 févr. 2013 wp-settings.php
-rw-r--r-- 1 root root 22135 15 mai 2013 wp-signup.php
-rw-r--r-- 1 root root 3692 9 mai 2013 wp-trackback.php
-rw-r--r-- 1 root root 2722 4 mars 2013 xmlrpc.php
&
admin#server01:/var/lib/wordpress$ find -type d -exec sudo chmod 755 {} \;
admin#server01:/var/lib/wordpress$ find -type f -exec sudo chmod 644 {} \;
admin#server01:/var/lib/wordpress$ ls -l
total 4
drwxr-xr-x 8 www-data www-data 4096 20 mars 15:04 wp-content
Manually remove broken plugin
admin#server01:/var/lib/wordpress/wp-content/plugins$ sudo rm akismet
admin#server01:/usr/share/wordpress/wp-content/plugins$ sudo rmdir akismet/
Manually remove broken themes
admin#server01:/usr/share/wordpress/wp-content/themes$ sudo rmdir twentythirteen/
admin#server01:/usr/share/wordpress/wp-content/themes$ sudo rmdir twentytwelve/
&
admin#server01:/var/lib/wordpress/wp-content/themes/clear$ sudo rm *
admin#server01:/var/lib/wordpress/wp-content/themes$ sudo rmdir clear/
Manually define themes symbolic links that dont want to appear automatically
admin#server01:/usr/share/wordpress/wp-content/themes$ sudo ln -s '/var/lib/wordpress/wp-content/themes/clear' 'clear'
Restart ssh :
admin#server01:~$ sudo /etc/init.d/ssh restart
Restarting OpenBSD Secure Shell server: sshd.
Restart apache :
admin#server01:~$ sudo service apache2 reload
Reloading web server config: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 92.243.##.### for ServerName
/etc/apache2/sites-available/fr.mydomain.www
<VirtualHost *:80>
ServerName mydomain.fr
ServerAlias www.mydomain.fr
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.fr
RewriteRule $(.*)$ http://www.mydomain.fr$1 [R=permanent,L]
DocumentRoot /usr/share/wordpress/
DirectoryIndex index.php index.html
ErrorLog /var/log/apache2/wp-error.log
TransferLog /var/log/apache2/wp-access.log
<Directory /usr/share/wordpress>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /wp/wp-content /var/lib/wordpress/wp-content/
ScriptAlias /wp /usr/share/wordpress/
<Directory "/var/lib/wordpress/wp-content">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
/etc/wordpress/config-mydomain.fr.php
<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'myPassword');
define('DB_HOST', 'localhost');
define('WP_CONTENT_DIR', '/var/lib/wordpress/wp-content');
define('FS_METHOD', 'direct');
?>
Apache seems to run as root
ps aux | grep apache
root 11565 0.0 0.7 227076 15040 ? Ss Mar19 0:03 /usr/sbin/apache2 -k start
root 23668 0.0 0.3 227212 7500 ? S 10:07 0:00 /usr/sbin/apache2 -k start
...
root 26875 0.0 0.3 227212 7500 ? S 12:50 0:00 /usr/sbin/apache2 -k start
admin 27111 0.0 0.0 9620 916 pts/1 S+ 13:18 0:00 grep apache
777*
I have tried to change /usr/share/wordpress/wp-content and /var/lib/wordpress/wp-content to 777 without success...and I know that is very very bad.
Maybe this is because of some weird behaviour of Wordpress: The check whether WP has write permissions creates a temporary file and compares the owner of that file (which will be the Apache process, www-data) to the result of getmyuid(). However, getmyuid() returns the owner of the running php file (wp-admin/update.php in this case) which is 0 (root) in the default install. Try to change the owner of this file to www-data, which made it work for me:
chown www-data:www-data /usr/share/wordpress/wp-admin/update.php

Why is /etc/apache2/sites-enabled/default returning blank?

I just installed a LAMP stack and when I ran sudo nano /etc/apache2/sites-enabled/default, it was empty, like whatever file it opened doesn't exist. Never had this problem on my last LAMP install. What's going on?
The files in Apache's sites-enabled directory are ordered, which means that the filenames start with a number. The default site is usually named 000-default or similar, not just default. Take a look in the directory to see what's there with ls, then edit that file with nano.
> ls -l /etc/apache2/sites-enabled
lrwxrwxrwx 1 root root 26 Nov 14 2013 000-default -> ../sites-available/default
> sudo nano /etc/apache2/sites-enabled/000-default
Hello thank you i get also this issue, as mentionned by Brian Kintz, I did
ls -l /etc/apache2/sites-enabled
and get line like :
lrwxrwxrwx 1 root root 26 Nov 14 2013 000-default -> ../sites-available/default
I try to edit it :
sudo nano /etc/apache2/sites-enabled/000-default
I have only virtualhost block inside this file.
Thank you

"Symbolic link not allowed or link target not accessible" on fresh installed XAMPP for Linux

I did a fresh-install of XAMPP for Linux (version 1.7.4) on my Ubuntu 11.04 x64 laptop.
Then I made a link in my htdocs folder to my project folder:
$pwd
/opt/lampp/htdocs
$sudo ln -s /home/petra/projects/webapp webapp
$ls -al
drwxr-xr-x 4 nobody root 4096 2011-08-18 11:58 .
drwxr-xr-x 18 root root 4096 2011-01-25 15:33 ..
lrwxrwxrwx 1 root root 26 2011-08-18 11:42 webapp -> /home/petra/projects/webapp
When I opened the webapp in the browser using http://localhost/webapp, it only showed "403 Access Forbidden". The error log said:
$tail -f /opt/lampp/logs/error_log
[Thu Aug 18 11:43:15 2011] [error] [client 127.0.0.1] Symbolic link not allowed or link target not accessible: /opt/lampp/htdocs/webapp
Here is the httpd.conf. Strangely, the FollowSymLinks options are already defined (default).
There is a similar question on the XAMPP forum but I think nobody seems to pay attention to it anymore.
Does anyone have an idea how to fix this?
Try to run Apache using your user.
By default Apache runs as "www-data" so edit your apache2.conf, and search for "user" and set:
user=youruser
Restart Apache and voilà, it should work.
I found out that if I use link from directory outside /home/petra, the web-app is working normally. I guess it's because I use Encrypted Home Directory setting on my Ubuntu.
I just have to move the project directory outside my home directory to make it work.
I ran into this problem when I symlinked the document root to code sitting on my encrypted home directory. I also solved it by running apache as the user who owned the encrypted content.