It seems like you are using an ad blocker. To enhance your experience and support our website, please consider:

  1. Signing in to disable ads on our site. Our users don't see ads
  2. Or, Sign up if you don't have an account yet
  3. Or, disable your adblocker by doing this:
    • Click on the adblocker icon in your browser's toolbar.
    • Select "Pause on this site" or a similar option for lancecourse.com.

Web development on GNU/Linux

By andy brookes

There is a general concept that the nearer your web development environment is to your live web hosting environment the less the unexpected snags you will have to fix. The current usage of the Unix and Linux operating system for web servers is estimated as of 2020 at 67%.

So there is a very good chance that your web application will end up on a Linux OS server; you can increase that figure if you take into account Cloud technology which is primarily Linux.

This article looks at some of the nuances of using Linux for web development. I am of course biased in that I am a long time user of GNU/Linux particularly Slackware; currently, I maintain Latex2html for the Slackware repository and contribute to the Docs.

I did use to use Windows for web stuff and it wasn't too bad in the old days when Windows Desktop as default was less cluttered. However generally I ended having to pay for third-party software such as CuteFTP. One day I built a new Desktop PC with a brand new blank hard drive. A blank hard drive with no OS! So it was decision time to pay for a Windows Install Disk, then have to pay for Office Suite or see what Linux can do.

I installed Linux and never looked back. As for CuteFTP I soon discovered there was a large repository where I could obtain the software free of Adverts, free of shareware and free of malware.

I mean it's hard enough coding and getting code bugs without throwing in, is that problem may be due to dodgy software I just installed?

When last in Ghana general comments to me were "why should I bother with that complicated Linux, when I can have Windows for free".

I don't buy that argument; if it was as simple as that why is not everybody in Ghana going from A to B on horses instead of cars. I mean a horse pretty much can do everything a car can, go uphill get you from A to B and only needs a bag of oats and a rub down!

It probably about decision and motivation. Let me just say I'm not here to judge and my air of superiority in using Slackware was recently given a knock and made me think from communication from Richard Stallman only last week.

