JacobTheDev
JacobTheDev

Reputation: 18510

Can't get .htaccess working on Ubuntu Server

I can't figure out how to get the .htaccess file on my new Ubuntu server working. I've tried following these instructions, but /etc/apache2/sites-available/default is apparently missing. I tried using the ls command, and all that comes up is default-ssl.conf.

I'm running Ubuntu 13.10, and I think the latest version of Apache. Seems to me that the default.conf might have been deleted or something, but I'm not sure.

Also, the .htaccess has an owner of www-data. Maybe just changing the owner would allow me to edit the file?

EDIT: Please note, I'm 100% new to this, so please explain things to me like I'm a 3 year old.

Upvotes: 2

Views: 3860

Answers (1)

Jonathan Kittell
Jonathan Kittell

Reputation: 7493

I don't want to put this in a comment, but this might help.

I've never used Ubuntu but have worked with Apache on Red Hat Enterprise Linux. If you have root access to the machine then the preferable way to add authentication or whatever configurations you want to put in the .htaccess file is to put them in the "httpd.conf" file or main configuration file.

/etc/httpd/conf/httpd.conf The main configuration file.
/etc/httpd/conf.d/ An auxiliary directory for configuration files that are included in the main configuration file.

cd into the /etc/apache2/ dir and then "ls -ll" and see if you have "conf/" or "conf.d". Instead of adding configurations to the main config file you can have separate ones instead, just depends on how you want to do it. It's easier to start with the main config file.

For example, if you can get to main config file("httpd.conf") at the bottom of it there will be "Section 3" I believe. If you are using vim enter "/Section 3" and it will take you straight to it. You will see an example of a virtual hosts configuration and below that you can add the directories of your web server.

<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot /www/docs/penguin.example.com
 ServerName penguin.example.com
 ErrorLog logs/penguin.example.com-error_log
 CustomLog logs/penguin.example.com-access_log common
</VirtualHost>



<Directory /var/www>
  Options Indexes Includes FollowSymLinks MultiViews
  AllowOverride AuthConfig
  Order allow,deny
  Allow from all
</Directory>

If you are using .htaccess files they are hidden so to see them you use "ls -a" when in the directory containing the .htaccess files.

So, back to your question, use "ls -a" to find the .htaccess files. All files with .something are hidden files. You could temporarily change the permissions to 777 just to make things easier so you can edit them and then change them back when you are done. Just make sure you change the permissions back to what they were. To find the permissions use "ls -ll".

# chmod 777 .htaccess

Upvotes: 1

Related Questions