Jekyll2020-01-08T01:42:58+00:00https://josephtingiris.github.io/atom.xmlJoseph TingirisDiscover, Define, Develop, DeployJoseph TingirisHow to install the RedHat Software Collections Library PHP 7.2 on CentOS 72020-01-07T23:48:00+00:002020-01-07T23:48:00+00:00https://josephtingiris.github.io/howto/install/php%207/centos%207/2020/01/07/redhat-scl-php-7.2-on-centos-7<p>This is a functional reference guide for Enterprise Linux, specifically CentOS 7, that attempts to provide a straightforward procedure for producing a highly functional, stable, and modern LAMP 7 stack (i.e. HOWTO).</p>
<h1 id="tldr">TL;DR</h1>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo yum clean all
sudo yum makecache
sudo yum -y install epel-release centos-release-scl
sudo yum -y install httpd24-mod_ssl libsodium
sudo yum -y install rh-php72 rh-php72-php rh-php72-php-bcmath rh-php72-php-cli rh-php72-php-common rh-php72-php-curl rh-php72-php-dba
sudo yum -y install rh-php72-php-embedded rh-php72-php-enchant rh-php72-php-fpm rh-php72-php-gd rh-php72-php-intl rh-php72-php-ldap
sudo yum -y install rh-php72-php-mbstring rh-php72-php-memcached rh-php72-php-mysqlnd rh-php72-php-odbc rh-php72-php-pdo
sudo yum -y install rh-php72-php-pear rh-php72-php-pecl-apcu rh-php72-php-pgsql rh-php72-php-process rh-php72-php-pspell
sudo yum -y install rh-php72-php-recode rh-php72-php-snmp rh-php72-php-soap rh-php72-php-xml rh-php72-php-xmlrpc rh-php72-php-zip
sudo yum -y install sclo-php72-php-imap sclo-php72-php-pecl-amqp sclo-php72-php-pecl-apcu-bc sclo-php72-php-sodium
sudo yum -y install sclo-php72-php-pecl-apfd sclo-php72-php-pecl-geoip sclo-php72-php-pecl-http sclo-php72-php-pecl-igbinary
sudo yum -y install sclo-php72-php-pecl-imagick sclo-php72-php-pecl-lzf sclo-php72-php-pecl-memcached sclo-php72-php-pecl-mongodb
sudo yum -y install sclo-php72-php-pecl-msgpack sclo-php72-php-pecl-propro sclo-php72-php-pecl-raphf sclo-php72-php-pecl-redis
sudo yum -y install sclo-php72-php-pecl-selinux sclo-php72-php-pecl-solr2 sclo-php72-php-pecl-uploadprogress sclo-php72-php-pecl-uuid
sudo yum -y install sclo-php72-php-pecl-xattr sclo-php72-php-pecl-xdebug sclo-php72-php-tidy
/opt/rh/rh-php72/root/usr/bin/php --ini
sudo systemctl stop httpd
sudo systemctl disable httpd
yum -y remove httpd httpd-tools php*
cat <<EOF > /etc/systemd/system/httpd.service
[Unit]
Description=The RedHat Software Collections Library (SCL) Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper \$OPTIONS -DFOREGROUND
ExecReload=/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper \$OPTIONS -k graceful
ExecStop=/bin/kill -WINCH \${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF > /etc/sysconfig/httpd
OPTIONS="-d /etc/httpd"
LANG=C
EOF
chmod 644 /etc/sysconfig/httpd
cat <<EOF > /etc/logrotate.d/httpd
/var/log/httpd/*log {
missingok
notifempty
sharedscripts
compress
postrotate
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
endscript
su apache apache
}
EOF
chmod 644 /etc/logrotate.d/httpd
cat <<EOF > /etc/ld.so.conf.d/rh-php72.conf
/opt/rh/rh-php72/root/usr/lib64
/opt/rh/httpd24/root/usr/lib64
/opt/rh/rh-php72/root/usr/lib
/opt/rh/httpd24/root/usr/lib
EOF
ldconfig
if [ -d /etc/httpd ] && [ ! -d /etc/httpd.base ]; then (mv /etc/httpd /etc/httpd.base); fi
if [ ! -f /etc/httpd/conf/httpd.conf ]; then (rsync -avp /opt/rh/httpd24/root/etc/httpd/ /etc/httpd/); fi
for httpd24_conf in $(find /etc/httpd -type f | xargs grep -l "/opt/rh/httpd24/root"); do echo $httpd24_conf; sed -i -e 's#/opt/rh/httpd24/root/etc#/etc#g' -e 's#/opt/rh/httpd24/root/var/www#/var/www#g' $httpd24_conf; done
sudo systemctl daemon-reload
sudo systemctl enable httpd24-htcacheclean
sudo systemctl start httpd24-htcacheclean
sudo systemctl status httpd24-htcacheclean
sudo systemctl enable httpd
sudo systemctl start httpd
sudo systemctl status httpd
ln -s /opt/rh/rh-php72/root/usr/bin/php /usr/bin/php
ln -s /etc/opt/rh/rh-php72/php.ini /etc/php.ini
sudo systemctl daemon-reload
sudo systemctl status httpd
</code></pre></div></div>
<h1 id="install-the-centos-epel--redhat-software-collections-library-scl-release-packages-clean--rebuild-the-yum-cache">Install the CentOS EPEL & RedHat Software Collections Library (scl) release packages, clean, & rebuild the yum cache.</h1>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo yum clean all
sudo yum makecache
sudo yum install epel-release centos-release-scl
</code></pre></div></div>
<h1 id="install-the-latest-redhat-scl-php-72--corresponding-dependent-httpd24-packages">Install the latest RedHat SCL php 7.2 & corresponding, dependent httpd24 packages.</h1>
<p>The following command installs the most commonly used php modules, as well.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo yum install httpd24-mod_ssl
sudo yum install rh-php72 rh-php72-php rh-php72-php-bcmath rh-php72-php-cli rh-php72-php-common rh-php72-php-curl rh-php72-php-dba
sudo yum install rh-php72-php-embedded rh-php72-php-enchant rh-php72-php-fpm rh-php72-php-gd rh-php72-php-intl rh-php72-php-ldap
sudo yum install rh-php72-php-mbstring rh-php72-php-memcached rh-php72-php-mysqlnd rh-php72-php-odbc rh-php72-php-pdo
sudo yum install rh-php72-php-pear rh-php72-php-pecl-apcu rh-php72-php-pgsql rh-php72-php-process rh-php72-php-pspell
sudo yum install rh-php72-php-recode rh-php72-php-snmp rh-php72-php-soap rh-php72-php-xml rh-php72-php-xmlrpc rh-php72-php-zip
sudo yum install sclo-php72-php-imap sclo-php72-php-pecl-amqp sclo-php72-php-pecl-apcu-bc sclo-php72-php-sodium
sudo yum install sclo-php72-php-pecl-apfd sclo-php72-php-pecl-geoip sclo-php72-php-pecl-http sclo-php72-php-pecl-igbinary
sudo yum install sclo-php72-php-pecl-imagick sclo-php72-php-pecl-lzf sclo-php72-php-pecl-memcached sclo-php72-php-pecl-mongodb
sudo yum install sclo-php72-php-pecl-msgpack sclo-php72-php-pecl-propro sclo-php72-php-pecl-raphf sclo-php72-php-pecl-redis
sudo yum install sclo-php72-php-pecl-selinux sclo-php72-php-pecl-solr2 sclo-php72-php-pecl-uploadprogress sclo-php72-php-pecl-uuid
sudo yum install sclo-php72-php-pecl-xattr sclo-php72-php-pecl-xdebug sclo-php72-php-tidy
</code></pre></div></div>
<h1 id="verify-the-php-72-installation">Verify the php 7.2 installation.</h1>
<p><em>At this point, there should be a fully functional httpd 2.4 with php 7.2 (using the mysqlnd driver, etc).</em></p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/opt/rh/rh-php72/root/usr/bin/php <span class="nt">--ini</span>
</code></pre></div></div>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Configuration File (php.ini) Path: /etc/opt/rh/rh-php72
Loaded Configuration File: /etc/opt/rh/rh-php72/php.ini
Scan for additional .ini files in: /etc/opt/rh/rh-php72/php.d
Additional .ini files parsed: /etc/opt/rh/rh-php72/php.d/15-xdebug.ini,
/etc/opt/rh/rh-php72/php.d/20-bcmath.ini,
/etc/opt/rh/rh-php72/php.d/20-bz2.ini,
/etc/opt/rh/rh-php72/php.d/20-calendar.ini,
/etc/opt/rh/rh-php72/php.d/20-ctype.ini,
/etc/opt/rh/rh-php72/php.d/20-curl.ini,
/etc/opt/rh/rh-php72/php.d/20-dba.ini,
/etc/opt/rh/rh-php72/php.d/20-dom.ini,
/etc/opt/rh/rh-php72/php.d/20-enchant.ini,
/etc/opt/rh/rh-php72/php.d/20-exif.ini,
/etc/opt/rh/rh-php72/php.d/20-fileinfo.ini,
/etc/opt/rh/rh-php72/php.d/20-ftp.ini,
/etc/opt/rh/rh-php72/php.d/20-gd.ini,
/etc/opt/rh/rh-php72/php.d/20-gettext.ini,
/etc/opt/rh/rh-php72/php.d/20-iconv.ini,
/etc/opt/rh/rh-php72/php.d/20-imap.ini,
/etc/opt/rh/rh-php72/php.d/20-intl.ini,
/etc/opt/rh/rh-php72/php.d/20-json.ini,
/etc/opt/rh/rh-php72/php.d/20-ldap.ini,
/etc/opt/rh/rh-php72/php.d/20-mbstring.ini,
/etc/opt/rh/rh-php72/php.d/20-mysqlnd.ini,
/etc/opt/rh/rh-php72/php.d/20-odbc.ini,
/etc/opt/rh/rh-php72/php.d/20-pdo.ini,
/etc/opt/rh/rh-php72/php.d/20-pgsql.ini,
/etc/opt/rh/rh-php72/php.d/20-phar.ini,
/etc/opt/rh/rh-php72/php.d/20-posix.ini,
/etc/opt/rh/rh-php72/php.d/20-pspell.ini,
/etc/opt/rh/rh-php72/php.d/20-recode.ini,
/etc/opt/rh/rh-php72/php.d/20-shmop.ini,
/etc/opt/rh/rh-php72/php.d/20-simplexml.ini,
/etc/opt/rh/rh-php72/php.d/20-snmp.ini,
/etc/opt/rh/rh-php72/php.d/20-soap.ini,
/etc/opt/rh/rh-php72/php.d/20-sockets.ini,
/etc/opt/rh/rh-php72/php.d/20-sodium.ini,
/etc/opt/rh/rh-php72/php.d/20-sqlite3.ini,
/etc/opt/rh/rh-php72/php.d/20-sysvmsg.ini,
/etc/opt/rh/rh-php72/php.d/20-sysvsem.ini,
/etc/opt/rh/rh-php72/php.d/20-sysvshm.ini,
/etc/opt/rh/rh-php72/php.d/20-tidy.ini,
/etc/opt/rh/rh-php72/php.d/20-tokenizer.ini,
/etc/opt/rh/rh-php72/php.d/20-xml.ini,
/etc/opt/rh/rh-php72/php.d/20-xmlwriter.ini,
/etc/opt/rh/rh-php72/php.d/20-xsl.ini,
/etc/opt/rh/rh-php72/php.d/20-zip.ini,
/etc/opt/rh/rh-php72/php.d/30-mysqli.ini,
/etc/opt/rh/rh-php72/php.d/30-pdo_mysql.ini,
/etc/opt/rh/rh-php72/php.d/30-pdo_odbc.ini,
/etc/opt/rh/rh-php72/php.d/30-pdo_pgsql.ini,
/etc/opt/rh/rh-php72/php.d/30-pdo_sqlite.ini,
/etc/opt/rh/rh-php72/php.d/30-wddx.ini,
/etc/opt/rh/rh-php72/php.d/30-xmlreader.ini,
/etc/opt/rh/rh-php72/php.d/30-xmlrpc.ini,
/etc/opt/rh/rh-php72/php.d/40-amqp.ini,
/etc/opt/rh/rh-php72/php.d/40-apcu.ini,
/etc/opt/rh/rh-php72/php.d/40-apfd.ini,
/etc/opt/rh/rh-php72/php.d/40-geoip.ini,
/etc/opt/rh/rh-php72/php.d/40-igbinary.ini,
/etc/opt/rh/rh-php72/php.d/40-imagick.ini,
/etc/opt/rh/rh-php72/php.d/40-lzf.ini,
/etc/opt/rh/rh-php72/php.d/40-msgpack.ini,
/etc/opt/rh/rh-php72/php.d/40-propro.ini,
/etc/opt/rh/rh-php72/php.d/40-raphf.ini,
/etc/opt/rh/rh-php72/php.d/40-selinux.ini,
/etc/opt/rh/rh-php72/php.d/40-uploadprogress.ini,
/etc/opt/rh/rh-php72/php.d/40-uuid.ini,
/etc/opt/rh/rh-php72/php.d/40-xattr.ini,
/etc/opt/rh/rh-php72/php.d/50-apc.ini,
/etc/opt/rh/rh-php72/php.d/50-http.ini,
/etc/opt/rh/rh-php72/php.d/50-memcached.ini,
/etc/opt/rh/rh-php72/php.d/50-mongodb.ini,
/etc/opt/rh/rh-php72/php.d/50-solr.ini
</code></pre></div></div>
<h1 id="additional-steps">Additional Steps</h1>
<p>There are some things that I’ve found make using the RedHat PHP 7.2.x SCL packages and upgrading existing code bases a little easier. <em>The following steps are <strong>OPTIONAL</strong>, but recommended.</em></p>
<h2 id="to-avoid-potential-conflict-ensure-the-centos-base-httpd-is-stopped-disabled-and-completely-removed-from-the-system">To avoid potential conflict, ensure the CentOS base httpd is stopped, disabled, and completely removed from the system.</h2>
<p><strong><em>I’d strongly recommend removing the CentOS base php & httpd.</em></strong> Having the base packages on the system, with SCL packages, can cause confusion. Although, to be fair, it’s possible as long as both httpd installs are configured to use different interfaces and/or ports.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>systemctl stop httpd
<span class="nb">sudo </span>systemctl disable httpd
</code></pre></div></div>
<p>It’s also important to note that, by default and because, both base & SCL httpd packages are configured to bind to all interfaces on port 80 (& port 443 if mod_ssl is installed). As a result, only one at a time will start successfully. If you’re not doing this then I’m sure you know what I mean & how to fix that.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>yum remove httpd httpd-tools php<span class="k">*</span>
</code></pre></div></div>
<h2 id="create-a-custom-systemd-httpdservice-file">Create a custom systemd httpd.service file.</h2>
<p>This will allow for a normal Enterprise Linux administrative ‘feel’ and retain functionality such as <code class="language-plaintext highlighter-rouge">systemctl restart httpd</code>. It will also override the default CentOS base httpd (if it exists on the system) and allow for local customizations. It’s helpful to me, sometimes.</p>
<p>The tendency for both httpd & httpd24 to use the same ports can be frustrating, especially for web developers who are unfamiliar with SCL. Ultimately, I’d recommend this and <strong><em>I do not recommend having both of the CentOS base httpd & SCL httpd24 on the same system</em></strong>. Nevertheless, if you do this then remember to run <code class="language-plaintext highlighter-rouge">systemctl daemon-reload</code> after creating /etc/systemd/system/httpd.service</p>
<h3 id="etcsystemdsystemhttpdservice">/etc/systemd/system/httpd.service</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cat <<EOF > /etc/systemd/system/httpd.service
[Unit]
Description=The RedHat Software Collections Library (SCL) Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper \$OPTIONS -DFOREGROUND
ExecReload=/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper \$OPTIONS -k graceful
ExecStop=/bin/kill -WINCH \${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
</code></pre></div></div>
<p>After creating or updating /etc/systemd/system/httpd.service then systemd needs to be reloaded. This, or a reboot, is mandatory every time a custom /etc/systemd service file is modified.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>systemctl daemon-reload <span class="c"># important!</span>
<span class="nb">sudo </span>systemctl status httpd
</code></pre></div></div>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>● httpd.service - The RedHat Software Collections (SCL) Apache HTTP Server
Loaded: loaded (/etc/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
</code></pre></div></div>
<h2 id="create-or-modify-the-systemctl-environmentfile-for-httpdservice">Create (or modify) the systemctl EnvironmentFile for httpd.service</h2>
<p>Doing this will cause the SCL httpd24 to re-use the familiar <code class="language-plaintext highlighter-rouge">/etc/httpd</code> structure (rather than what’s in <code class="language-plaintext highlighter-rouge">/opt/rh/httpd24/root/etc/httpd</code>).</p>
<h3 id="etcsysconfighttpd">/etc/sysconfig/httpd</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cat <<EOF > /etc/sysconfig/httpd
OPTIONS="-d /etc/httpd"
LANG=C
EOF
chmod 644 /etc/sysconfig/httpd
</code></pre></div></div>
<h2 id="copy-the-httpd24-files-to-etchttpd-and-modify-them">Copy the httpd24 files to /etc/httpd and modify them.</h2>
<p><strong><em>PAY MORE ATTENTION TO THE FINAL CONFIGURATIONS THAN IS OUTLINED HERE.</em></strong></p>
<p>If using <code class="language-plaintext highlighter-rouge">/etc/httpd</code>, then be sure to update the contents of <code class="language-plaintext highlighter-rouge">/etc/httpd</code> to reflect what’s in <code class="language-plaintext highlighter-rouge">/opt/rh/httpd24/root/etc/httpd</code>. I typically move the old /etc/httpd out of the way, rsync the SCL configs, and then modify what’s in <code class="language-plaintext highlighter-rouge">/etc/httpd</code> because that preserves the integrity of the SCL packaged configs.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="o">[</span> <span class="nt">-d</span> /etc/httpd <span class="o">]</span> <span class="o">&&</span> <span class="o">[</span> <span class="o">!</span> <span class="nt">-d</span> /etc/httpd.base <span class="o">]</span><span class="p">;</span> <span class="k">then</span> <span class="o">(</span><span class="nb">mv</span> /etc/httpd /etc/httpd.base<span class="o">)</span><span class="p">;</span> <span class="k">fi</span> <span class="c"># artifacts may exist, e.q. conf.d/squid.conf</span>
<span class="k">if</span> <span class="o">[</span> <span class="o">!</span> <span class="nt">-f</span> /etc/httpd/conf/httpd.conf <span class="o">]</span><span class="p">;</span> <span class="k">then</span> <span class="o">(</span>rsync <span class="nt">-avp</span> /opt/rh/httpd24/root/etc/httpd/ /etc/httpd/<span class="o">)</span><span class="p">;</span> <span class="k">fi</span> <span class="c"># don't accidentally overwrite httpd.conf (et al)</span>
</code></pre></div></div>
<p>For new installs, I typically prefer <code class="language-plaintext highlighter-rouge">/var/www</code> as a starting point for <em>DocumentRoot</em>. It’s also important that the <em>ServerRoot</em> directive is changed in <code class="language-plaintext highlighter-rouge">httpd.conf</code>, to reference <code class="language-plaintext highlighter-rouge">/etc/httpd</code>, so that the correct config structure is used.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">for </span>httpd24_conf <span class="k">in</span> <span class="si">$(</span>find /etc/httpd <span class="nt">-type</span> f | xargs <span class="nb">grep</span> <span class="nt">-l</span> <span class="s2">"/opt/rh/httpd24/root"</span><span class="si">)</span><span class="p">;</span> <span class="k">do </span><span class="nb">echo</span> <span class="nv">$httpd24_conf</span><span class="p">;</span> <span class="nb">sed</span> <span class="nt">-i</span> <span class="nt">-e</span> <span class="s1">'s#/opt/rh/httpd24/root/etc#/etc#g'</span> <span class="nt">-e</span> <span class="s1">'s#/opt/rh/httpd24/root/var/www#/var/www#g'</span> <span class="nv">$httpd24_conf</span><span class="p">;</span> <span class="k">done</span>
<span class="sb">```</span>sh
<span class="nb">sudo </span>systemctl daemon-reload <span class="c"># can't hurt!</span>
<span class="nb">sudo </span>systemctl <span class="nb">enable </span>httpd24-htcacheclean
<span class="nb">sudo </span>systemctl start httpd24-htcacheclean
<span class="nb">sudo </span>systemctl status httpd24-htcacheclean
<span class="nb">sudo </span>systemctl <span class="nb">enable </span>httpd <span class="c"># or, httpd24-http</span>
<span class="nb">sudo </span>systemctl start httpd <span class="c"># or, httpd24-http</span>
<span class="nb">sudo </span>systemctl status httpd <span class="c"># or, httpd24-http</span>
</code></pre></div></div>
<p>This is mostly for any other binaries that may be installed, that depend on the shared SCL libraries. For them to always work properly with the RedHat SCL packages, then the following files should be configured manually. Anything compiled and linked with ld will find them.</p>
<h2 id="add-the-rh-php72-shared-library-directories-to-the-ld-linker-search-path-via-etcldsoconfdrh-php72conf">Add the rh-php72 shared library directories to the ld linker search path via /etc/ld.so.conf.d/rh-php72.conf</h2>
<h3 id="etcldsoconfdrh-php72conf">/etc/ld.so.conf.d/rh-php72.conf</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/opt/rh/rh-php72/root/usr/lib64
/opt/rh/httpd24/root/usr/lib64
/opt/rh/rh-php72/root/usr/lib
/opt/rh/httpd24/root/usr/lib
</code></pre></div></div>
<h3 id="prefix-the-rh-php72-binary-directories-to-all-login-paths-via-etcprofiledzzzz-sclsh">Prefix the rh-php72 binary directories to all login PATHs via /etc/profile.d/zzzz-scl.sh</h3>
<p>This is may be helpful. Naming a profile.d include ‘zzzz-scl.sh’ will ensure it gets loaded last. Existing <strong>PATH</strong>s should be appended & preserved.</p>
<h4 id="etcprofiledzzzz-sclsh">/etc/profile.d/zzzz-scl.sh</h4>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="o">[</span> <span class="nt">-d</span> /opt/rh/ <span class="o">]</span> <span class="o">&&</span> <span class="o">[</span> <span class="nt">-r</span> /opt/rh/ <span class="o">]</span><span class="p">;</span> <span class="k">then
</span><span class="nv">Rhscl_Roots</span><span class="o">=</span><span class="si">$(</span>find /opt/rh/ <span class="nt">-type</span> f <span class="nt">-name</span> <span class="nb">enable </span>2> /dev/null | <span class="nb">sort</span> <span class="nt">-V</span><span class="si">)</span>
<span class="k">for </span>Rhscl_Enable <span class="k">in</span> <span class="nv">$Rhscl_Roots</span><span class="p">;</span> <span class="k">do
if</span> <span class="o">[</span> <span class="nt">-r</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
<span class="nb">.</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span>
<span class="k">else
continue
fi
</span><span class="nv">Rhscl_Root</span><span class="o">=</span><span class="s2">"</span><span class="si">$(</span><span class="nb">dirname</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span><span class="si">)</span><span class="s2">/root"</span>
<span class="nv">Rhscl_Bins</span><span class="o">=</span><span class="s2">"usr/bin usr/sbin bin sbin"</span>
<span class="k">for </span>Rhscl_Bin <span class="k">in</span> <span class="nv">$Rhscl_Bins</span><span class="p">;</span> <span class="k">do
if</span> <span class="o">[</span> <span class="nt">-d</span> <span class="s2">"</span><span class="nv">$Rhscl_Root</span><span class="s2">/</span><span class="nv">$Rhscl_Bin</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then
</span>Scl_Path+<span class="o">=</span><span class="s2">"</span><span class="nv">$Rhscl_Root</span><span class="s2">/</span><span class="nv">$Rhscl_Bin</span><span class="s2">:"</span>
<span class="k">fi
done
</span><span class="nb">unset </span>Rhscl_Bin Rhscl_Bins Rhscl_Enable Rhscl_Root
<span class="k">done
</span><span class="nb">unset </span>Rhscl_Roots
<span class="k">fi
</span><span class="nb">export </span><span class="nv">PATH_SCL</span><span class="o">=</span><span class="nv">$Scl_Path</span>
<span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span><span class="k">${</span><span class="nv">PATH_SCL</span><span class="k">}</span>:<span class="nv">$PATH</span>
</code></pre></div></div>
<h1 id="caveats">Caveats</h1>
<p><em>The following information may be helpful.</em></p>
<p>Many packages, programs, & utilities (and people) expect the default CentOS 7 filesystem locations for associated files. The RedHat SCL packages relocate everything to <code class="language-plaintext highlighter-rouge">/opt/rh/</code>.</p>
<ul>
<li>
<p>On CentOS 7 machines with <em>only</em> rh-php-7.2 installed, it may be easiest to use a symbolic link. However, it should <strong>not</strong> be done on machines that choose to have the default php and scl php co-exist on the same machine.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ln -s /opt/rh/rh-php72/root/usr/bin/php /usr/bin/php
ln -s /etc/opt/rh/rh-php72/php.ini /etc/php.ini
</code></pre></div> </div>
</li>
<li>
<p>Best practice, for shell scripts in general, is to use the <code class="language-plaintext highlighter-rouge">/usr/bin/env <processor></code> directives rather than hard coding something like <code class="language-plaintext highlighter-rouge">#!/usr/bin/php</code>. This is a good practice.</p>
<p><code class="language-plaintext highlighter-rouge">#!/usr/bin/env php</code></p>
</li>
<li>
<p>Here’s a quick one liner to find all files from the current directory that contain <code class="language-plaintext highlighter-rouge">/bin/php</code>; they may need to be changed to <code class="language-plaintext highlighter-rouge">#!/usr/bin/env php</code> (rather than relying on a symbolic link).</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> find . -type f | xargs grep -l "/bin/php"
</code></pre></div> </div>
</li>
</ul>
<h1 id="disclaimer">Disclaimer</h1>
<p><strong>Many SCL packages are available and may have been installed if you’re blindly copy/pasting the commands in this guide. Some are ‘rh’ (maintained by RedHat), while others are ‘sclo’ (maintained by the Software Collections organization [not RedHat]). Some are required & others may not be needed.</strong></p>
<p><strong>Jumping into php 7 will enable some newer things to work, but if it isn’t broke, then why fix it? The reality is that php 5.4 has been around for a long time and by now is very stable. It’s still supported by RedHat and will be for many more years.</strong></p>
<p><strong>Or, if & when you’re paranoid about security; I’d recommend sticking with the CentOS 7 base php 5.4 & trust RedHat and the CentOS community. Long term stability and security updates are the main reason a lot of us use RedHat or derivitives like CentOS, anyway.</strong></p>
<h1 id="references">References</h1>
<ul>
<li><a href="https://access.redhat.com/solutions/2662201">https://access.redhat.com/solutions/2662201</a></li>
<li><a href="http://wiki.centos.org/SpecialInterestGroup/SCLo">http://wiki.centos.org/SpecialInterestGroup/SCLo</a></li>
<li><a href="https://www.softwarecollections.org/en/">https://www.softwarecollections.org/en/</a></li>
<li><a href="https://access.redhat.com/security/updates/backporting">https://access.redhat.com/security/updates/backporting</a></li>
</ul>Joseph TingirisThis is a functional reference guide for Enterprise Linux, specifically CentOS 7, that attempts to provide a straightforward procedure for producing a highly functional, stable, and modern LAMP 7 stack (i.e. HOWTO).How to install the RedHat Software Collections Library PHP 7.1 on CentOS 72017-11-01T16:18:00+00:002018-01-27T13:25:00+00:00https://josephtingiris.github.io/howto/install/php%207/centos%207/2017/11/01/redhat-scl-php-7.1-on-centos-7<p>This is a functional reference guide for Enterprise Linux, specifically CentOS 7, that attempts to provide a straightforward procedure for producing a highly functional, stable, and modern LAMP 7 stack (i.e. HOWTO).</p>
<h1 id="install-the-centos-epel--redhat-software-collections-library-scl-release-packages-clean--rebuild-the-yum-cache">Install the CentOS EPEL & RedHat Software Collections Library (scl) release packages, clean, & rebuild the yum cache.</h1>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo yum clean all
sudo yum makecache
sudo yum install epel-release centos-release-scl
</code></pre></div></div>
<h1 id="install-the-latest-redhat-scl-php-71--corresponding-dependent-httpd24-packages">Install the latest RedHat SCL php 7.1 & corresponding, dependent httpd24 packages.</h1>
<p>The following command installs the most commonly required php modules, as well.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo yum install rh-php71 rh-php71-php rh-php71-php-bcmath rh-php71-php-cli rh-php71-php-common rh-php71-php-dba rh-php71-php-embedded rh-php71-php-enchant rh-php71-php-fpm rh-php71-php-gd rh-php71-php-intl rh-php71-php-ldap rh-php71-php-mbstring rh-php71-php-mysqlnd rh-php71-php-odbc rh-php71-php-pdo rh-php71-php-pear rh-php71-php-pecl-apcu rh-php71-php-pgsql rh-php71-php-process rh-php71-php-pspell rh-php71-php-recode rh-php71-php-snmp rh-php71-php-soap rh-php71-php-xml rh-php71-php-xmlrpc sclo-php71-php-imap sclo-php71-php-mcrypt sclo-php71-php-pecl-amqp sclo-php71-php-pecl-apcu-bc sclo-php71-php-pecl-apfd sclo-php71-php-pecl-geoip sclo-php71-php-pecl-http sclo-php71-php-pecl-igbinary sclo-php71-php-pecl-imagick sclo-php71-php-pecl-lzf sclo-php71-php-pecl-memcached sclo-php71-php-pecl-mongodb sclo-php71-php-pecl-msgpack sclo-php71-php-pecl-propro sclo-php71-php-pecl-raphf sclo-php71-php-pecl-redis sclo-php71-php-pecl-selinux sclo-php71-php-pecl-solr2 sclo-php71-php-pecl-uploadprogress sclo-php71-php-pecl-uuid sclo-php71-php-pecl-xattr sclo-php71-php-pecl-xdebug sclo-php71-php-tidy httpd24 httpd24-mod_ssl
</code></pre></div></div>
<h1 id="verify-the-php-71-installation">Verify the php 7.1 installation.</h1>
<p><em>At this point, there should be a fully functional httpd 2.4 with php 7.1 (using the mysqlnd driver, etc).</em></p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/opt/rh/rh-php71/root/usr/bin/php <span class="nt">--ini</span>
</code></pre></div></div>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Configuration File (php.ini) Path: /etc/opt/rh/rh-php71
Loaded Configuration File: /etc/opt/rh/rh-php71/php.ini
Scan for additional .ini files in: /etc/opt/rh/rh-php71/php.d
Additional .ini files parsed: /etc/opt/rh/rh-php71/php.d/15-xdebug.ini,
/etc/opt/rh/rh-php71/php.d/20-bcmath.ini,
/etc/opt/rh/rh-php71/php.d/20-bz2.ini,
/etc/opt/rh/rh-php71/php.d/20-calendar.ini,
/etc/opt/rh/rh-php71/php.d/20-ctype.ini,
/etc/opt/rh/rh-php71/php.d/20-curl.ini,
/etc/opt/rh/rh-php71/php.d/20-dba.ini,
/etc/opt/rh/rh-php71/php.d/20-dom.ini,
/etc/opt/rh/rh-php71/php.d/20-enchant.ini,
/etc/opt/rh/rh-php71/php.d/20-exif.ini,
/etc/opt/rh/rh-php71/php.d/20-fileinfo.ini,
/etc/opt/rh/rh-php71/php.d/20-ftp.ini,
/etc/opt/rh/rh-php71/php.d/20-gd.ini,
/etc/opt/rh/rh-php71/php.d/20-gettext.ini,
/etc/opt/rh/rh-php71/php.d/20-iconv.ini,
/etc/opt/rh/rh-php71/php.d/20-imap.ini,
/etc/opt/rh/rh-php71/php.d/20-intl.ini,
/etc/opt/rh/rh-php71/php.d/20-json.ini,
/etc/opt/rh/rh-php71/php.d/20-ldap.ini,
/etc/opt/rh/rh-php71/php.d/20-mbstring.ini,
/etc/opt/rh/rh-php71/php.d/20-mcrypt.ini,
/etc/opt/rh/rh-php71/php.d/20-mysqlnd.ini,
/etc/opt/rh/rh-php71/php.d/20-odbc.ini,
/etc/opt/rh/rh-php71/php.d/20-pdo.ini,
/etc/opt/rh/rh-php71/php.d/20-pgsql.ini,
/etc/opt/rh/rh-php71/php.d/20-phar.ini,
/etc/opt/rh/rh-php71/php.d/20-posix.ini,
/etc/opt/rh/rh-php71/php.d/20-pspell.ini,
/etc/opt/rh/rh-php71/php.d/20-recode.ini,
/etc/opt/rh/rh-php71/php.d/20-shmop.ini,
/etc/opt/rh/rh-php71/php.d/20-simplexml.ini,
/etc/opt/rh/rh-php71/php.d/20-snmp.ini,
/etc/opt/rh/rh-php71/php.d/20-soap.ini,
/etc/opt/rh/rh-php71/php.d/20-sockets.ini,
/etc/opt/rh/rh-php71/php.d/20-sqlite3.ini,
/etc/opt/rh/rh-php71/php.d/20-sysvmsg.ini,
/etc/opt/rh/rh-php71/php.d/20-sysvsem.ini,
/etc/opt/rh/rh-php71/php.d/20-sysvshm.ini,
/etc/opt/rh/rh-php71/php.d/20-tidy.ini,
/etc/opt/rh/rh-php71/php.d/20-tokenizer.ini,
/etc/opt/rh/rh-php71/php.d/20-xml.ini,
/etc/opt/rh/rh-php71/php.d/20-xmlwriter.ini,
/etc/opt/rh/rh-php71/php.d/20-xsl.ini,
/etc/opt/rh/rh-php71/php.d/20-zip.ini,
/etc/opt/rh/rh-php71/php.d/30-mysqli.ini,
/etc/opt/rh/rh-php71/php.d/30-pdo_mysql.ini,
/etc/opt/rh/rh-php71/php.d/30-pdo_odbc.ini,
/etc/opt/rh/rh-php71/php.d/30-pdo_pgsql.ini,
/etc/opt/rh/rh-php71/php.d/30-pdo_sqlite.ini,
/etc/opt/rh/rh-php71/php.d/30-wddx.ini,
/etc/opt/rh/rh-php71/php.d/30-xmlreader.ini,
/etc/opt/rh/rh-php71/php.d/30-xmlrpc.ini,
/etc/opt/rh/rh-php71/php.d/40-amqp.ini,
/etc/opt/rh/rh-php71/php.d/40-apcu.ini,
/etc/opt/rh/rh-php71/php.d/40-apfd.ini,
/etc/opt/rh/rh-php71/php.d/40-geoip.ini,
/etc/opt/rh/rh-php71/php.d/40-igbinary.ini,
/etc/opt/rh/rh-php71/php.d/40-imagick.ini,
/etc/opt/rh/rh-php71/php.d/40-lzf.ini,
/etc/opt/rh/rh-php71/php.d/40-msgpack.ini,
/etc/opt/rh/rh-php71/php.d/40-propro.ini,
/etc/opt/rh/rh-php71/php.d/40-raphf.ini,
/etc/opt/rh/rh-php71/php.d/40-selinux.ini,
/etc/opt/rh/rh-php71/php.d/40-uploadprogress.ini,
/etc/opt/rh/rh-php71/php.d/40-uuid.ini,
/etc/opt/rh/rh-php71/php.d/40-xattr.ini,
/etc/opt/rh/rh-php71/php.d/50-apc.ini,
/etc/opt/rh/rh-php71/php.d/50-http.ini,
/etc/opt/rh/rh-php71/php.d/50-memcached.ini,
/etc/opt/rh/rh-php71/php.d/50-mongodb.ini,
/etc/opt/rh/rh-php71/php.d/50-redis.ini,
/etc/opt/rh/rh-php71/php.d/50-solr.ini
</code></pre></div></div>
<h1 id="additional-steps">Additional Steps</h1>
<p>There are some things that I’ve found make using the RedHat PHP 7.1.x SCL packages and upgrading existing code bases a little easier. <em>The following steps are <strong>OPTIONAL</strong>, but recommended.</em></p>
<h2 id="to-avoid-potential-conflict-ensure-the-centos-base-httpd-is-stopped-disabled-and-completely-removed-from-the-system">To avoid potential conflict, ensure the CentOS base httpd is stopped, disabled, and completely removed from the system.</h2>
<p><strong><em>I’d strongly recommend removing the CentOS base php & httpd.</em></strong> Having the base packages on the system, with SCL packages, can cause confusion. Although, to be fair, it’s possible as long as both httpd installs are configured to use different interfaces and/or ports.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>systemctl stop httpd
<span class="nb">sudo </span>systemctl disable httpd
</code></pre></div></div>
<p>It’s also important to note that, by default and because, both base & SCL httpd packages are configured to bind to all interfaces on port 80 (& port 443 if mod_ssl is installed). As a result, only one at a time will start successfully. If you’re not doing this then I’m sure you know what I mean & how to fix that.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>yum remove httpd httpd-tools php<span class="k">*</span>
</code></pre></div></div>
<h2 id="create-a-custom-systemd-httpdservice-file">Create a custom systemd httpd.service file.</h2>
<p>This will allow for a normal Enterprise Linux administrative ‘feel’ and retain functionality such as <code class="language-plaintext highlighter-rouge">systemctl restart httpd</code>. It will also override the default CentOS base httpd (if it exists on the system) and allow for local customizations. It’s helpful to me, sometimes.</p>
<p>The tendency for both httpd & httpd24 to use the same ports can be frustrating, especially for web developers who are unfamiliar with SCL. Ultimately, I’d recommend this and <strong><em>I do not recommend having both of the CentOS base httpd & SCL httpd24 on the same system</em></strong>. Nevertheless, if you do this then remember to run <code class="language-plaintext highlighter-rouge">systemctl daemon-reload</code> after creating /etc/systemd/system/httpd.service</p>
<h3 id="etcsystemdsystemhttpdservice">/etc/systemd/system/httpd.service</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cat <<EOF > /etc/systemd/system/httpd.service
[Unit]
Description=The RedHat Software Collections Library (SCL) Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper \$OPTIONS -DFOREGROUND
ExecReload=/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper \$OPTIONS -k graceful
ExecStop=/bin/kill -WINCH \${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
</code></pre></div></div>
<p>After creating or updating /etc/systemd/system/httpd.service then systemd needs to be reloaded. This, or a reboot, is mandatory every time a custom /etc/systemd service file is modified.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>systemctl daemon-reload <span class="c"># important!</span>
<span class="nb">sudo </span>systemctl status httpd
</code></pre></div></div>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>● httpd.service - The RedHat Software Collections (SCL) Apache HTTP Server
Loaded: loaded (/etc/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:httpd(8)
man:apachectl(8)
</code></pre></div></div>
<h2 id="create-or-modify-the-systemctl-environmentfile-for-httpdservice">Create (or modify) the systemctl EnvironmentFile for httpd.service</h2>
<p>Doing this will cause the SCL httpd24 to re-use the familiar <code class="language-plaintext highlighter-rouge">/etc/httpd</code> structure (rather than what’s in <code class="language-plaintext highlighter-rouge">/opt/rh/httpd24/root/etc/httpd</code>).</p>
<h3 id="etcsysconfighttpd">/etc/sysconfig/httpd</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cat <<EOF > /etc/sysconfig/httpd
OPTIONS="-d /etc/httpd"
LANG=C
EOF
chmod 644 /etc/sysconfig/httpd
</code></pre></div></div>
<h2 id="copy-the-httpd24-files-to-etchttpd-and-modify-them">Copy the httpd24 files to /etc/httpd and modify them.</h2>
<p><strong><em>PAY MORE ATTENTION TO THE FINAL CONFIGURATIONS THAN IS OUTLINED HERE.</em></strong></p>
<p>If using <code class="language-plaintext highlighter-rouge">/etc/httpd</code>, then be sure to update the contents of <code class="language-plaintext highlighter-rouge">/etc/httpd</code> to reflect what’s in <code class="language-plaintext highlighter-rouge">/opt/rh/httpd24/root/etc/httpd</code>. I typically move the old /etc/httpd out of the way, rsync the SCL configs, and then modify what’s in <code class="language-plaintext highlighter-rouge">/etc/httpd</code> because that preserves the integrity of the SCL packaged configs.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="o">[</span> <span class="nt">-d</span> /etc/httpd <span class="o">]</span> <span class="o">&&</span> <span class="o">[</span> <span class="o">!</span> <span class="nt">-d</span> /etc/httpd.base <span class="o">]</span><span class="p">;</span> <span class="k">then</span> <span class="o">(</span><span class="nb">mv</span> /etc/httpd /etc/httpd.base<span class="o">)</span><span class="p">;</span> <span class="k">fi</span> <span class="c"># artifacts may exist, e.q. conf.d/squid.conf</span>
<span class="k">if</span> <span class="o">[</span> <span class="o">!</span> <span class="nt">-f</span> /etc/httpd/conf/httpd.conf <span class="o">]</span><span class="p">;</span> <span class="k">then</span> <span class="o">(</span>rsync <span class="nt">-avp</span> /opt/rh/httpd24/root/etc/httpd/ /etc/httpd/<span class="o">)</span><span class="p">;</span> <span class="k">fi</span> <span class="c"># don't accidentally overwrite httpd.conf (et al)</span>
</code></pre></div></div>
<p>For new installs, I typically prefer <code class="language-plaintext highlighter-rouge">/var/www</code> as a starting point for <em>DocumentRoot</em>. It’s also important that the <em>ServerRoot</em> directive is changed in <code class="language-plaintext highlighter-rouge">httpd.conf</code>, to reference <code class="language-plaintext highlighter-rouge">/etc/httpd</code>, so that the correct config structure is used.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">for </span>httpd24_conf <span class="k">in</span> <span class="si">$(</span>find /etc/httpd <span class="nt">-type</span> f | xargs <span class="nb">grep</span> <span class="nt">-l</span> <span class="s2">"/opt/rh/httpd24/root"</span><span class="si">)</span><span class="p">;</span> <span class="k">do </span><span class="nb">echo</span> <span class="nv">$httpd24_conf</span><span class="p">;</span> <span class="nb">sed</span> <span class="nt">-i</span> <span class="nt">-e</span> <span class="s1">'s#/opt/rh/httpd24/root/etc#/etc#g'</span> <span class="nt">-e</span> <span class="s1">'s#/opt/rh/httpd24/root/var/www#/var/www#g'</span> <span class="nv">$httpd24_conf</span><span class="p">;</span> <span class="k">done</span>
</code></pre></div></div>
<p>I also prefer the standard <code class="language-plaintext highlighter-rouge">/var/log/httpd</code> directory for logs, and usually ensure the <code class="language-plaintext highlighter-rouge">/etc/httpd/logs</code> link points there.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">rm</span> /etc/httpd/logs <span class="o">&&</span> <span class="nb">ln</span> <span class="nt">-s</span> /var/log/httpd /etc/httpd/logs
</code></pre></div></div>
<p>This can also be helpful, if for nothing more than preserving the original SCL config. After years and years of <code class="language-plaintext highlighter-rouge">/etc/php.ini</code>, it’s become finger memory for many. It’s hard coded into lots of stuff that looks for it here, too.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="o">[</span> <span class="o">!</span> <span class="nt">-f</span> /etc/php.ini <span class="o">]</span><span class="p">;</span> <span class="k">then</span> <span class="o">(</span><span class="nb">cp</span> /etc/opt/rh/rh-php71/php.ini /etc/php.ini<span class="o">)</span><span class="p">;</span> <span class="k">fi</span> <span class="c"># don't accidentally overwrite php.ini</span>
<span class="nb">grep</span> <span class="nt">-q</span> <span class="nt">-i</span> <span class="nt">-F</span> <span class="s1">'^PHPIniDir'</span> /etc/httpd/conf.d/rh-php71-php.conf <span class="o">||</span> <span class="o">(</span><span class="nb">echo</span><span class="p">;</span> <span class="nb">echo</span> <span class="s1">'PHPIniDir /etc/php.ini'</span><span class="o">)</span> <span class="o">>></span> /etc/httpd/conf.d/rh-php71-php.conf
</code></pre></div></div>
<h2 id="on-development-machines-that-may-be-building-cc-packages-that-require-installed-php-headers-install-the-corresponding-devel-packages">On development machines that may be building C/C++ packages that require installed php headers, install the corresponding devel packages.</h2>
<p>These are usually not needed (or recommended) on production systems.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>yum install rh-php71-php-devel rh-php71-php-pecl-apcu-devel rh-php71-scldevel sclo-php71-php-pecl-http-devel sclo-php71-php-pecl-igbinary-devel sclo-php71-php-pecl-imagick-devel sclo-php71-php-pecl-msgpack-devel sclo-php71-php-pecl-propro-devel sclo-php71-php-pecl-raphf-devel
</code></pre></div></div>
<h2 id="update-systemd-then-enable-start-and-check-the-status-of-httpd24-htcacheclean--httpd24-httpd-andor-httpd">Update systemd then enable, start, and check the status of httpd24-htcacheclean & httpd24-httpd (and/or httpd).</h2>
<p>The CentOS base only contains a single service named <em>httpd</em>, whereas the SCL httpd24 package contains two services, <em>httpd24-htcacheclean</em> and <em>httpd24-httpd</em>. If you’ve gotten this far then the following depends on whether or not a custom <em>httpd</em> service was added (above). Again, I usually use a custom httpd.service.</p>
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>systemctl daemon-reload <span class="c"># can't hurt!</span>
<span class="nb">sudo </span>systemctl <span class="nb">enable </span>httpd24-htcacheclean
<span class="nb">sudo </span>systemctl start httpd24-htcacheclean
<span class="nb">sudo </span>systemctl status httpd-htcacheclean
<span class="nb">sudo </span>systemctl <span class="nb">enable </span>httpd <span class="c"># or, httpd24-http</span>
<span class="nb">sudo </span>systemctl start httpd <span class="c"># or, httpd24-http</span>
<span class="nb">sudo </span>systemctl status httpd <span class="c"># or, httpd24-http</span>
</code></pre></div></div>
<p>This is mostly for any other binaries that may be installed, that depend on the shared SCL libraries. For them to always work properly with the RedHat SCL packages, then the following files should be configured manually. Anything compiled and linked with ld will find them.</p>
<h2 id="add-the-rh-php71-shared-library-directories-to-the-ld-linker-search-path-via-etcldsoconfdrh-php71conf">Add the rh-php71 shared library directories to the ld linker search path via /etc/ld.so.conf.d/rh-php71.conf</h2>
<h3 id="etcldsoconfdrh-php71conf">/etc/ld.so.conf.d/rh-php71.conf</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/opt/rh/rh-php71/root/usr/lib64
/opt/rh/httpd24/root/usr/lib64
/opt/rh/rh-php71/root/usr/lib
/opt/rh/httpd24/root/usr/lib
</code></pre></div></div>
<h3 id="prefix-the-rh-php71-binary-directories-to-all-login-paths-via-etcprofiledzzzz-sclsh">Prefix the rh-php71 binary directories to all login PATHs via /etc/profile.d/zzzz-scl.sh</h3>
<p>This is may be helpful. Naming a profile.d include ‘zzzz-scl.sh’ will ensure it gets loaded last. Existing <strong>PATH</strong>s should be appended & preserved.</p>
<h4 id="etcprofiledzzzz-sclsh">/etc/profile.d/zzzz-scl.sh</h4>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="o">[</span> <span class="nt">-d</span> /opt/rh/ <span class="o">]</span> <span class="o">&&</span> <span class="o">[</span> <span class="nt">-r</span> /opt/rh/ <span class="o">]</span><span class="p">;</span> <span class="k">then
</span><span class="nv">Rhscl_Roots</span><span class="o">=</span><span class="si">$(</span>find /opt/rh/ <span class="nt">-type</span> f <span class="nt">-name</span> <span class="nb">enable </span>2> /dev/null | <span class="nb">sort</span> <span class="nt">-V</span><span class="si">)</span>
<span class="k">for </span>Rhscl_Enable <span class="k">in</span> <span class="nv">$Rhscl_Roots</span><span class="p">;</span> <span class="k">do
if</span> <span class="o">[</span> <span class="nt">-r</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
<span class="nb">.</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span>
<span class="k">else
continue
fi
</span><span class="nv">Rhscl_Root</span><span class="o">=</span><span class="s2">"</span><span class="si">$(</span><span class="nb">dirname</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span><span class="si">)</span><span class="s2">/root"</span>
<span class="nv">Rhscl_Bins</span><span class="o">=</span><span class="s2">"usr/bin usr/sbin bin sbin"</span>
<span class="k">for </span>Rhscl_Bin <span class="k">in</span> <span class="nv">$Rhscl_Bins</span><span class="p">;</span> <span class="k">do
if</span> <span class="o">[</span> <span class="nt">-d</span> <span class="s2">"</span><span class="nv">$Rhscl_Root</span><span class="s2">/</span><span class="nv">$Rhscl_Bin</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then
</span>Scl_Path+<span class="o">=</span><span class="s2">"</span><span class="nv">$Rhscl_Root</span><span class="s2">/</span><span class="nv">$Rhscl_Bin</span><span class="s2">:"</span>
<span class="k">fi
done
</span><span class="nb">unset </span>Rhscl_Bin Rhscl_Bins Rhscl_Enable Rhscl_Root
<span class="k">done
</span><span class="nb">unset </span>Rhscl_Roots
<span class="k">fi
</span><span class="nb">export </span><span class="nv">PATH_SCL</span><span class="o">=</span><span class="nv">$Scl_Path</span>
<span class="nb">export </span><span class="nv">PATH</span><span class="o">=</span><span class="k">${</span><span class="nv">PATH_SCL</span><span class="k">}</span>:<span class="nv">$PATH</span>
</code></pre></div></div>
<h1 id="caveats">Caveats</h1>
<p><em>The following information may be helpful.</em></p>
<p>Many packages, programs, & utilities (and people) expect the default CentOS 7 filesystem locations for associated files. The RedHat SCL packages relocate everything to <code class="language-plaintext highlighter-rouge">/opt/rh/</code>.</p>
<ul>
<li>
<p>On CentOS 7 machines with <em>only</em> rh-php-7.1 installed, it may be easiest to use a symbolic link. However, it should <strong>not</strong> be done on machines that choose to have the default php and scl php co-exist on the same machine.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ln -s /opt/rh/rh-php71/root/usr/bin/php /usr/bin/php
</code></pre></div> </div>
</li>
<li>
<p>Best practice, for shell scripts in general, is to use the <code class="language-plaintext highlighter-rouge">/usr/bin/env <processor></code> directives rather than hard coding something like <code class="language-plaintext highlighter-rouge">#!/usr/bin/php</code>. This is a good practice.</p>
<p><code class="language-plaintext highlighter-rouge">#!/usr/bin/env php</code></p>
</li>
<li>
<p>Here’s a quick one liner to find all files from the current directory that contain <code class="language-plaintext highlighter-rouge">/bin/php</code>; they may need to be changed to <code class="language-plaintext highlighter-rouge">#!/usr/bin/env php</code> (rather than relying on a symbolic link).</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> find . -type f | xargs grep -l "/bin/php"
</code></pre></div> </div>
</li>
</ul>
<h1 id="disclaimer">Disclaimer</h1>
<p><strong>Many SCL packages are available and may have been installed if you’re blindly copy/pasting the commands in this guide. Some are ‘rh’ (maintained by RedHat), while others are ‘sclo’ (maintained by the Software Collections organization [not RedHat]). Some are required & others may not be needed.</strong></p>
<p><strong>Jumping into php 7 will enable some newer things to work, but if it isn’t broke, then why fix it? The reality is that php 5.4 has been around for a long time and by now is very stable. It’s still supported by RedHat and will be for many more years.</strong></p>
<p><strong>Or, if & when you’re paranoid about security; I’d recommend sticking with the CentOS 7 base php 5.4 & trust RedHat and the CentOS community. Long term stability and security updates are the main reason a lot of us use RedHat or derivitives like CentOS, anyway.</strong></p>
<h1 id="references">References</h1>
<ul>
<li><a href="https://access.redhat.com/solutions/2662201">https://access.redhat.com/solutions/2662201</a></li>
<li><a href="http://wiki.centos.org/SpecialInterestGroup/SCLo">http://wiki.centos.org/SpecialInterestGroup/SCLo</a></li>
<li><a href="https://www.softwarecollections.org/en/">https://www.softwarecollections.org/en/</a></li>
<li><a href="https://access.redhat.com/security/updates/backporting">https://access.redhat.com/security/updates/backporting</a></li>
</ul>Joseph TingirisThis is a functional reference guide for Enterprise Linux, specifically CentOS 7, that attempts to provide a straightforward procedure for producing a highly functional, stable, and modern LAMP 7 stack (i.e. HOWTO).Neo(vim)2017-10-22T13:02:33+00:002017-10-22T13:02:33+00:00https://josephtingiris.github.io/howto/install/neovim/centos%207/2017/10/22/neovim-on-centos-7<h1 id="another-holy-war">Another holy war?</h1>
<p>There are countless text editors out there, and I know programming languages and programmers. They’re fiercely loyal to their favorites. The <a href="https://en.wikipedia.org/wiki/Editor_war">editor war</a> has been going on since the 70’s.</p>
<p>Like it or not; If you’re a computer professional then you will eventually have to learn something about <a href="https://en.wikipedia.org/wiki/Vi">vi</a> or <a href="https://en.wikipedia.org/wiki/Emacs">emacs</a>. They share <a href="http://www.slate.com/articles/technology/bitwise/2014/05/oldest_software_rivalry_emacs_and_vi_two_text_editors_used_by_programmers.html">The Oldest Rivalry in Computing</a>.</p>
<p>Most people either love them or hate them. I think the latter gave rise to the use of a plethora of other editors such as <a href="https://en.wikipedia.org/wiki/Pico_(text_editor)">pico</a>, <a href="https://en.wikipedia.org/wiki/GNU_nano">nano</a>, and the ever expanding choices of more modern <a href="https://en.wikipedia.org/wiki/Integrated_development_environment">IDEs</a>.</p>
<p>This post is really about setting up and using <a href="https://github.com/neovim/neovim">neovim</a> on <a href="https://www.centos.org/">CentOS 7</a>. I’m both excited and tentative at the thought. I spend a considerable amount of time in an editor, particularly vim, and this is a topic that interests me.</p>
<h1 id="but-ide-x-is-so-great">But IDE X is so great!</h1>
<p>The problem, for someone like me, is that it takes quality time to learn how to use an editor proficiently. It takes even more time to integrate it with different development environments. Constantly switching from one set of tools to another can be extremely time consuming.</p>
<p>If you’ve ever been stuck working on a machine without <em>your</em> editor then you know where I’m coming from. Like so many others, I had to learn vi out of necessity (and because it is way better than ed). While I’ve used emacs for some time too, and fully recognize there are many others, none are as ever-present as vi.</p>
<p>I program a lot, in different languages. Throughout the course of my life & career I’ve used countless IDEs. Most focus on a single language very well and few cater to a polyglot. They can be good, or bad, depending on your point of view and what you want to do.</p>
<p>Personally, I find it extremely cumbersome to be required to use a mouse. It’s akin to torture; <a href="https://en.wikipedia.org/wiki/Carpal_tunnel_syndrome">Carpal tunnel syndrome</a> is real and yes, I feel it. To this day, for any number of reasons, I still find myself going back to vi(m) for a large portion of what I do on a daily basis.</p>
<p>Honestly, I’ve preferred using <a href="http://www.vim.org/">vim</a> for decades. It’s like the lowest common denominator; It’s always there. It rarely changes. The vim plugin/script ecosystem is constantly growing. The community never ceases to amaze me.</p>
<p>Yet, I still find myself checking out other IDEs and migrating to the newer ones like <a href="https://atom.io/">atom</a> and <a href="https://www.sublimetext.com/">sublime</a>. Like others, surely, I’m still searching for <strong><em><a href="http://matrix.wikia.com/wiki/The_One">The One</a></em></strong> IDE that can handle all <strong><em><a href="http://matrix.wikia.com/wiki/The_Source">The Source</a></em></strong></p>
<p>Either <strong>neovim</strong> is very cleverly named, or the author really likes <strong><em>The Matrix</em></strong>.</p>
<p>Or maybe …</p>
<p><img src="http://www.memebucket.com/mb/2012/08/What-If-Neo-Is-Not-The-One-852.png" alt="neo is not the one" /></p>
<p>… I’m just having fun with it. :lol:</p>
<p>The <a href="https://gitter.im/neovim/neovim">neovim glitter</a> referred me here when I asked. https://en.wiktionary.org/wiki/neo-</p>
<p>So, I guess it’s <strong><em>newvim</em></strong></p>
<p>Seriously. For the most part, <a href="http://www.vim.org/">vim</a> with <a href="http://www.vim.org/scripts/">scripts</a> is a very capable IDE for most programming languages. Configured appropriately, vim is far from a ‘simple’ text editor like vi. The <a href="http://www.vim.org/about">about</a> page describes it like this. <em>Vim is an advanced text editor that seeks to provide the power of the de-facto Unix editor ‘Vi’, with a more complete feature set.</em></p>
<p>It also says, this.<br />
Most of the machines I’ve been working with lately are x86_64 CentOS or RHEL 7. Many are production servers that were installed with the <a href="https://www.centos.org/download/">Minimal ISO</a>. While it’s not entirely obvious (or easy to search), mounting the <a href="http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1708.iso]">latest ISO</a> readily confirms the <strong>only</strong> editor that’s installable is <em>vim-minimal</em>. I’ve also encountered this working in initrd and initramfs environments. It’s been that way for years.</p>
<p>So, the writing is on the minimal Linux wall. The traditional editor ‘holy war’ is over. vi(m) won.</p>
<p>Frankly, I’ll probably be programming as long as I can type because I love it. I’ve still got at least another 15+ years until I can retire. I also hope the next generation(s) of programmers will build on and improve what’s been built before us.</p>
<p>About every year, or so, I take a look at the current state of the IDE and what’s available. Neovim is pretty cool. It’s definitely a step up from vim-enhanced.</p>Joseph TingirisAnother holy war?Installing and building an existing project with npm and grunt on CentOS 72017-10-17T01:01:19+00:002017-10-21T22:37:19+00:00https://josephtingiris.github.io/centos%207/npm/grunt/2017/10/17/centos-7-npm-grunt<p>This is the <em>basic</em> process to install and build an existing GRUNT project with npm on CentoOS 7.</p>
<ol>
<li>
<p>Install npm via CentOS EPEL</p>
<p><a href="https://www.npmjs.com/">npm</a> is the package manager for JavaScript</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> yum install epel-release npm
</code></pre></div> </div>
</li>
<li>
<p>Set your npm prefix to somewhere you have write access to <em>bin</em>, <em>etc</em>, & <em>lib</em>. The <em>bin</em> directory should be in your $PATH, i.e.</p>
<p><strong>It is <em>not</em> recommended to run npm as root.</strong></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> npm config set prefix '~/'
export PATH=~/bin:$PATH
</code></pre></div> </div>
</li>
<li>
<p>Install GRUNT</p>
<p><a href="https://gruntjs.com/">GRUNT</a> is the JavaScript Task Runner</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> npm install -g grunt-cli
</code></pre></div> </div>
</li>
<li>
<p>Install project_dir</p>
<p>A typical GRUNT project has a <code class="language-plaintext highlighter-rouge">package.json</code> and a <code class="language-plaintext highlighter-rouge">Gruntfile.js</code> in a <code class="language-plaintext highlighter-rouge">project_dir</code>, i.e.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> cd project_dir
npm install
grunt
</code></pre></div> </div>
</li>
</ol>Joseph TingirisThis is the basic process to install and build an existing GRUNT project with npm on CentoOS 7.GitHub Metadata: No GitHub API authentication could be found. Some fields may be missing or have incorrect data.2017-10-15T22:00:12+00:002017-10-15T22:18:18+00:00https://josephtingiris.github.io/jekyll/github/metadata/2017/10/15/no-github-api-authentication-could-be-found<p>Here’s a solution to fix issues like this …</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ bundle exec jekyll serve
Configuration file: /home/jtingiris/src/josephtingiris.github.io/_config.yml
Source: /home/jtingiris/src/josephtingiris.github.io
Destination: /home/jtingiris/src/josephtingiris.github.io/_site
Incremental build: disabled. Enable with --incremental
Generating...
GitHub Metadata: No GitHub API authentication could be found. Some fields may be missing or have incorrect data.
done in 16.628 seconds.
Auto-regeneration: enabled for '/home/jtingiris/src/josephtingiris.github.io'
Server address: http://127.0.0.1:4000
Server running... press ctrl-c to stop.
</code></pre></div></div>
<ol>
<li>
<p>Create a GiHub personal acces token with only the <code class="language-plaintext highlighter-rouge">public_repo</code> scope selectd. Here’s the <a href="https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/">GitHub Guide</a></p>
</li>
<li>
<p>Make sure to copy the token now. It wont be shown again. If you loose it then you’ll have to create a new one.</p>
</li>
<li>Export the token as an environment variable, e.g. via .bashrc. i.e.
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>export JEKYLL_GITHUB_TOKEN=330103c2f8b25f4a3301b5be3e0f56371a133301
</code></pre></div> </div>
</li>
<li>Verify the token is in your environment, i.e.
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>echo $JEKYLL_GITHUB_TOKEN
</code></pre></div> </div>
</li>
<li>Alternatively, you can use it inline, e.g.
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>JEKYLL_GITHUB_TOKEN=330103c2f8b25f4a3301b5be3e0f56371a133301 bundle exec jekyll serve
</code></pre></div> </div>
</li>
</ol>
<p>All said and done, jekyll should serve without warning.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ bundle exec jekyll serve
Configuration file: /home/jtingiris/src/josephtingiris.github.io/_config.yml
Source: /home/jtingiris/src/josephtingiris.github.io
Destination: /home/jtingiris/src/josephtingiris.github.io/_site
Incremental build: disabled. Enable with --incremental
Generating...
done in 20.059 seconds.
Auto-regeneration: enabled for '/home/jtingiris/src/josephtingiris.github.io'
Server address: http://127.0.0.1:4000
Server running... press ctrl-c to stop.
</code></pre></div></div>Joseph TingirisHere’s a solution to fix issues like this … $ bundle exec jekyll serve Configuration file: /home/jtingiris/src/josephtingiris.github.io/_config.yml Source: /home/jtingiris/src/josephtingiris.github.io Destination: /home/jtingiris/src/josephtingiris.github.io/_site Incremental build: disabled. Enable with --incremental Generating... GitHub Metadata: No GitHub API authentication could be found. Some fields may be missing or have incorrect data. done in 16.628 seconds. Auto-regeneration: enabled for '/home/jtingiris/src/josephtingiris.github.io' Server address: http://127.0.0.1:4000 Server running... press ctrl-c to stop. Create a GiHub personal acces token with only the public_repo scope selectd. Here’s the GitHub Guide Make sure to copy the token now. It wont be shown again. If you loose it then you’ll have to create a new one. Export the token as an environment variable, e.g. via .bashrc. i.e. export JEKYLL_GITHUB_TOKEN=330103c2f8b25f4a3301b5be3e0f56371a133301 Verify the token is in your environment, i.e. echo $JEKYLL_GITHUB_TOKEN Alternatively, you can use it inline, e.g. JEKYLL_GITHUB_TOKEN=330103c2f8b25f4a3301b5be3e0f56371a133301 bundle exec jekyll serve All said and done, jekyll should serve without warning. $ bundle exec jekyll serve Configuration file: /home/jtingiris/src/josephtingiris.github.io/_config.yml Source: /home/jtingiris/src/josephtingiris.github.io Destination: /home/jtingiris/src/josephtingiris.github.io/_site Incremental build: disabled. Enable with --incremental Generating... done in 20.059 seconds. Auto-regeneration: enabled for '/home/jtingiris/src/josephtingiris.github.io' Server address: http://127.0.0.1:4000 Server running... press ctrl-c to stop.Highlight Test2017-07-19T00:00:00+00:002017-07-19T00:00:00+00:00https://josephtingiris.github.io/jekyll/highlight/2017/07/19/highlight-test<p>This is a highlight test.</p>
<h1 id="normal-block">Normal block</h1>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>alert('Hello World!');
</code></pre></div></div>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>print 'helloworld'
</code></pre></div></div>
<h1 id="highlight-block">Highlight block</h1>
<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">alert</span><span class="p">(</span> <span class="dl">'</span><span class="s1">Hello, world!</span><span class="dl">'</span> <span class="p">);</span>
</code></pre></div></div>
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">print</span> <span class="s">'helloworld'</span>
</code></pre></div></div>
<div class="language-ruby highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">def</span> <span class="nf">foo</span>
<span class="nb">puts</span> <span class="s1">'foo'</span>
<span class="k">end</span>
</code></pre></div></div>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="k">def</span> <span class="nf">foo</span>
<span class="nb">puts</span> <span class="s1">'foo'</span>
<span class="k">end</span></code></pre></figure>
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><table class="rouge-table"><tbody><tr><td class="gutter gl"><pre class="lineno">1
2
3
</pre></td><td class="code"><pre><span class="k">def</span> <span class="nf">foo</span>
<span class="nb">puts</span> <span class="s1">'foo'</span>
<span class="k">end</span>
</pre></td></tr></tbody></table></code></pre></figure>
<div class="language-c++ highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">#include <iostream>
</span>
<span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span>
<span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="n">arg1</span><span class="p">,</span> <span class="kt">int</span> <span class="n">arg2</span><span class="p">)</span>
<span class="p">{</span>
<span class="p">}</span>
<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
<span class="p">{</span>
<span class="n">string</span> <span class="n">str</span><span class="p">;</span>
<span class="n">foo</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">);</span>
<span class="n">cout</span> <span class="o"><<</span> <span class="s">"Hello World"</span> <span class="o"><<</span> <span class="n">endl</span><span class="p">;</span>
<span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>Joseph TingirisThis is a highlight test. Normal block alert('Hello World!'); print 'helloworld' Highlight block alert( 'Hello, world!' ); print 'helloworld' def foo puts 'foo' end def foo puts 'foo' end 1 2 3 def foo puts 'foo' end #include <iostream> using namespace std; void foo(int arg1, int arg2) { } int main() { string str; foo(1, 2); cout << "Hello World" << endl; return 0; }How to Download, Build, & Install Asterisk 13 on CentOS 72016-12-15T12:20:28+00:002017-12-22T16:30:00+00:00https://josephtingiris.github.io/howto/install/asterisk%2013/centos%207/2016/12/15/asterisk-13-on-centos-7<p>At the time this was written, Asterisk 13 is the current LTS (long term support) version.</p>
<h2 id="downloading-building--installing-asterisk-13">Downloading, Building, & Installing Asterisk 13</h2>
<p>The official documentation is here, <a href="https://wiki.asterisk.org/wiki/display/AST/Building+and+Installing+Asterisk">https://wiki.asterisk.org/wiki/display/AST/Building+and+Installing+Asterisk</a></p>
<p>This guide will primarily focus on downloading, building, customizing, and installing the most current version of Asterisk 13 on CentOS 7 with an open source G729 codec (that’s not supplied with Asterisk 13). Patching and/or rebuilding from Gerrit will be noted but are otherwise out of scope at this time.</p>
<h3 id="prepare">Prepare</h3>
<p>In addition to a C compiler, Asterisk 13 also requires some specific system libraries. Before Asterisk can be compiled, they must be installed. For more information, see <a href="https://wiki.asterisk.org/wiki/display/AST/System+Libraries">https://wiki.asterisk.org/wiki/display/AST/System+Libraries</a>.</p>
<p>To <em>run</em> the Asterisk 13 binaries compiled in this guide, on CentOS 7, <em>_only_</em> the following dependencies are actually required (i.e. an entire development environment is <em>not</em> required).</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>yum <span class="nb">install </span>epel-release audiofile bluez-libs corosynclib curl freetds gmime gnutls gsm haveged help2man iksemel iksemel-utils jack-audio-connection-kit jansson libcurl libedit libical libnl libogg libsq3 libsqlite3x libsrtp libtiff libtool-ltdl libvorbis libxml2 libxslt lua mysql-connector-odbc mysql-utilities ncurses neon net-snmp net-snmp-utils newt openssl opus opusfile opus-tools patch pjproject portaudio postgresql-libs radiusclient-ng sox soxr spandsp speex speex-tools sqlite sqlite2 unbound-libs unixODBC uuid wget xmlstarlet SDL
</code></pre></div></div>
<p><strong>In addition</strong> to the above packages, To <em>compile</em> Asterisk 13 on CentOS 7, the following yum command will install all of the necessary development dependencies.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>yum <span class="nb">install </span>audiofile-devel autoconf automake bluez-libs-devel cmake3 corosynclib-devel doxygen-latex freetds-devel gcc git gmime-devel gnutls-devel gsm-devel gtk2-devel haveged-devel iksemel-devel jack-audio-connection-kit-devel jansson-devel kernel-devel libcurl-devel libedit-devel libical-devel libnl-devel libogg-devel libsq3-devel libsqlite3x-devel libsrtp-devel libtiff-devel libtool-ltdl-devel libvorbis-devel libxml2-devel libxslt-devel lua-devel mysql-devel ncurses-devel neon-devel net-snmp-devel newt-devel openssl-devel opus-devel opusfile-devel patch pjproject-devel pkgconfig portaudio-devel postgresql-devel radiusclient-ng-devel sox-devel soxr-devel spandsp-devel speex-devel speex-tools sqlite2-devel sqlite-devel unbound-devel unixODBC-devel uuid-devel SDL-devel
</code></pre></div></div>
<p>This guide will depend on a couple of environment variables, to make the procedure repeatable with ‘copy/paste’. It’s assumed that these commands are run as <em>root</em>.</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">BUILD_DIR</span><span class="o">=</span>/usr/local/src/dps/build
<span class="nb">export </span><span class="nv">BUILD_PREFIX</span><span class="o">=</span>/opt/dps
<span class="c"># to start from scratch ...</span>
<span class="k">if</span> <span class="o">[</span> <span class="nt">-d</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then </span><span class="nb">mv</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">.</span><span class="si">$(</span><span class="nb">date</span> +%Y%m%d%H%M%S<span class="si">)</span><span class="s2">"</span> <span class="o">&&</span> <span class="nb">mkdir</span> <span class="nt">-p</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span><span class="p">;</span> <span class="k">fi
if</span> <span class="o">[</span> <span class="nt">-d</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then </span><span class="nb">mv</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">.</span><span class="si">$(</span><span class="nb">date</span> +%Y%m%d%H%M%S<span class="si">)</span><span class="s2">"</span> <span class="o">&&</span> <span class="nb">mkdir</span> <span class="nt">-p</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span><span class="p">;</span> <span class="k">fi</span>
</code></pre></div></div>
<h3 id="download-the-current-version-of-asterisk-13-choose-a-download-method">Download the current version of Asterisk 13; choose a download method</h3>
<p>There are a couple choices to get the source code from digium. For the sake of simplicity, the public tar download repository is easier to work from and sufficicent for most new builds. Maintaining concurrent builds and/or patching previous builds is possible but usually unnecessary. I’d recommend just starting from scratch each time.</p>
<h5 id="the-public-tar-download-repository-for-asterisk-source-is-available-here">The public tar download repository for asterisk source, is available here:</h5>
<p><a href="http://downloads.asterisk.org/pub/telephony/asterisk/">http://downloads.asterisk.org/pub/telephony/asterisk/</a></p>
<p>For example, it is a good idea to download all files in an empty directory (even though they may not be used)</p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span>
wget http://downloads.asterisk.org/pub/telephony/asterisk/ChangeLog-13-current
wget http://downloads.asterisk.org/pub/telephony/asterisk/README-13-current
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current-patch.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current-patch.tar.gz.asc
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current-summary.html
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current-summary.txt
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.md5
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.sha1
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.sha256
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz.asc
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz <span class="c"># optional</span>
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-current.tar.gz <span class="c"># optional</span>
wget http://downloads.asterisk.org/pub/telephony/dahdi-tools/dahdi-tools-current.tar.gz <span class="c"># optional</span>
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
</code></pre></div></div>
<h5 id="the-semi-public-gerrit-repository-for-asterisk-revision-control-is-documented-here">The semi-public Gerrit repository for asterisk revision control, is documented here:</h5>
<p><a href="https://www.asterisk.org/downloads/source-code">https://www.asterisk.org/downloads/source-code</a></p>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c"># note; this is unnecessary if wget was used as above</span>
<span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span>
<span class="c"># git clone -b 13 http://gerrit.asterisk.org/asterisk asterisk-13</span>
</code></pre></div></div>
<h3 id="build-the-current-version-of-asterisk-13">Build the current version of Asterisk 13</h3>
<p>The following steps assume wget was used as described above.</p>
<h5 id="verify-asterisk-13-currenttargz-is-valid-compare-the-hashes-from-the-following-output">Verify asterisk-13-current.tar.gz is valid; compare the hashes from the following output</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span>
<span class="nb">cat </span>asterisk-13-current.sha256
<span class="nb">sha256sum </span>asterisk-13-current.tar.gz
</code></pre></div></div>
<h5 id="untar-asterisk-13-currenttargz-into-an-empty-directory">Untar asterisk-13-current.tar.gz into an empty directory</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span>
<span class="nb">tar </span>zxvf asterisk-13-current.tar.gz
</code></pre></div></div>
<h5 id="optional-build--install-dhadi-this-must-be-done-prior-to-building-libpri--asterisk-13">[OPTIONAL] Build & Install DHADI; this must be done prior to building LibPRI & Asterisk 13</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span>
<span class="nb">tar </span>zxvf dahdi-linux-complete-current.tar.gz
<span class="nb">cd </span>dahdi-linux-complete-<span class="k">*</span>
make distclean
<span class="nv">DESTDIR</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span> make <span class="nt">-C</span> linux all <span class="c"># NOTE: This builds ONLY the drivers for the CURRENT running kernel</span>
<span class="nv">DESTDIR</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span> make <span class="nt">-C</span> linux <span class="nb">install</span> <span class="c"># NOTE: This installs ONLY the drivers for the CURRENT running kernel, but NOT in /usr</span>
<span class="o">(</span><span class="nb">cd </span>tools <span class="o">&&</span> <span class="o">[</span> <span class="nt">-f</span> config.status <span class="o">]</span> <span class="o">||</span> ./configure <span class="nt">--prefix</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span> <span class="nt">--with-dahdi</span><span class="o">=</span>../linux<span class="o">)</span>
make <span class="nt">-C</span> tools all
make <span class="nt">-C</span> tools <span class="nb">install
</span>make <span class="nt">-C</span> tools config
</code></pre></div></div>
<h5 id="optional-build--install-libpri-this-must-done-prior-to-building-asterisk-13">[OPTIONAL] Build & Install LibPRI; this must done prior to building Asterisk 13</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span>
<span class="nb">tar </span>zxvf libpri-current.tar.gz
<span class="nb">cd </span>libpri-1<span class="k">*</span>
make clean
<span class="nv">DESTDIR</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span> <span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">"-L</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/lib -L</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/usr/lib"</span> <span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">"-I</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/include -I</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/usr/include"</span> make
<span class="nv">DESTDIR</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span> <span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">"-L</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/lib -L</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/usr/lib"</span> <span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">"-I</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/include -I</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/usr/include"</span> make <span class="nb">install</span>
</code></pre></div></div>
<h5 id="configure-asterisk-13-source">Configure Asterisk 13 source</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">/asterisk-13."</span><span class="k">*</span>
make distclean
./contrib/scripts/install_prereq install-unpackaged
./contrib/scripts/get_mp3_source.sh
<span class="nv">LDFLAGS</span><span class="o">=</span><span class="s2">"-L</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/lib -L</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/usr/lib"</span> <span class="nv">CFLAGS</span><span class="o">=</span><span class="s2">"-I</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/include -I</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">/usr/include"</span> ./configure <span class="nt">--with-pjproject-bundled</span> <span class="nt">--prefix</span><span class="o">=</span><span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span>
</code></pre></div></div>
<h5 id="select-asterisk-13-modules-that-will-be-compiled-and-check-dependencies-for-various-optional-modules">Select Asterisk 13 modules that will be compiled and check dependencies for various optional modules.</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">/asterisk-13."</span><span class="k">*</span>
make menuselect
</code></pre></div></div>
<p>This following are subjective; Typically, it may be useful to enable the following to be built, via menuselect. Or, automatically enabled via menuselect/menuselect, see <a href="https://wiki.asterisk.org/wiki/display/AST/Using+Menuselect+to+Select+Asterisk+Options">https://wiki.asterisk.org/wiki/display/AST/Using+Menuselect+to+Select+Asterisk+Options</a></p>
<h6 id="add-ons">Add-ons</h6>
<ul>
<li>chan_mobile</li>
<li>chan_ooh323</li>
<li>format_mp3</li>
<li>res_config_mysql</li>
<li>app_mysql</li>
<li>cdr_mysql</li>
</ul>
<h6 id="applications">Applications</h6>
<ul>
<li>app_fax</li>
<li>app_ivrdemo</li>
<li>app_meetme</li>
<li>app_saycounted</li>
<li>app_setcallerid</li>
</ul>
<h6 id="codec-translators">Codec Translators</h6>
<ul>
<li>codec_opus</li>
<li>codec_silk</li>
<li>codec_siren7</li>
<li>codec_siren14</li>
<li>DO NOT INSTALL CODEC g729a (it will be installed later)</li>
</ul>
<h6 id="resource-modules">Resource Modules</h6>
<ul>
<li>res_fax</li>
<li>res_mwi_external</li>
<li>res_mwi_external_ami</li>
<li>res_stasis_mailbox</li>
<li>res_chan_stats</li>
<li>res_corosync</li>
<li>res_endpoint_stats</li>
<li>res_fax_spandsp</li>
<li>res_pktccops</li>
<li>res_digium_phone</li>
</ul>
<h6 id="compiler-flags">Compiler Flags</h6>
<ul>
<li>G711_NEW_ALGORITHM</li>
<li>G711_REDUCED_BRANCHING</li>
</ul>
<h6 id="utilities">Utilities</h6>
<ul>
<li>aelparse</li>
<li>astman</li>
<li>check_expr</li>
<li>check_expr2</li>
<li>conf2ael</li>
<li>muted</li>
<li>smsq</li>
<li>stereorize</li>
<li>streamplayer</li>
</ul>
<h6 id="agi-samples">AGI Samples</h6>
<ul>
<li>jukebox.agi</li>
</ul>
<h6 id="core-sound-samples">Core Sound Samples</h6>
<ul>
<li><em>Select ALL</em> [for chosen language(s), e.g. EN & ES]</li>
</ul>
<h6 id="music-on-hold-file-packages">Music On Hold File Packages</h6>
<ul>
<li><em>Select ALL</em> [for chosen language(s), e.g. EN & ES]</li>
</ul>
<h6 id="extra-sound-packages">Extra Sound Packages</h6>
<ul>
<li><em>Select ALL</em> [for chosen language(s), e.g. EN & ES]</li>
</ul>
<h5 id="make-asterisk-13-core">Make Asterisk 13 (core)</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">/asterisk-13."</span><span class="k">*</span>
make
</code></pre></div></div>
<h5 id="install-asterisk-13-core">Install Asterisk 13 (core)</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">/asterisk-13."</span><span class="k">*</span>
make <span class="nb">install</span>
</code></pre></div></div>
<h5 id="make-asterisk-13-documentation">Make Asterisk 13 (documentation)</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">/asterisk-13."</span><span class="k">*</span>
make samples
make basic-pbx
make progdocs
</code></pre></div></div>
<h5 id="install-asterisk-13-documentation">Install Asterisk 13 (documentation)</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">/asterisk-13."</span><span class="k">*</span>
make <span class="nb">install</span>
</code></pre></div></div>
<h5 id="install-g729-codec">Install G729 codec</h5>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_PREFIX</span><span class="k">}</span><span class="s2">"</span>
<span class="k">if</span> <span class="o">[</span> <span class="nt">-d</span> lib64 <span class="o">]</span><span class="p">;</span> <span class="k">then </span><span class="nb">mv </span>lib64/<span class="k">*</span> lib/ <span class="o">&&</span> <span class="nb">rmdir </span>lib64<span class="p">;</span> <span class="k">fi
if</span> <span class="o">[</span> <span class="o">!</span> <span class="nt">-h</span> lib64 <span class="o">]</span><span class="p">;</span> <span class="k">then </span><span class="nb">ln</span> <span class="nt">-s</span> lib lib64<span class="p">;</span> <span class="k">fi
</span><span class="nb">cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span>
git clone git://git.linphone.org/bcg729.git
<span class="nb">cd </span>bcg729
make clean
<span class="nv">LDFLAGS</span><span class="o">=</span><span class="s1">'-L/opt/dps/lib -L/opt/dps/lib64'</span> cmake3 <span class="nb">.</span> <span class="nt">-DCMAKE_INSTALL_PREFIX</span><span class="o">=</span>/opt/dps
make
make <span class="nb">install
cd</span> <span class="s2">"</span><span class="k">${</span><span class="nv">BUILD_DIR</span><span class="k">}</span><span class="s2">"</span>
wget http://asterisk.hosting.lv/src/asterisk-g72x-1.4.2.tar.bz2
bunzip2 <span class="nt">-c</span> asterisk-g72x-1.4.2.tar.bz2 | <span class="nb">tar </span>xvf -
<span class="nb">cd </span>asterisk-g72x-1.4.2/
<span class="nv">LDFLAGS</span><span class="o">=</span><span class="s1">'-L/opt/dps/lib -L/opt/dps/lib64'</span> ./autogen.sh
make distclean
<span class="nv">LDFLAGS</span><span class="o">=</span><span class="s1">'-L/opt/dps/lib -L/opt/dps/lib64'</span> ./configure <span class="nt">--prefix</span><span class="o">=</span>/opt/dps <span class="nt">--with-bcg729</span>
make
make <span class="nb">install</span>
</code></pre></div></div>Joseph TingirisAt the time this was written, Asterisk 13 is the current LTS (long term support) version.How to install RedHat Software Collections Library PHP 7 on CentOS 72016-08-28T11:19:59+00:002017-10-21T20:03:00+00:00https://josephtingiris.github.io/howto/install/php%207/centos%207/2016/08/28/redhat-scl-php-7.0-on-centos-7<h1 id="ensure-httpd-is-stopped-and-disabled">Ensure httpd is stopped and disabled.</h1>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemctl stop httpd
systemctl disable httpd
</code></pre></div></div>
<h1 id="install-the-centos-epel--software-collections-library-scl-release-packages-clean--rebuild-the-yum-cache">Install the CentOS EPEL & Software Collections Library (scl) release packages, clean, & rebuild the yum cache.</h1>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>yum install epel-release centos-release-scl
yum clean all
yum makecache
</code></pre></div></div>
<h1 id="install-the-latest-redhat-scl-php-70--corresponding-dependent-httpd24-packages">Install the latest RedHat SCL php 7.0 & corresponding, dependent httpd24 packages.</h1>
<p>The following command installs the most commonly required php modules, as well.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>yum install rh-php70 rh-php70-php rh-php70-php-bcmath rh-php70-php-cli rh-php70-php-common rh-php70-php-dba rh-php70-php-embedded rh-php70-php-enchant rh-php70-php-fpm rh-php70-php-gd rh-php70-php-intl rh-php70-php-ldap rh-php70-php-mbstring rh-php70-php-mysqlnd rh-php70-php-odbc rh-php70-php-pdo rh-php70-php-pear rh-php70-php-pgsql rh-php70-php-process rh-php70-php-pspell rh-php70-php-recode rh-php70-php-snmp rh-php70-php-soap rh-php70-php-xml rh-php70-php-xmlrpc sclo-php70-php-imap sclo-php70-php-mcrypt sclo-php70-php-pecl-apcu sclo-php70-php-pecl-apcu-bc sclo-php70-php-pecl-memcached sclo-php70-php-tidy httpd24 httpd24-mod_ssl
</code></pre></div></div>
<h1 id="configure-the-necessary-operating-system-files">Configure the necessary operating system files.</h1>
<p>For <strong>'’bash’‘</strong>, <strong>'’crond’‘</strong>, & <strong>'’systemctl’‘</strong> to work properly with the RedHat SCL php 7 packages, the following files MUST be configured manually.</p>
<h4 id="etcldsoconfdrh-php70conf">/etc/ld.so.conf.d/rh-php70.conf</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>/opt/rh/rh-php70/root/usr/lib64
/opt/rh/httpd24/root/usr/lib64
/opt/rh/rh-php70/root/usr/lib
/opt/rh/httpd24/root/usr/lib
</code></pre></div></div>
<h4 id="etcprofiledzzzz-sclsh">/etc/profile.d/zzzz-scl.sh</h4>
<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="o">[</span> <span class="nt">-d</span> /opt/rh/ <span class="o">]</span> <span class="o">&&</span> <span class="o">[</span> <span class="nt">-r</span> /opt/rh/ <span class="o">]</span><span class="p">;</span> <span class="k">then
</span><span class="nv">Rhscl_Roots</span><span class="o">=</span><span class="si">$(</span>find /opt/rh/ <span class="nt">-type</span> f <span class="nt">-name</span> <span class="nb">enable </span>2> /dev/null | <span class="nb">sort</span> <span class="nt">-V</span><span class="si">)</span>
<span class="k">for </span>Rhscl_Enable <span class="k">in</span> <span class="nv">$Rhscl_Roots</span><span class="p">;</span> <span class="k">do
if</span> <span class="o">[</span> <span class="nt">-r</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then</span>
<span class="nb">.</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span>
<span class="k">else
continue
fi
</span><span class="nv">Rhscl_Root</span><span class="o">=</span><span class="s2">"</span><span class="si">$(</span><span class="nb">dirname</span> <span class="s2">"</span><span class="nv">$Rhscl_Enable</span><span class="s2">"</span><span class="si">)</span><span class="s2">/root"</span>
<span class="nv">Rhscl_Bins</span><span class="o">=</span><span class="s2">"usr/bin usr/sbin bin sbin"</span>
<span class="k">for </span>Rhscl_Bin <span class="k">in</span> <span class="nv">$Rhscl_Bins</span><span class="p">;</span> <span class="k">do
if</span> <span class="o">[</span> <span class="nt">-d</span> <span class="s2">"</span><span class="nv">$Rhscl_Root</span><span class="s2">/</span><span class="nv">$Rhscl_Bin</span><span class="s2">"</span> <span class="o">]</span><span class="p">;</span> <span class="k">then
</span>Scl_Path+<span class="o">=</span><span class="s2">"</span><span class="nv">$Rhscl_Root</span><span class="s2">/</span><span class="nv">$Rhscl_Bin</span><span class="s2">:"</span>
<span class="k">fi
done
</span><span class="nb">unset </span>Rhscl_Bin Rhscl_Bins Rhscl_Enable Rhscl_Root
<span class="k">done
</span><span class="nb">unset </span>Rhscl_Roots
<span class="k">fi
</span><span class="nb">export </span><span class="nv">PATH_SCL</span><span class="o">=</span><span class="nv">$Scl_Path</span>
</code></pre></div></div>
<h4 id="etcsystemdsystemhttpdservice">/etc/systemd/system/httpd.service</h4>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)
[Service]
Type=notify
EnvironmentFile=/opt/rh/httpd24/root/etc/sysconfig/httpd
ExecStart=/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper $OPTIONS -DFOREGROUND
ExecReload=/opt/rh/httpd24/root/usr/sbin/httpd-scl-wrapper $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
</code></pre></div></div>
<h1 id="enable-start-and-check-the-status-of-httpd">Enable, start, and check the status of httpd.</h1>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>systemctl daemon-reload # important!
systemctl enable httpd
systemctl start httpd
systemctl status httpd
</code></pre></div></div>
<h1 id="verify-locations-of-php-ini-files">Verify locations of php ini files.</h1>
<p><em>At this point, there should be a fully functional httpd 2.4 with php 7.0 (using the mysqlnd driver, etc).</em></p>
<p><code class="language-plaintext highlighter-rouge">php --ini</code></p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Configuration File (php.ini) Path: /etc/opt/rh/rh-php70
Loaded Configuration File: /etc/opt/rh/rh-php70/php.ini
Scan for additional .ini files in: /etc/opt/rh/rh-php70/php.d
Additional .ini files parsed: /etc/opt/rh/rh-php70/php.d/20-bcmath.ini,
/etc/opt/rh/rh-php70/php.d/20-bz2.ini,
/etc/opt/rh/rh-php70/php.d/20-calendar.ini,
/etc/opt/rh/rh-php70/php.d/20-ctype.ini,
/etc/opt/rh/rh-php70/php.d/20-curl.ini,
/etc/opt/rh/rh-php70/php.d/20-dba.ini,
/etc/opt/rh/rh-php70/php.d/20-dom.ini,
/etc/opt/rh/rh-php70/php.d/20-enchant.ini,
/etc/opt/rh/rh-php70/php.d/20-exif.ini,
/etc/opt/rh/rh-php70/php.d/20-fileinfo.ini,
/etc/opt/rh/rh-php70/php.d/20-ftp.ini,
/etc/opt/rh/rh-php70/php.d/20-gd.ini,
/etc/opt/rh/rh-php70/php.d/20-gettext.ini,
/etc/opt/rh/rh-php70/php.d/20-iconv.ini,
/etc/opt/rh/rh-php70/php.d/20-imap.ini,
/etc/opt/rh/rh-php70/php.d/20-intl.ini,
/etc/opt/rh/rh-php70/php.d/20-json.ini,
/etc/opt/rh/rh-php70/php.d/20-ldap.ini,
/etc/opt/rh/rh-php70/php.d/20-mbstring.ini,
/etc/opt/rh/rh-php70/php.d/20-mcrypt.ini,
/etc/opt/rh/rh-php70/php.d/20-mysqlnd.ini,
/etc/opt/rh/rh-php70/php.d/20-odbc.ini,
/etc/opt/rh/rh-php70/php.d/20-pdo.ini,
/etc/opt/rh/rh-php70/php.d/20-pgsql.ini,
/etc/opt/rh/rh-php70/php.d/20-phar.ini,
/etc/opt/rh/rh-php70/php.d/20-posix.ini,
/etc/opt/rh/rh-php70/php.d/20-pspell.ini,
/etc/opt/rh/rh-php70/php.d/20-recode.ini,
/etc/opt/rh/rh-php70/php.d/20-shmop.ini,
/etc/opt/rh/rh-php70/php.d/20-simplexml.ini,
/etc/opt/rh/rh-php70/php.d/20-snmp.ini,
/etc/opt/rh/rh-php70/php.d/20-soap.ini,
/etc/opt/rh/rh-php70/php.d/20-sockets.ini,
/etc/opt/rh/rh-php70/php.d/20-sqlite3.ini,
/etc/opt/rh/rh-php70/php.d/20-sysvmsg.ini,
/etc/opt/rh/rh-php70/php.d/20-sysvsem.ini,
/etc/opt/rh/rh-php70/php.d/20-sysvshm.ini,
/etc/opt/rh/rh-php70/php.d/20-tidy.ini,
/etc/opt/rh/rh-php70/php.d/20-tokenizer.ini,
/etc/opt/rh/rh-php70/php.d/20-xml.ini,
/etc/opt/rh/rh-php70/php.d/20-xmlwriter.ini,
/etc/opt/rh/rh-php70/php.d/20-xsl.ini,
/etc/opt/rh/rh-php70/php.d/20-zip.ini,
/etc/opt/rh/rh-php70/php.d/30-mysqli.ini,
/etc/opt/rh/rh-php70/php.d/30-pdo_mysql.ini,
/etc/opt/rh/rh-php70/php.d/30-pdo_odbc.ini,
/etc/opt/rh/rh-php70/php.d/30-pdo_pgsql.ini,
/etc/opt/rh/rh-php70/php.d/30-pdo_sqlite.ini,
/etc/opt/rh/rh-php70/php.d/30-wddx.ini,
/etc/opt/rh/rh-php70/php.d/30-xmlreader.ini,
/etc/opt/rh/rh-php70/php.d/30-xmlrpc.ini,
/etc/opt/rh/rh-php70/php.d/40-apcu.ini,
/etc/opt/rh/rh-php70/php.d/40-igbinary.ini,
/etc/opt/rh/rh-php70/php.d/40-msgpack.ini,
/etc/opt/rh/rh-php70/php.d/50-apc.ini,
/etc/opt/rh/rh-php70/php.d/50-memcached.ini
</code></pre></div></div>
<h1 id="optional-steps">Optional Steps</h1>
<p><em>The following steps are <strong>OPTIONAL</strong>, but recommended.</em></p>
<p>These are some things that will make using the RedHat PHP 7.0.x SCL packages and upgrading existing code bases a little easier.</p>
<ul>
<li>
<p>On development machines that may be building C/C++ packages that require installed php headers, additionally install the corresponding devel packages.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> yum install rh-php70-php-devel rh-php70-scldevel sclo-php70-php-pecl-apcu-devel sclo-php70-php-pecl-http-devel
</code></pre></div> </div>
</li>
<li>
<p>Remove the default CentOS7 <em>httpd*</em> & <em>php*</em> packages & their dependencies. This can help avoid confusion as to which version of php (& httpd) is actually in use.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> yum remove httpd httpd-tools php*
</code></pre></div> </div>
</li>
<li>
<p>Create (or modify) the systemctl EnvironmentFile for httpd.service. By doing this, it will cause the scl httpd24 to re-use the existing <code class="language-plaintext highlighter-rouge">/etc/httpd</code> structure (rather than what’s in <code class="language-plaintext highlighter-rouge">/opt/rh/httpd24/root/etc/httpd</code>). If <strong><code class="language-plaintext highlighter-rouge">#OPTIONS= in /opt/rh/httpd24/root/etc/sysconfig/httpd</code></strong> and change it to the following, then be sure to update the contents of <code class="language-plaintext highlighter-rouge">/etc/httpd</code> to reflect what’s in <code class="language-plaintext highlighter-rouge">/opt/rh/httpd24/root/etc/httpd</code>.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> OPTIONS="-d /etc/httpd"
</code></pre></div> </div>
</li>
</ul>
<h1 id="caveats">Caveats</h1>
<p><em>The following information may be helpful.</em></p>
<p>Many packages, programs, & utilities (and people) expect the default CentOS 7 filesystem locations for associated files. The RedHat SCL packages relocate everything to <code class="language-plaintext highlighter-rouge">/opt/rh/</code>.</p>
<ul>
<li>
<p>If you chose to update the <code class="language-plaintext highlighter-rouge">/opt/rh/httpd24/root/etc/httpd</code> OPTIONS then make sure there are no base httpd artifacts left in <code class="language-plaintext highlighter-rouge">/etc/httpd</code>. Using rsync can be helpful in this case, i.e.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> rsync -avp /opt/rh/httpd24/root/etc/httpd/ /etc/httpd/ --delete-after
</code></pre></div> </div>
</li>
<li>
<p>On CentOS 7 machines with <em>only</em> rh-php-7.0 installed, it may be easiest to use a symbolic link. However, it should <strong>not</strong> be done on machines that choose to have the default php and scl php co-exist on the same machine.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ln -s /opt/rh/rh-php70/root/usr/bin/php /usr/bin/php
</code></pre></div> </div>
</li>
<li>
<p>Best practice, for scripts in general, is to use tge <code class="language-plaintext highlighter-rouge">/usr/bin/env <processor></code> directives rather than hard coding something like <code class="language-plaintext highlighter-rouge">#!/usr/bin/php</code>.</p>
<p><code class="language-plaintext highlighter-rouge">#!/usr/bin/env php</code></p>
</li>
<li>
<p>Here’s a quick one liner to find all files from the current directory that contain ‘‘bin/php’’; they may need to be changed to <code class="language-plaintext highlighter-rouge">#!/usr/bin/env php</code> (rather than relying on a symbolic link).</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> find . -type f -exec gawk 'FNR>10 {nextfile} /bin\/php/ { print FILENAME ; nextfile }' {} \;
</code></pre></div> </div>
</li>
<li>
<p>If open source scripts or packages are found using hard coded shebang conventions then please report them to their author(s) and have them changed upstream.</p>
</li>
</ul>
<h1 id="references">REFERENCES</h1>
<ul>
<li>https://access.redhat.com/solutions/2662201</li>
<li>http://wiki.centos.org/SpecialInterestGroup/SCLo</li>
</ul>Joseph TingirisEnsure httpd is stopped and disabled.Emoji Test2015-09-19T00:00:00+00:002015-09-19T00:00:00+00:00https://josephtingiris.github.io/jekyll/emoji/2015/09/19/emoji-test<p>This is an emoji test. :smile: lol.</p>
<p>See emoji cheat sheet for more detail :wink: : <a href="https://www.webpagefx.com/tools/emoji-cheat-sheet/">https://www.webpagefx.com/tools/emoji-cheat-sheet/</a>.</p>
<p>:bowtie::smile::laughing::blush::smiley::relaxed::smirk:
:heart_eyes::kissing_heart::kissing_closed_eyes::flushed::relieved::satisfied::grin:</p>Joseph TingirisThis is an emoji test. :smile: lol.How to fix KDE Plasma OpenGL on CentOS 7 running as a VMWare guest2015-02-23T02:19:59+00:002015-02-23T02:19:59+00:00https://josephtingiris.github.io/howto/fix/vmware/centos%207/kde/opengl/2015/02/23/vmware-centos-kde-opengl-fix<p>By default, CentOS 7 KDE Plasma Advanced Desktop Effects wont allow a Compositing Type of OpenGL. This is a <a href="https://forum.kde.org/viewtopic.php?f=111&t=109963">bug</a>; Attempting to enable OpenGL 1.2, 2.0, or 3.1 on a VMWare (workstation) guest causes KDE to crash. The Desktop Effect settings continously revert back to a Compositing Type of XRender.</p>
<p>It turns out that there’s a workaround that’s fairly straightfoward, with one caveat. OpenGL 2.0 will work, but OpenGL 3.1 will not.</p>
<p>Here’s how to use a Compositing Type of <strong>OpenGL 2.0</strong> qith the Qt graphics system <strong>Raster</strong>.</p>
<ol>
<li>
<p>As root, add an KDE environment script to ‘‘/etc/kde/env’’, i.e.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> vi /etc/kde/env/force_opengl.sh
</code></pre></div> </div>
</li>
<li>
<p>The content of the script should look something like this (note: KWIN_COMPOSE is ‘‘NOT’’ ZERO2, it’s OH2).</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> #!/usr/bin/bash
export KWIN_DIRECT_GL=1
export KWIN_COMPOSE=O2
</code></pre></div> </div>
</li>
<li>
<p>Log out of KDE & log back in again (or reboot)</p>
</li>
<li>
<p>Click <strong>Start -> System Settings -> Desktop Effects -> Advanced</strong>, change the following, & click <strong>Apply</strong>.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> Compositing Type: OpenGL 2.0
Qt graphics System: Raster
</code></pre></div> </div>
</li>
<li>
<p>Log out of KDE & log back in again (or reboot)</p>
</li>
<li>
<p>Click <strong>Start -> System Settings -> Desktop Effects -> All Effects</strong>, select what you want, & click <strong>Apply</strong>.</p>
</li>
<li>
<p>A good effect to test & see OpenGL 2.0 in action is the <strong><em>Desktop Cube</em></strong>.</p>
</li>
</ol>Joseph TingirisBy default, CentOS 7 KDE Plasma Advanced Desktop Effects wont allow a Compositing Type of OpenGL. This is a bug; Attempting to enable OpenGL 1.2, 2.0, or 3.1 on a VMWare (workstation) guest causes KDE to crash. The Desktop Effect settings continously revert back to a Compositing Type of XRender.