Solving 403 Forbidden Error on Apache2 Virtual Host

You must have come across an error while cre­at­ing new vir­tu­al host in apache2 serv­er this error is 403 for­bid­den error (You don’t have per­mis­sion to access / on this serv­er.) . I will dis­cuss about this issue in detail here:


Apache2 runs his process as www-data user ‚Basi­cal­ly, it’s just a user with stripped per­mis­sions so if some­one man­aged to find a secu­ri­ty hole in one of your web appli­ca­tions they wouldn’t be able to do much. With­out a low­er-user like www-data set, apache2 would run as root, which would be a secu­ri­ty issue.So to allow apache to serve your files it is need­ed that those files should be under this www-data user.


1:(Rec­om­mend­ed Way)
chown your htdocs direc­to­ry to www-data , this will solve your every prob­lem includ­ing file read and write oper­a­tion you have to chown htdocs direc­to­ry to www-data.Follow this com­mand to chown to www-data-
For Ubun­tu-

In Case of cen­tOS -

2:Mod­i­fy your vhost file (usu­al­ly /etc/apache2/sites-available/yoursite.conf)

and add -

so your vhost file will look like -

Now restart your apache by-

sudo ser­vice apache2 restart


/etc/init.d/httpd restart


Web Developer & Server Admin, Skilled in Java , PHP , LAMP, Tomcat, Mongo DB & SQL. Available for freelancing project or Open Source Contribution, Feel free to contact me at .

You may also like...