Httpsrv 1.0 – Usage / update, uninstall and more on Linux

Usage:
If you call the script by doing: /etc/init.d/httpsrv or service httpsrv or simply httpsrv
The script is going to output bellow text, those are options that you can use with the script
All options will trigger different actions and I will try to cover them all in this section

 

run|stop|restart|stats|info|conf|conftest|web_conf|web_make|php_conf|php_make|install|update|link|perm_all|perm


Options and actions:

  • run = Starts the server
  • stop = Stop the server
  • restart = Restart the server
  • stats = Check if httpd or/and mysqld are running or not
  • info = Prints information about executables, compiled modules and versions
  • conf = Prints information about default paths to configurationfiles
  • conftest = Testing and validating the configurationfile: httpd.conf
  • web_conf = Only used for installation, configures sources for httpd
  • web_make = Only used for installation, compiling sources for httpd
  • php_conf = Only used for installation, configures sources for php
  • php_make = Only used for installation, compiling sources for php
  • install = Only used for installation, finalizing installation of httpsrv
  • update = Creating a new directory for httpsrv and moves the old to httpsrv_old
  • link = Creates symlinks for certain executables in /usr/local/sbin
  • perm_all = Chowns and changes permission on the ROOT-Variable
  • perm = Chowns and changes permission on the ROOT-Variable /htdocs
  • start = This trigger is only used in autostart and will force start

By default php.ini-production will be loaded as configuration for PHP (php.ini)
This file will not display error messages to the user when httpsrv is running
If you want to change this you can do so using the below commands:

rm -f /srv/httpsrv/etc/php.ini
cp -f /srv/httpsrv/etc/php.ini-development /srv/httpsrv/etc/php.ini

For this to take effect you will need to restart the webserver
To revert to the default php.ini and turn off the error messages run:

rm -f /srv/httpsrv/etc/php.ini
cp -f /srv/httpsrv/etc/php.ini-production /srv/httpsrv/etc/php.ini

Update Apache (httpd) and php / Httpsrv

  • Stop the server using: /etc/init.d/httpsrv stop
  • Run the command: /etc/init.d/httpsrv update
    This will rename your curent folder ”httpsrv” to httpsrv_old and create a new one

After this run all the commands that you used when you first installed httpsrv
You dont need to run any commands to install mysql, this shall already be installed
(Also don´t forget to reconfigure httpd.conf)

/etc/init.d/httpsrv web_conf
/etc/init.d/httpsrv web_make
/etc/init.d/httpsrv php_conf
/etc/init.d/httpsrv php_make
/etc/init.d/httpsrv install
/etc/init.d/httpsrv link
mysql -u root -p < ../phpmyadmin/sql/create_tables.sql

Update phpMyAdmin:
Download phpMyAdmin from the website and extract it.
After download, rename the resulting folder to phpmyadmin.
Rename or delete the folder ”phpmyadmin” on your server and upload the new one.
Now you can run the commands below to finish the installation:

cd /srv/httpsrv
rm -f phpmyadmin/config.sample.inc.php
cp -f src/script/config.inc.php phpmyadmin/
/etc/init.d/httpsrv perm_all
/etc/init.d/httpsrv restart

You can launch the graphical configuration tool for phpMyAdmin
Navigating to localhost/phpmyadmin/setup in your webbrowser
This only work for localhost or the local IP: 127.0.0.1

Uninstallation in Debian:
Run the below in a terminal as root or sudo

/etc/init.d/httpsrv stop
update-rc.d -f httpsrv remove
mysqladmin -u root -p drop phpmyadmin
cd /srv && userdel -fr httpsrv
rm -f /usr/local/sbin/php
rm -f /usr/local/sbin/phpize
rm -f /usr/local/sbin/httpsrv
rm -f /usr/local/sbin/htpasswd
rm -f /usr/local/sbin/htdigest
rm -f /usr/local/sbin/htcacheclean
rm -f /etc/init.d/httpsrv

Uninstallation for CentOS:
Run the below in a terminal as root or sudo

/etc/init.d/httpsrv stop
chkconfig httpsrv off && chkconfig --del httpsrv
mysqladmin -u root -p drop phpmyadmin
cd /srv && userdel -fr httpsrv
rm -f /usr/local/sbin/php
rm -f /usr/local/sbin/phpize
rm -f /usr/local/sbin/httpsrv
rm -f /usr/local/sbin/htpasswd
rm -f /usr/local/sbin/htdigest
rm -f /usr/local/sbin/htcacheclean
rm -f /etc/init.d/httpsrv

Explanation about symliked executables in /usr/local/sbin:

  • /usr/local/sbin/php = Call this with help to find out more info
  • /usr/local/sbin/phpize = Can be used when compiling PECL extensions
  • /usr/local/sbin/htpasswd = Used with flat-files for basic authentication in httpd
  • /usr/local/sbin/htdigest = Used with flat-files for digest authentication in httpd
  • /usr/local/sbin/htcacheclean = Used to clean up disk cache in httpd (apache2)

Those links are linked to the path-variable
This means that you can execute them wherever you are in the file-system

Disclaimer:
Httpsrv is a set of scripts and preconfigured configuration files to make it easier you you if you want to compile apache and php yourself
Because of the preconfigured configuration files I highly recomend that you take the time and change some variables in all of those files
Feel free to test this as your primary webserver but remember to change some settings about passwords and phrases e.g blowfish_secret
Also if you run this server publicly you shall activate your security in the server and add some firewall rules to allow trafic to httpd

Configurationfiles:

  • httpsrv/etc/php.ini
  • httpsrv/conf/httpd.conf
  • httpsrv/phpmyadmin/config.inc.php
  • httpsrv/conf/extra/phpmyadmin.conf

To find the configfile for MySQL you can run:
Default paths: /etc/mysql/my.cnf or /etc/my.cnf

/etc/init.d/httpsrv conf

Remember that those scriptfiles have been created by me (www.leemann.se/fredrik) and not the actual software developers.
I take no responsability for any harm those applications might do to your system or network.

There are html and php files used for testing in the public folder named htdocs You shall delete those files before you make the server public.
This is for security reasons and you probably don´t want the world to know how your server is compiled and what modules are loaded and being used.

Always when using a server that facing to the outside (publicly) you shall take your responsibility to configure it and make it as secure as possible.
Remember that the software can have bugs and faults (software: apache software fundation, php, phpMyAdmin and Oracle MySQL Community)

In production environments a best practice is to uninstall development and compile-tools like make and gcc.
Those are a security concern since you can use them to compile malicious code to applications.

Those scriptfiles have been a project for me and I have learnt alot more about: Apache / php / MySQL and phpMyAdmin.
This server is built from sourcecode.You can also install a complete LAMP-Stack from your Linux distributions package manager.

Usefull links for more reading:
http://php.net/manual/en/install.pecl.phpize.php
http://httpd.apache.org/docs/current/programs/htdigest.html
https://httpd.apache.org/docs/2.4/programs/htcacheclean.html
https://httpd.apache.org/docs/current/programs/htpasswd.html
http://php.net/manual/en/features.commandline.interactive.php
https://www.question-defense.com/tools/phpmyadmin-blowfish-secret-generator

Donate
Donation are not required but very much appreciated.
Click the below link to donate with PayPal (PayPal.Me)
Link: https://www.paypal.me/freddan88

GitHub
Link: https://github.com/freddan88