Jay
Jay

Reputation: 841

localhost apache2 not working after change default path on ubuntu desktop 22.04

I have installed apache2, php, mariadb, phpmyadmin to Ubuntu 22.04.

All was working fine than I changed default www path to new folder path "/home/user/www".

For this I did following steps

  1. in /etc/apache2/sites-available/000-default.conf I changed DocumentRoot /home/user/www
  2. in apache2.conf I changed

< Directory /> Options Indexes FollowSymLinks AllowOverride All Require all denied < /Directory>

to

Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted

And added

<Directory /home/user/www>Options Indexes FollowSymLinks
AllowOverride All Require all denied < /Directory>

sudo adduser user www-data
sudo chown -R www-data:www-data /home/user/www/
sudo chmod -R g+rw /home/user/www/

sudo systemctl reload apache2

And I am getting error when I go to 'localhost'

enter image description here

"Forbidden You don't have permission to access this resource.Server unable to read htaccess file, denying access to be safe

Apache/2.4.52 (Ubuntu) Server at localhost Port 80"

Upvotes: 0

Views: 2361

Answers (1)

enok.seth
enok.seth

Reputation: 51

Yes it's due to new directive of apache2 with ubuntu 22.04.3-LTS

  1. You need to edit: /etc/apache2/apache2.conf
  2. Then, at the end of file add: ServerName 127.0.1.1
  3. Go to: /etc/apache2/sites-available/000-default.conf
  4. ChangeDocumentRoot /var/www/html to-> /home/user/www/
  5. After that: sudo apachectl configtest
  6. You should get a result of: Syntax OK
  7. Fianlly, restart apache: systemctl restart apache2

I made my symbolic link to /home/user/www

ln -s /home/YourName/www ( Important !) Without sudo!

Ubuntu 22.04

But it's different on ubuntu 22.04:

  1. You need to edit: /etc/apache2/apache2.conf
  2. Then, at the end of file add: ServerName localhost
  3. Go to: /etc/apache2/sites-available/000-default.conf
  4. change path DocumentRoot /var/www/html to -> /var/www
  5. After that: sudo apachectl configtest
  6. You should get a result of: Syntax OK
  7. Fianlly, restart apache: systemctl restart apache2

I made my symbolic link to /home/user/www

ln -s /home/YourName/www ( Important !) Without sudo

That's done, good Programming days!

Upvotes: 1

Related Questions