Configure Apache Linux Mint 19.1 Server

Configure Apache web server for local web development on Linux Mint 19.1. Enable multiple websites on a local test server for developing PHP and MySQL based applications and websites.

The image below shows what is achieved in this tutorial. Two websites are configured in a user’s home folder that can be accessed in a web browser. The website accessed as http://test/ in the web browser is found in /home/web/test/public_html on the host computer. A second website called phptest is accessed by the name phptest in the web browser as can be seen in the image.

Configure Apache for Multiple Local Web Servers on Linux Mint 19.1
Configure Apache for Multiple Local Web Servers on Linux Mint 19.1

Configure Apache for Multiple Local Websites

In the previous post a local LAMP stack was set up on a Linux Mint 19.1 computer. In this tutorial, the Apache server from the local LAMP stack is set up to host one or more local websites. This is useful during web development in order to test local PHP websites before deploying them live on the internet. Local copies of PHP and MySQL based blogging and content management systems can be installed for test purposes using this configuration. Applications such as WordPress and Joomla fall into this category.

Configure Apache on Linux Mint 19.1 in 2019

This tutorial updates a previous tutorial that shows how to configure Apache for local web development on Linux Mint 18.x. Steps on configuring Apache for Linux Mint 19.x follow below which have changed slightly from Linux Mint 18.x.

Configuring Apache for Local Web Development Tutorial

Before continuing with the tutorial steps that follow, first install a local LAMP stack on Linux Mint 19 or Linux Mint 19.1.

Choose a Location for the Local Websites

By default, after installing Apache as part of the LAMP stack, a single website is set up as localhost which can also be accessed by the IP address from the web browser address bar. The files for this website are found in the Linux file system at /var/www/html. This means that root privileges must be granted to any applications that are used to modify the website files.

For the above reason, I like to put local development websites in my home folder. Furthermore it is better for backup purposes – backing up your home folder automatically backs up the local websites, rather than having to remember that they are in another part of the Linux file system.

For the purposes of this tutorial, a folder called web will be created in the home folder. This folder will contain sub-folders, each holding a separate development website.

The full path to the folder is:

/home/<user name>/web/

Where <user name> is your Linux login user name and personal home folder name.

Create a Folder for Each Website

Create a new folder for each local website that you want. Create these folders inside the main folder that you created in the previous step. Two folders are created as examples for this tutorial. The first folder is called test and the second phptest as shown below.

/home/<user name>/web/test/public_html/
/home/<user name>/web/phptest/public_html/

Note that each site folder has a public_html sub-folder where the PHP or HTML files will be placed that are directly accessible from a web browser. On some servers this folder may be called htdocs. This allows certain PHP files to be placed “behind” this public folder that may contain passwords or other information that is to be kept private.

More folders for additional websites can be added at any time. For example if you are a web developer and need to add a local copy of a new client’s website, just add a new folder and then continue with the steps below to configure Apache for the new website.

Write a PHP script called index.php for each of the websites that will uniquely identify them. For example, print the name of each website so that it can be viewed in a browser. Save the scripts to their respective website folders created above. These files are just for testing that the Apache configuration works after we have done with the configuration.

Example index.php script for the test website:

<!DOCTYPE html>
<html lang="en">
        <meta charset="utf-8">
        <title>Test Site</title>

        <h1><?php echo "Site Name: Test"; ?></h1>


Make a similar PHP file for the phptest website, but substitute Phptest in the above file in place of Test in two places – in the title tag and in the PHP code block.

Configure the Apache Web Server

An Apache configuration file for each local website must be created by copying an existing file in the Linux file system. To do this, the file manager is opened as root to edit the file system files, as is described in the steps that follow.

Open the File Manager as Root (Administrator)

Start the file manager or file browser, which by default can be found on the bottom task bar or panel in Linux Mint.

In the left panel of the file manager, click the File System item. In the main right pane, navigate to etc and then apache2. The results can be seen in the image below.

Configure Apache Local Websites
Configure Apache Local Websites

Right-click on the sites-available folder and then click Open as Administrator on the menu that pops up (click Open as Root in Linux Mint Cinnamon). You will be prompted for your Linux password in the Authenticate dialog box that pops up. Enter your password and click the Authenticate button in the dialog box.

A new file manager will now open that has administrator privileges, also known as root privileges or superuser. This allows you to edit any files in the Linux file system.

Caution: With the file manager opened as superuser it is possible to edit or delete any file in the file system. Use the file manager with great care when it has superuser privileges and close it immediately after editing the necessary file system files.

Create the Apache Configuration Files

You should now have the file manager open with superuser privileges and be in the sites-available folder as shown below.

Apache Sites Available Folder
Apache Sites Available Folder

