How Do You Fix a memcached.so Error when Running PHP Too?

Problem scenario
You get an error about memcache and you are running PHP. Or you get an error “Unable to load dynamic library “memcached.so”? You run “php –version” and you see an error about memcache or memcached (e.g., a missing memcached.so file). What should you do?

Possible Solution #1
Get a memcached.so file from a working Linux server and place it in the directory that the error message showed in the php –version command.

Why Does a PHP Program Call to a Python Program Work from the Back-End but Not from the Front-End?

Problem scenario
In your PHP program, the Python binary is executing regardless of how the PHP program is run (e.g., from a command line with the php command or when downloaded from a web browser). The PHP program will launch Python programs if the PHP program is invoked from the back-end with PHP. But Python programs are not being interpreted by Python when a web browser loads the PHP file.

How Do You Get a PHP Program to Invoke a Python Program via Browsing a Website?

Problem scenario
You want Debian/Ubuntu Linux to support a website. You want a Python program to run every time a web page is downloaded. How do you get a PHP program to invoke a Python program on Debian/Ubuntu Linux?

Solution

Prerequisites
i. This assumes you have Apache2 and PHP installed. If you need assistance run this: sudo apt -y install apache2 php
ii.

How Do You Install Composer on Debian/Ubuntu Linux?

Problem scenario
You want to install Composer (a dependency manager for PHP) on your Debian/Ubuntu Linux server. What do you do?

Solution

  1. Run these commands:

sudo apt -y update
sudo apt -y install php-cli unzip
cd ~
sudo curl -sS https://getcomposer.org/installer -o composer-setup.php
HASH=curl -sS https://composer.github.io/installer.sig
echo $HASH
php -r “if (hash_file(‘SHA384’,

How Do You Get a PHP Script to Invoke a Bash Command?

Problem scenario
You are trying to get a PHP file to invoke a bash script. When you run it from the command line with “php foobar.php” you just see the content of the PHP file. What do you do to get PHP to invoke a bash script?

Solution
Make sure you have the correct header and closing symbols. Here is the content of foobar.php:

<?php
exec(‘bash /var/www/html/testScript.sh’); …

What Are Some Tips on a Bash Programmer Becoming a PHP Programmer?

Problem scenario
You are a Bash programmer, but you want to learn how to code in PHP.  How do you learn to develop PHP scripts when you have a Linux bash background?

Solution
If you are new to PHP programming and familiar with Bash programming, remember these tips:

1.  Variable assignments involve the variable with the syntax of a cash sign “$” before the variable name. 

How Do You Troubleshoot the PHP Syntax Error “unexpected end of file in …”?

Problem scenario
You receive this message “PHP Parse error:  syntax error, unexpected end of file in /path/to/file.php on line x.”  How do you solve this?

Solution
Verify you have a closing brace for every open brace.  You may want to go to this site to help you find an unmatched brace.

How Do You Install Memcached on an Ubuntu Server?

Problem scenario
You want to try out Memcached.  How do you install memcached and php-memcached to test it?

Solution
(These directions were based on ServerMom.org directions.)

1.  Run these commands:

sudo apt-get -y update
sudo apt -y install memcached php-memcached php7.0 apache2
  # apache2 is not necessary but useful for testing purposes

2. 

How Do You Troubleshoot PHP Not Displaying the Output of a Bash Command?

Problem scenario
You have a PHP program that works from the back-end (from a command terminal executing like php foobar.php). When you view the program in a web browser, it is not running the Bash commands properly. What should you do?

Solution
The root cause is probably the user execution context and a variety of permissions or configuration settings on the Linux system.