Running an unauthorized copy of Windows still gives Microsoft power over you. So I say: an unauthorized copy of Windows is a very bad thing -- almost as bad as an authorized copy ;-{.

Slackware GNU/Linux has two flaws. It contains nonfree programs. See
The developers call it "Slackware Linux" which is unfair to the GNU Project. See and this, plus the history.


— Dr. Richard Stallman

So GNU/Linux Slackware is free as in free beer but not in terms of free in access to all of its code.

If you have only ever used Windows there will be a learning curve but there are choices on how fast you learn Linux. Things would be better if in 3rd World Countries such as Ghana they were serious in embracing Linux users and putting Linux onto the school Curriculum.

Some say Linux is complicated but more I find it a more minimal experience especially using XFCE Desktop. I recently looked at a friend's laptop that was 30 gig and had Windows 10 on it. The hard drive was full but Windows wanted to do it said 2.8gig of updates. To be honest, how you can find your way around the system with all that clutter on the Desktop is beyond me!

The way I think about Linux is to use a car metaphor. Your Diesel car uses diesel and your petrol car, petrol. Apart from that, a driver uses his steering wheel, breaks, etc without a second thought about the engineering concept of the 4 stroke engine.

It's a bit like that in Linux. Once installed and you log in; you have at your disposal Firefox web browser and to all intents and purposes wouldn't know if you were on Linux or Windows.

All the other stuff like LibreOffice is available from the menu; the layout of LibreOffice is user-intuitive and you can save files as "doc".

Basically, the least complicated way is to use Linux as a normal user. In this case "file permissions" are set so that you will not be challenged.

On my Slackware GNU/Linux I have:

bash-5.0$ php -v

PHP 7.4.1 (cli) (built: Dec 19 2019 00:29:31) ( ZTS )

Copyright (c) The PHP Group

Zend Engine v3.4.0, Copyright (c) Zend Technologies

with Zend OPcache v7.4.1, Copyright (c), by Zend Technologies

bash-5.0$

So with PHP 7.4.1 that's quite adequate to work for say CodeIgniter 4 or Symfony.

Since around 5.5 PHP came with its dev server you can simply do PHP development on your Desktop.

If for instance I download and unzip the latest CodeIgniter, cd into it and run this command:

bash-5.0$ php spark serve

CodeIgniter CLI Tool - Version 4.0.3 - Server-Time: 2020-07-03 06:08:42am

CodeIgniter development server started on `http://localhost:8080`

Press Control-C to stop.

[Fri Jul 3 12:08:42 2020] PHP 7.4.1 Development Server (http://localhost:8080) started

I am up and running and can see the landing page at http://localhost:8080

PHP Development server

As I previously said its best to develop in as near to as your live environment will be so maybe apache might be more appropriate. Also, MySQL needs a database server so you can't use MySQL with the above method but what you can do is easily use sqlite3.

I have a few projects I'm working on and one risk leaving things on the Desktop is that they are easily likely to be wiped.

Developing PHP on Linux in the apache web server is not that complicated; I have it set up so that each project has its own directory located at var/www/htdocs

|- htdocs

|-- CI

|-- gbn

|-- ginabrookes

|-- ginbrookes

|-- index.php

|-- mysymfony

I access via a web page and via a set up using httpd-vhosts.conf file.

Basically, I give each project a different Local host address so that I can directly access each project

such as :

127.0.0.2

127.0.0.3

In httpd-vhosts.conf file, I could do:

<VirtualHost 127.0.0.7:80>

ServerName ginabrookes.com

ServerAlias www.ginabrookes.com

DocumentRoot "/var/www/htdocs/ginabrookes/public"

<Directory "/var/www/htdocs/ginabrookes/public>

Order allow, deny

Allow from All

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

Or by editing I can use a domain name in the web address bar by matching IP to a name.

For loopbacking.

127.0.0.1 localhost

127.0.0.1 darkstar.citreon.org darkstar

127.0.0.2 CI.org

127.0.0.6 ginbrookes.com

127.0.0.7 ginabrookes.com
End of hosts.

There are some quirks to editing the development code since files within the system that are not in your usual userspace come under root or apache.

Maybe I can address that at another time.

When you first use Linux as a "normal" user; it's not so bad; everything is there from the menu such as Firefox and generally everything works no problem. You can create documents, open them later, and edit - no problem. Everything is fine in your "normal user space".

Then one day like being in some old mansion you get inquisitive and start to look into other areas, but you find all the doors locked. You try to do something and get a "permission denied" you start feeling like your under "house arrest" and maybe a panic attack coming on.

Well, that's one way of looking at it. Basically, everything outside your normal userspace comes under root or other labels.

Apache webserver is located in the central system, not in your user space; this is probably one of the main bugs bears Windows users will have.

If you have a PHP framework inside at directory say called my "mydev", located at /var/www/htdocs/mydev then you are going to get a shock when you open up say a PHP class and edit something- you can't do it because you don't have permission to do so.

In a nutshell, Linux is a multi-user system; it's designed so that users don't wander into unknown territory and mess up the whole system.

So if you have web dev in Apache web server and can't edit the code then how do you get around it?

Well if you look in /etc/httpd/httpd.conf you will find what Apache runs as in terms of who owns it and under whose permission it runs under.

Generally, you should see :

user: Apache
group: Apache

So maybe your know thinking "oh I see it's like one of those poncy exclusive golf clubs" - I can't get in unless I'm a member!

Sort of.

So say your user name is "andrew" how does andrew get into the exclusive "apache" club? well, you can run this command:

# usermod -a -G apache andrew

That code will keep all the existing groups andrew belongs to but also, add andrew to the "apache" group.

To make sure your "mydev" is set up you can run:

bash-5.0# chown apache:apache mydev -R
bash-5.0# chmod 775 mydev -R

What chmod 775 means is that the owner can read, write and execute and the group can do the same - that means that since user Andrew belongs to the Apache group he can now edit code no problem.

The 5 at the end of 775 means everybody else but owner and group. They can read the code, run it but they can't change the code.

Linux permission is a subject in itself. Of course, all this seems complicated but just like some club that does car mechanics if you have some guiding hand at a Linux group, it will all be clear.

Apart from maybe seeming complex to start with, Linux has benefits and features:

It's a very robust system that can cope with erratic "dumsor" in Ghana generally, you don't have to worry about viruses. There is an Aladdin's cave of software you can add to your system free.

Unlike Windows where you have the choice of either cloned and very likely insecure system or pay every two years for a new OS; you can upgrade your Linux system.

Once you get into Linux, then open software is at your door. Then a brave new world beckons of getting involved with others on coding projects.

Also with Linux, you can run live Linux from a USB stick which when attached to your PC can give you access to fix file systems

Once you get used to Linux, actually, its a minimalist experience; your system does what you expect it to. You take control of your computer. Exactly what a software developer needs.

Last updated 2021-02-01 UTC