Give it a listen and read the lyrics along with it.
Give it a listen and read the lyrics along with it.
Here are reasons why I elect PHP as my favorite language for back-end and server-side software:
It's free and open source
The source code you write is the output document
php binary behaves much like the Linux cat (concatenate) command, but with the addition of the language's logic & execution interpreted between <?php and ?> tags read from the input. The output isn't required to be text/html, it can be anything UTF-8.It's old — it has been out long enough to be supported & well understood
Apache is suggested but not required
It's trusted and vetted
Short answer:
Long answer:
PM2 makes daemonizing processes very easy. Most virtual machines I spin up are single-user Debian environments. I would rather use PM2 to host my server software spawned in by a shell script rather than doing this the systemd way. You can think of PM2 as giving you the "daemonize this" command.
For example:
pm2 start my-script.sh
Whatever my-script.sh is doing, PM2 will ensure that it continues to run in the background. Should you want my-script.sh to run automatically at startup, easy. Just run the commands below:
pm2 startup
pm2 save
When run as root, this will tell PM2 to start its list of processes when the system boots with no extra fuss. Want to see what's currently running under PM2? Run:
pm2 list
Seriously. The task of managing daemonized processes has never been easier. Here's how you prepare your Debian system to have Node.js and PM2:
apt install nodejs
apt install npm
npm install -g n
n latest
npm install -g pm2
This installs Node.js, the Node package manager, and the "n" utility for making sure that you are using the latest version of Node.js.
Now that you have PM2, it's time to start hosting your microservices written in Python and PHP. I use shell scripting to spawn the processes like so:
PHP:
#!/bin/bash
# https://stackoverflow.com/a/1482133
SCRIPT_DIR="$(dirname -- "$(readlink -f -- "$0";)";)"
cd "${SCRIPT_DIR}"
# Allow port setting via first argument:
PORT=8000
if [[ ! "$1" == "" ]]
then
PORT="$1"
fi
# Handle multiple simultaneous requests in Linux only:
export PHP_CLI_SERVER_WORKERS=4
php -S 0.0.0.0:$PORT index.php --enable-mbstring
Python:
#!/bin/bash
INSTALLATION=0
if [[ ! -d venv ]]
then
python3 -m venv venv || python -m venv venv || (
echo "Could not create a Python virtual environment."
exit 1
)
INSTALLATION=1
fi
if [[ -f ./venv/bin/activate ]]; then source ./venv/bin/activate; fi
if [[ -f ./venv/Scripts/activate ]]; then source ./venv/Scripts/activate; fi
if [[ $INSTALLATION -eq 1 ]]
then
pip install discord.py
pip install pillow
fi
python -u bot.py Set the kernel option net.core.wmem_max to 8388608 via issuing sysctl -w net.core.wmem_max=8388608. You can have this change persist across reboots by writing:
net.core.wmem_max = 8388608
...to /etc/sysctl.d/xrdp.conf.
Ensure the following:
tcp_send_buffer_bytes=4194304
max_bpp=16
This was all that was needed to get my unbearably slow experience to something usable for connections over a private VPN. No tweaks to the compositor needed.
Insert the following line
export $(dbus-launch)
...before the test -x and exec lines in /etc/xrdp/startwm.sh to allow signing into your user account more than once. This is especially useful for users coming from Windows environments where you can be signed in locally (at home) and connect to your same user account from afar via RDP.
This site is running on a microblogging engine I wrote. If you have a LAMP stack of your own, you can combine these two projects to experiment with it:
Maintain compatibility with old & text-based browsers
Offer a balance of simplicity and customization
body[data-page='...'] selector