Problems activating "mod_rewrite" (I can't edit 000-default file)

Hello everyone,

Maybe an expert could help me..

I'm trying to activate mod_rewrite module on a Ubuntu 11.04 server (natty) and I having problem to edit the file 000-default in 3rd step, the steps to activate the module are:
1-Install Apache web server in Ubuntu Linux
2-Enable mod_rewrite module in Apache web server with:

$ sudo a2enmod rewrite

3-Edit the site file 000-default located in: /etc/apache2/sites-enabled/ directory, changing all AllowOverride None to AllowOverride All:

/etc/apache2/sites-enabled/000-default

4-And finally, restart Apache with:

sudo /etc/init.d/apache2 restart

The file looks blue when I see it in terminal with "ls" and a print is as below:

$: /etc/apache2/sites-enabled$ ls -la
total 8
drwxr-xr-x 2 root root 4096 2011-10-14 09:50 .
drwxr-xr-x 7 root root 4096 2011-11-11 06:48 ..
lrwxrwxrwx 1 root root   26 2011-10-14 09:50 000-default -> ../sites-available/default

I have sudo access, using vim I can do the changes but when I try to save changes I receive:
E45: 'readonly' option is set (add ! to override)

Why this is happening?
How can I edit this file?

Many thanks in advance for any help.

Regards

It is a symbolic link so the permissions are determined by those of ../sites-available/default . You can either change these permissions or use :w! to write the file..

1 Like

Hello Scrutinizer, thanks for answer.

I've just see the ../sites-available/default I didn't know about that relation.

So, you meam if I edit ../sites-available/default will be enough and that edition will automatically change the 000-default file?

Thanks for help so far.

Regards

When you do vim 000-default , you are really editing ../sites-available/default through the symbolic link. If you change the permissions like this: chmod u+w 000-default - which means you are giving write access to the owner of ../sites-available/default - then you will no longer get that message..

Alternatively if you exit vim after your changes, using :w! you should be able to override the readonly permissions..

1 Like

Thank you, thank you Scrutinizer, it works!!!

Only 2 questions more:
the 000-default had before permissions 777 and wasn't working for me after I did chmod u+v how you suggested me. Why?

Do I need to change back the permissions of 000-default to something? if yes, to what level permission?

Many thanks really for your great help

Regards

It is u+w , not u+v (see man chmod) . The permissions weren't 777, because those belong to the symbolic link, not the actual file (../sites-available/default).. You can check the permissions of that file with

ls -l ../sites-available/default

alternatively if you use

ls -lL 000-default

ls will follow the symbolic link and display the permissions of the actual file. I would expect the permissions to be 444 ( -r--r--r-- )

You are correct, is chmod u+w, it was a typo :D.

The permissions are as follow:

/etc/apache2/sites-available$ ls -l
total 12
-rw-r--r-- 1 root root  946 2012-02-06 18:24 default
-rw-r--r-- 1 root root 7469 2011-02-22 11:34 default-ssl

and

etc/apache2/sites-enabled$ ls -l
total 0
lrwxrwxrwx 1 root root 26 2011-10-14 09:50 000-default -> ../sites-available/default

/etc/apache2/sites-enabled$ ls -lL 000-default
-rw-r--r-- 1 root root 946 2012-02-06 18:24 000-default

I still have to change the permissions to 444 in 000-default file?

Thanks again for your help