To develop PHP web apps, you need to set up Apache, MySQL and PHP, in a LAMP Stack (Linux/Apache/MySQL/PHP) environment. You can either install the individual components i.e Apache, MySQL and PHP or you can install a BUNDLE package which includes all the software needed in a single installer package. There are various All-In-One packages available. Some of these are:
Easy PHP (@ http://www.easyphp.org/).
XAMPP @ Apache Friends Website (Cross-platform for Windows, Mac OS and Linux).
Zend Server (@ Zend Website) (Cross-platform for Windows, Mac OS and Linux).
Various SNAP, APPIMAGE and DOCKER pre-packaged containers and app-combo packages.
You need some knowledge of these programming languages:
- Database programming: SQL (MySQL or PostgreSQL).
- Server-side programming: PHP (or Python, or Perl).
- On Ubuntu, use sudo apt install mysql-server.
- On CentOS, issue the command sudo yum install mysql-server.
- During the previous step, you will be asked to supply a root user password for the mysql database access. Use a different one to the root password for the server you are on to ensure some security.
- Once the install process is complete, do the following:
- Verify the install with which mysql and which mysqld. These should return the paths of the relevant software.
- Configure mysql for first use with mysql_install_db
- Set mysql server to always run with systemctl enable mysql
- To access mysql, use the mysql client with the following parameters: mysql -u root -p
- See the official MySQL website for creating a database and granting users access
- Ubuntu: sudo apt install apache2
- CentOS: sudo yum install httpd
- Verify with which apache2 or which httpd
- Ensure run on start with systemctl enable apache2 or systemctl enable httpd (CentOS)
- Remember to allow port 80 and 443 (for SSL) access through your firewall
- See the Apache Web site for finer detail on setting up virtual sites, SSL, etc.
- Ubuntu: sudo apt install php libapache2-mod-php php-mcrypt php-mysql
- CentOS: sudo yum install php libapache2-mod-php php-mcrypt php-mysql
- Verify with which php and sudo apache2ctl configtest or sudo apachectl configtest
- Run php -i to list all the installed modules
- The official PHP website
The LAMP stack may seem trivial at first, but you can build extremely powerful and versatile web applications with this combination. It also uses surprisingly few resources and can be run on the lowest spec VPS at Host Africa with ease. As usage increases, you will have to keep watch on resource usage with tools such as top, htop, mytop (for mysql) and apachetop. There are various development tools available for the LAMP stack on both Windows and Linux (IDE’s) but these are beyond the scope of this article.
Using just these 3 tools, I have written custom monitoring systems, BI reporting back and frontends, a full client zone for an ISP and automated secure DNS cluster updaters. PHP is a very powerful language that is extremely forgiving of hamfisted programmers such as myself and rewards even the feeblest of efforts with surprising generosity. Apache may be swapped out for the web server of your choice. MySQL is often swapped out with MariaDB (a plugin, fully open source replacement by the original writer of MySQL). The Standard Query Language (SQL) is a fascinating system with much more power than most developers realize and may be used for some amazing data manipulation.
All in all, a set of packages with much fun and enjoyment!