DEV Community

loading...

Wordpress Permalink( shows 404) not working in LAMP stack ubuntu 20.04

Sahil kashyap
I'm sahil kashyap
・1 min read

Assuming

  • php7.4 is running(php8.0 showed way to many error to run wordpress)
  • you've placed your wordpress project in /var/www/html/mywordpress and given it file permission 755(basically read & write in folder/files & subfolder/files)
  • setuped the db connection in wp-config.php properly
  • went to url: "localhost/mywordpress/wp-admin" and allowed the permalinks
  • an automatic .htaccess would have been created or wordpress UI will give you the .htaccess file content. copy it and paste it in "mywordpress" folder

before rewrite

sudo a2enmod rewrite

make sure its enabled

Here's the solution

  1. go to this file
    /etc/apache2/apache2.conf

  2. open it in sudo nano or simply drop the file in vscode
    Go to line "159"

and update this line

<Directory />
    Options FollowSymLinks
    AllowOverride none
    Require all denied
</Directory>
Enter fullscreen mode Exit fullscreen mode

to

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Require all denied
</Directory>
Enter fullscreen mode Exit fullscreen mode

and
on line 170

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride none
    Require all granted
</Directory>
Enter fullscreen mode Exit fullscreen mode

to

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
Enter fullscreen mode Exit fullscreen mode

now save the file
and in cmd run this

sudo service apache2 restart

this should fix it

Discussion (0)