Skip to content

docker4lamp - A LAMP Docker development environment

I have made this project (Docker For LAMP) publically available on Github, under the MIT license.

The target user group is php developers who want or need a simple, minimal (yet very current) LAMP development environment. I want this to be friendly to new developers, and a useful alternative to localhost environments like xamp, mamp or wamp.

Ideally it offers the type of convenience and isolation of a vagrant lamp environment except with orchestrated containers. Continue reading "docker4lamp - A LAMP Docker development environment"

Symfony 5.2 and Apache 2.4

Certainly the most convenient way to develop a Symfony 5.x app is to use the symfony server. Eventually however, you may have to deploy the application. For a number of years nginx with php-fpm was the preference for many sysadmins seeking to wring the maximum performance out of a webserver that also has to run php scripts, but there are now simple ways of configuring apache to use php-fpm while achieving comparable performance to nginx.

For example a vhost setting like this one is possible:


<VirtualHost *:80>
    SetEnv ENVIRONMENT "dev"
    <FilesMatch \.php$>
        SetHandler proxy:fcgi://php:9000
        # for Unix sockets, Apache 2.4.10 or higher
    </FilesMatch>
    # Proxy .php requests to port 9000 of the php-fpm container
    DocumentRoot /usr/local/apache2/cms/public
    ServerName cms.mydev.local
    ServerAdmin admin@mydev.local

    <Directory /usr/local/apache2/cms/public>
        DirectoryIndex index.php index.html
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
   
    # Send apache logs to stdout and stderr
    CustomLog /proc/self/fd/1 common
    ErrorLog /proc/self/fd/2
</VirtualHost>
 


Continue reading "Symfony 5.2 and Apache 2.4"

Putting Apache on a diet - how to get a lean configuration, Part 1

In this article I'm going to go over some of the details of how Apache works, and uses memory. As you will see, the apache processes that serve requests will grow to include the amount of memory they need for a particular request, and they will still be using that memory, even when they are serving something simple like a .css file or an image.

For this reason, the first limitation you are likely to encounter running Apache is a limitation on memory. I will explore this topic and show you how you can do the same.

The first thing need to determine about Apache is what mode it is running in. If your plan is to use Apache with php via mod_apache, then the prevailing wisdom for many years has been that there may be library extensions in PHP that are not thread safe. For this reason, people have tended to avoid running Apache as a threaded server, for fear that scripts may randomly die producing the dreaded 500 Internal server error pages we all know and love.

This fear may be overstated depending on the nature of your php code, but the defaults for apache packages I've seen, seem almost always to be using the prefork worker.

Prefork vs Worker?

So the first question you might be asking yourself is, which mode is my current apache server running in? There is a simple safe way to determine this -- run the httpd(apache) program with a specific command line switch. There are programs like which and whereis that might help you locate it, if you don't know where it is.


whereis httpd
 


CODE:
httpd: /usr/sbin/httpd.worker /usr/sbin/httpd /usr/sbin/httpd.event /etc/httpd /usr/share/man/man8/httpd.8.gz

So let's run the /usr/sbin/httpd with the -h for help and see what happens:




Continue reading "Putting Apache on a diet - how to get a lean configuration, Part 1"

Centos Virtual LAMP server -- Part II

*Part 1 of this series is here*

Customizing your LAMP server


Unix people are probably familiar with the father of the DNS system -- the /etc/hosts file. The hosts file has a simple format:

ipaddress hostname

In the days prior to DNS, people would update a master hosts file and copy it around to all the servers in the enterprise. Surprisingly Windows versions also support this file, as a way of overriding DNS, so we can use this to our advantage, by adding an entry for our development server. In this example, I'm going to use dev.gizmola.com, which is not a real server.

One important reason to do this is that Apache and other web servers, use a feature of HTTP 1.1 that specifies a header field named "Host:". This mechanism facilitates the service of multiple domains from a single apache server, through the configuration of apache virtual host (or vhost) entires. The server uses the Host name in the HTTP header to determine how to route requests, so without host name resolution. you have to use non-standard ports and other mechanisms that are more trouble than they're worth. a

Continue reading "Centos Virtual LAMP server -- Part II"