Make a copy of 000-default.conf for each website that will be configured. Drag this file in file manager and hold down the Ctrl key before dropping it in the same folder to make copies of this file. Rename each new file to the name of the folders being used, i.e. test and phptest for this tutorial. The image below shows the two new files created by copying 000-default.conf in the file manager. The files are renamed next.

Copying the Apache Configuration File
Copying the Apache Configuration File

To rename a file in file manager, click the file to select it and then press F2 to edit it. Now type the new name and press the Enter key. The result of renaming the two files is shown below. You should now have two files called test.conf and phptest.conf which are copies of 000-default.conf.

Rename the Apache Configuration Files
Rename the Apache Configuration Files

Editing the Apache Configuration Files

Each of the configuration files must now be edited. Double-click test.conf to open it for editing (this must be done in the file manager opened as superuser or else it will not be able to be saved). Add the following lines to the file. First change the server name at the top of the file and uncomment it by removing the # symbol from the left of it. Modify the paths in the below text to suit your user name and website name. The sever name and paths are marked in bold in the next code listing.

ServerName test

ServerAdmin webmaster@localhost
DocumentRoot /home/user/web/test/public_html/
<Directory /home/user/web/test/public_html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted

The complete file looks as follows where user is the name of the logged in user and home folder:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    ServerName test

    ServerAdmin webmaster@localhost
    DocumentRoot /home/user/web/test/public_html/
    <Directory /home/user/web/test/public_html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

It is important to modify the lines above marked in bold. These lines will be different for each website and must contain the name of the web server and path to each website’s folder.

Save and close these files after editing.

Activate the New Local Websites

Right-click in the file manager that was opened as superuser and should have the /etc/apache2/sites-available/ folder open. In the menu that pops up click Open in Terminal to open this folder in a terminal window.

In the terminal window, type a2ensite followed by the site name(s), e.g.:

a2ensite test phptest

The terminal window is shown below after running the command.

Enable Apache Websites for Local Web Development using a2ensite
Enable Apache Websites for Local Web Development using a2ensite

The terminal window can now be closed.

Configure Host File

In the file manager that was opened as root, navigate two folders back. This is the /etc/ folder. Open the hosts file for editing (/etc/hosts) by double-clicking it.

Add the names of the new sites next to the IP address of in the hosts file, as shown below.    localhost    toshi    test    phptest

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Save and close the file.

Open a terminal window and enter the following to restart the Apache server so that the changes can take effect.

sudo service apache2 restart

Before continuing, close the file manager that you opened as root.

Allow Apache to Access the Web Folders

The new websites are now configured, but Apache does not have permission to access your local website folders. Trying to access the test website using http://test/ in a web browser will result in an access error. Apache must be given access to this folder.

In Linux Mint, click the Menu button on the bottom panel at the very left to bring up the main menu. Type “users” to bring up the Users and Groups menu item. Click the Users and Groups menu item to open the Users Settings dialog box, as can be seen in the image below.

Users Setting Dialog Box
Users Setting Dialog Box

In the Users Settings dialog box, click your user name in the left top box. In the above image, the user name is “user” and is selected in green highlight. Click the Manage Groups button to bring up the Groups settings dialog box. Scroll down to the very bottom of the groups list in the Groups settings dialog box and click www-data to select it. Now click the Properties button. In the dialog box that opens, check the tick box next to your user name, as shown for the user name “user” in the image below.

Group www-data Properties Dialog Box
Group www-data Properties Dialog Box

Click the OK button to close the dialog box. Enter your password when prompted and then click the Authenticate button. Close the Group settings dialog box and then the User Settings dialog box.

Log out and then log back in for the changes to take effect.

Open a normal file manager (not as root) and navigate to your main website folder (called web in this tutorial). Right click the web folder and then select Properties on the menu that pops up. In the properties dialog box, click the Permissions tab. Under Group, select www-data from the drop down list and make sure that Access Files is selected next to Folder access, as shown in the image below.

Give www-data Permission to Access the Folder
Give www-data Permission to Access the Folder

Click the Apply Permissions to Enclosed Files button near the bottom of the dialog box and then click the Close button.

Finally navigate one level back in the file manager and right-click the user’s folder and select Properties on the menu that pops up. Click the Permissions tab in the dialog box that opens. Next to Groups, select www-data. Make sure that Access files is selected next to Folder access. Click the Close button to close the dialog box.

Access the Local Websites

The local websites used as examples in this tutorial can now be accessed from a browser. Type http://test/ in the browser address bar to access the test website and http://phptest/ to access the phptest website. You can now use the new websites for local web development of PHP and WordPress sites or other sites or applications that use a LAMP stack.

