Lamp stack: A simple LAMP starter project

I recently started looking into what it takes to get PHP running on Glitch. None of the existing starter projects fulfilled all my expectations, so I decided to make one myself.

The projects is set up as a LAMP version of hello-sqlite. It also has a lot of comments in hopes that it can be used even if you are only a beginner at PHP.

Some noteable changes, compared to the lamp-poc project, are:

  • DocumentRoot (i.e. the folder where files are served from) is set to a specific folder instead of the app root. This makes it easier to control what files can be publicly accessed.
  • Apache logs are saved to the .data folder instead of the .apache2/log folder. This prevents them from being remixed and potentially leaking sensitive information.
  • Apache access logs have the correct IP instead of all logging as 127.0.0.1
  • Accessing a folder without trailing slash will no longer append port 3000.
  • The error httpd (pid X) already running should be fixed.
  • Several small security improvements.

Since lamp-poc was only a proof of concept there are of cause many more additions. These were just same of the most needed changes, in my opinion.

7 Likes

Curious, what did you do to fix this?

1 Like

The following piece of code, in the start script, does it:

if [ -f .apache2/apache2.pid ]; then
  kill $(< .apache2/apache2.pid) &> /dev/null
  rm -f .apache2/apache2.pid
fi

When Apache starts, the pid is stored in the file .apache2/apache2.pid. The script looks for the existence of that file, and if found, it kills the process and deletes the file.

2 Likes

Nice, thats pretty slick. Good idea for putting the site contents in a different folder too.

2 Likes