Test Website after Apache Configuration
Test Website after Apache Configuration

Further Configuration

You may also want to configure PHP to display error and warning messages during software development on the local LAMP stack. Enabling error and warning messages to be displayed helps with debugging PHP code locally before moving it to a live production server.

24 thoughts on “Configure Apache Linux Mint 19.1 Server”

  1. Article is great. I followed all the detailed procedure but I have a query as to how my phptest when I access on localhost, what is showing is the php default page as stored on /var/www/html/ & not the one created on home/user/web/phptest; however the test is alright showing Site Name: Test.

    1. Hi Mat
      You possibly left phptest out of the hosts file. Go back and check that it is in there and also that you enabled phptest with a2ensite.

  2. I’ve got an Apache server running on localhost and another one on /home/myname/web/test/public_html. I can see both of them from the computer they’re running on, and I can see the localhost one from other computers on my LAN.

    I can’t figure out how to access …..web/test/public_html from a separate computer on my LAN. Probably a simple answer, but I’m really new to Linux and Apache.

    1. This setup isn’t meant to be accessed from an external computer, it is for local development. The site names are set up in the hosts file that gives each website a name on the local machine.

      What I do if I want to develop on another computer as well is I set up the sites in the same way on the other computer, then just sync the files between them.

  3. Installed as directed but when I call http://test/ I get a directory instead of the index.php executing. If I click on the file in the directory it works fine – . Am I missing something?

    1. Normally the default configurations files are set up to automatically run index.php
      Are you on Linux Mint 19.x?

  4. I like the way you have set this up and really appreciate your work on writing it up.
    Works fantastic apart from being able to update a CMS in place.
    I am new to mint and guessing I will have to punch some holes through the fire wall to get patches on the CMS? What have people done to get updates to their test sites automatically or is it pull down each update individually and manually install?

  5. I am confused by the directory permissions changes.
    Would it be possible for you to give the linux commands rather that the GUI examples.

  6. Great article, but I got stuck on the 2nd to the last step. I’m not seeing a ‘Manage Groups’ button on ‘Users and Groups’ screen so I can’t add my user name to the ‘www-data’ group.

    What am I doing wrong? I’m using Mint 19.3

    Thank you

  7. It’s amazing how Apache-Linux have changed over the years; and the last time I installed development servers on a local machine (7-8 years ago) is much different. Thank you for such a detailed “How To…”

    That said, I’ve run into one problem: A 403 Forbidden error when accessing my “site.” I did add, in my sitexxx.conf file a , within the deny,allow text -the allow from string. To no avail. Directory and File permissions are proper. LM 19.3. Apparently I’m missing something and your advice would be appreciated.

  8. …found my problem…. Using old Apache “allow, deny…” directives in sitexxx.conf files. Thanks again for this tutorial. Old habits die hard.

  9. Great article, thanks!

    I followed the instructions but it seems I cannot set the permissions properly, so http://tests/ gives me a “403 Forbidden” status answer.

    As someone else asked, is it possible to give the commands to type to set (and check) these permissions?

  10. It would seem my browser resolves test to which is a website… I’m sure this is a great set up but I think I need an alternative way to accomplish this task.

  11. I installed Apache and the other software on Mint 19.3 MATE using the great tutorial that links to this page. It worked perfectly. I got as far as configuring the host file in etc. I do not have a host file in etc. That seems to be the core problem.

    http://phptest gets me a blank page. http://test takes me to a website at

    BTW, thanks for all this work.

  12. great tutorial.. all works until “Allow Apache to Access the Web Folders” sections.. Im in linux mint 20 btw, users and group doesnt have manage and property button.. what to do?

    1. I think the difference is that the tutorial was made using Linux Mint Mate, but you are probably using Linux Mint Cinnamon. In the “Users and Groups” dialog box, click the text next to the “Groups” item at the bottom right of the box. This allows you to add users to various groups. You just need to click the correct check box in the dialog box that opens. There is no property button.

  13. For everyone who’s getting “403 Forbidden” error. In my case I had to whitelist directory in apache2.conf because I created them in my home directory and Apache denies access by default.

  14. It’s a great tutorial, thanks for making it.
    However, I have one web site I’m trying to set up – followed all the steps as far as I can tell, and everything seems OK, except when I go to test the new site and put in http://newsite, I get the default Apache 2 page. I can’t figure out why it’s not going to the new site. The conf files look fine, the paths look right, hosts look right, the directory and index.php is in place, no problem with the permission setting … any clue what could cause this?

  15. Well, like someone else mentioned, I see I can get to the files if I type in index.php with the url. Maybe that can be fixed in the php config file.

Leave a Reply

Your email address will not be published. Required fields are marked *