Compare commits

...

9 Commits
2.21.1 ... sapi

21 changed files with 550 additions and 60 deletions

View File

@ -107,16 +107,16 @@ describe('Utils tests', () => {
await cleanup(script_path);
});
it('checking extensionArray', async () => {
expect(await utils.extensionArray('a, b, php_c, php-d')).toEqual([
it('checking packageArray', async () => {
expect(await utils.packageArray('a, b, php_c, php-d')).toEqual([
'a',
'b',
'c',
'd'
]);
expect(await utils.extensionArray('')).toEqual([]);
expect(await utils.extensionArray(' ')).toEqual([]);
expect(await utils.packageArray('')).toEqual([]);
expect(await utils.packageArray(' ')).toEqual([]);
});
it('checking INIArray', async () => {

View File

@ -18,6 +18,9 @@ inputs:
coverage:
description: 'Setup code coverage driver.'
required: false
sapi:
description: 'Setup PHP Server API.'
required: false
tools:
description: 'Setup popular tools globally.'
required: false

108
dist/index.js vendored
View File

@ -1808,7 +1808,7 @@ const utils = __importStar(__nccwpck_require__(314));
* @param version
*/
async function addExtensionDarwin(extension_csv, version) {
const extensions = await utils.extensionArray(extension_csv);
const extensions = await utils.packageArray(extension_csv);
let add_script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension) {
@ -1877,7 +1877,7 @@ exports.addExtensionDarwin = addExtensionDarwin;
* @param version
*/
async function addExtensionWindows(extension_csv, version) {
const extensions = await utils.extensionArray(extension_csv);
const extensions = await utils.packageArray(extension_csv);
let add_script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension) {
@ -1961,7 +1961,7 @@ exports.addExtensionWindows = addExtensionWindows;
* @param version
*/
async function addExtensionLinux(extension_csv, version) {
const extensions = await utils.extensionArray(extension_csv);
const extensions = await utils.packageArray(extension_csv);
let add_script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension) {
@ -1980,14 +1980,14 @@ async function addExtensionLinux(extension_csv, version) {
// match couchbase, pdo_oci, oci8, http, pecl_http
// match 5.3ioncube...7.4ioncube, 5.3geos...7.4geos
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6gearman...7.4gearman
// match 5.6gearman...8.1gearman
case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension):
case /^couchbase$|^pdo_oci$|^oci8$|^http|^pecl_http|^pdo_firebird$/.test(extension):
case /^(5\.6|7\.[0-4]|8\.0)intl-[\d]+\.[\d]+$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4])(ioncube|geos)$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4]|8\.[0-9])gearman$/.test(version_extension):
add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux');
return;
// match pre-release versions. For example - xdebug-beta
@ -2095,6 +2095,7 @@ const core = __importStar(__nccwpck_require__(186));
const config = __importStar(__nccwpck_require__(373));
const coverage = __importStar(__nccwpck_require__(84));
const extensions = __importStar(__nccwpck_require__(587));
const sapi = __importStar(__nccwpck_require__(489));
const tools = __importStar(__nccwpck_require__(905));
const utils = __importStar(__nccwpck_require__(314));
/**
@ -2113,7 +2114,11 @@ async function getScript(filename, version, os_version) {
const ini_values_csv = await utils.getInput('ini-values', false);
const coverage_driver = await utils.getInput('coverage', false);
const tools_csv = await utils.getInput('tools', false);
const sapi_csv = await utils.getInput('sapi', false);
let script = await utils.readScript(filename);
if (sapi_csv) {
script += await sapi.addSAPI(sapi_csv, os_version);
}
script += await tools.addTools(tools_csv, version, os_version);
if (extension_csv) {
script += await extensions.addExtension(extension_csv, version, os_version);
@ -2152,7 +2157,82 @@ async function run() {
}
exports.run = run;
// call the run function
run();
(async () => {
await run();
})().catch(error => {
core.setFailed(error.message);
});
/***/ }),
/***/ 489:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.addSAPI = exports.getSapiList = void 0;
const utils = __importStar(__nccwpck_require__(314));
async function getSapiList(sapi_csv) {
const sapi_list = await utils.packageArray(sapi_csv);
const servers = sapi_list.filter(sapi => /.*:.*/.test(sapi));
return [servers[servers.length - 1]].concat(sapi_list.filter(sapi => /.*[^:].*/.test(sapi)));
}
exports.getSapiList = getSapiList;
/**
* Function to set sapi
*
* @param sapi_csv
* @param os_version
*/
async function addSAPI(sapi_csv, os_version) {
let script = '\n' + (await utils.stepLog('Setup SAPI', os_version));
let sapi_list;
switch (true) {
case sapi_csv.split(':').length - 1 > 1:
sapi_list = await getSapiList(sapi_csv);
script +=
'\n' +
utils.log('Multiple SAPI with web servers specified, choosing the last one ' +
sapi_list[0], os_version, 'warning');
break;
default:
sapi_list = await utils.packageArray(sapi_csv);
}
await utils.asyncForEach(sapi_list, async function (sapi) {
sapi = sapi.toLowerCase();
switch (os_version) {
case 'linux':
case 'darwin':
script += '\nadd_sapi ' + sapi;
break;
case 'win32':
script += '\nAdd-Sapi ' + sapi;
break;
}
});
return script;
}
exports.addSAPI = addSAPI;
/***/ }),
@ -2650,7 +2730,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseVersion = exports.fetch = exports.getInput = exports.readEnv = void 0;
exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.packageArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseVersion = exports.fetch = exports.getInput = exports.readEnv = void 0;
const fs = __importStar(__nccwpck_require__(747));
const https = __importStar(__nccwpck_require__(211));
const path = __importStar(__nccwpck_require__(622));
@ -2843,18 +2923,18 @@ exports.writeScript = writeScript;
/**
* Function to break extension csv into an array
*
* @param extension_csv
* @param package_csv
*/
async function extensionArray(extension_csv) {
switch (extension_csv) {
async function packageArray(package_csv) {
switch (package_csv) {
case '':
case ' ':
return [];
default:
return extension_csv
return package_csv
.split(',')
.map(function (extension) {
return extension
.map(function (package_name) {
return package_name
.trim()
.toLowerCase()
.replace(/^php[-_]/, '');
@ -2862,7 +2942,7 @@ async function extensionArray(extension_csv) {
.filter(Boolean);
}
}
exports.extensionArray = extensionArray;
exports.packageArray = packageArray;
/**
* Function to break csv into an array
*

View File

@ -0,0 +1,3 @@
LoadModule phpPHP_MAJOR_module PHP_DIR\PHP_APACHE_DLL
AddHandler application/x-httpd-php .php
PHPIniDir PHP_DIR

View File

@ -0,0 +1,8 @@
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so
<FilesMatch "\.php$">
<If "-f %{REQUEST_FILENAME}">
SetHandler "proxy:fcgi://127.0.0.1:9000/"
</If>
</FilesMatch>

36
src/configs/nginx.conf Normal file
View File

@ -0,0 +1,36 @@
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}

View File

@ -0,0 +1,5 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www/html"
ServerName localhost
</VirtualHost>

View File

@ -0,0 +1,7 @@
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

View File

@ -0,0 +1,22 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.php;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/phpPHP_VERSION-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}

View File

@ -10,7 +10,7 @@ export async function addExtensionDarwin(
extension_csv: string,
version: string
): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv);
const extensions: Array<string> = await utils.packageArray(extension_csv);
let add_script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension: string) {
@ -115,7 +115,7 @@ export async function addExtensionWindows(
extension_csv: string,
version: string
): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv);
const extensions: Array<string> = await utils.packageArray(extension_csv);
let add_script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension: string) {
@ -229,7 +229,7 @@ export async function addExtensionLinux(
extension_csv: string,
version: string
): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv);
const extensions: Array<string> = await utils.packageArray(extension_csv);
let add_script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension: string) {
@ -249,7 +249,7 @@ export async function addExtensionLinux(
// match couchbase, pdo_oci, oci8, http, pecl_http
// match 5.3ioncube...7.4ioncube, 5.3geos...7.4geos
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6gearman...7.4gearman
// match 5.6gearman...8.1gearman
case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension
):
@ -262,7 +262,7 @@ export async function addExtensionLinux(
case /^(5\.6|7\.[0-4]|8\.0)intl-[\d]+\.[\d]+$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4])(ioncube|geos)$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
case /^(5\.[3-6]|7\.[0-4]|8\.[0-9])gearman$/.test(version_extension):
add_script += await utils.customPackage(
ext_name,
'ext',

View File

@ -1,8 +1,9 @@
import {exec} from '@actions/exec/lib/exec';
import {exec} from '@actions/exec';
import * as core from '@actions/core';
import * as config from './config';
import * as coverage from './coverage';
import * as extensions from './extensions';
import * as sapi from './sapi';
import * as tools from './tools';
import * as utils from './utils';
@ -26,10 +27,13 @@ export async function getScript(
const ini_values_csv: string = await utils.getInput('ini-values', false);
const coverage_driver: string = await utils.getInput('coverage', false);
const tools_csv: string = await utils.getInput('tools', false);
const sapi_csv: string = await utils.getInput('sapi', false);
let script: string = await utils.readScript(filename);
if (sapi_csv) {
script += await sapi.addSAPI(sapi_csv, os_version);
}
script += await tools.addTools(tools_csv, version, os_version);
if (extension_csv) {
script += await extensions.addExtension(extension_csv, version, os_version);
}
@ -69,4 +73,8 @@ export async function run(): Promise<void> {
}
// call the run function
run();
(async () => {
await run();
})().catch(error => {
core.setFailed(error.message);
});

51
src/sapi.ts Normal file
View File

@ -0,0 +1,51 @@
import * as utils from './utils';
export async function getSapiList(sapi_csv: string): Promise<Array<string>> {
const sapi_list: Array<string> = await utils.packageArray(sapi_csv);
const servers: Array<string> = sapi_list.filter(sapi => /.*:.*/.test(sapi));
return [servers[servers.length - 1]].concat(
sapi_list.filter(sapi => /.*[^:].*/.test(sapi))
);
}
/**
* Function to set sapi
*
* @param sapi_csv
* @param os_version
*/
export async function addSAPI(
sapi_csv: string,
os_version: string
): Promise<string> {
let script: string = '\n' + (await utils.stepLog('Setup SAPI', os_version));
let sapi_list: Array<string>;
switch (true) {
case sapi_csv.split(':').length - 1 > 1:
sapi_list = await getSapiList(sapi_csv);
script +=
'\n' +
utils.log(
'Multiple SAPI with web servers specified, choosing the last one ' +
sapi_list[0],
os_version,
'warning'
);
break;
default:
sapi_list = await utils.packageArray(sapi_csv);
}
await utils.asyncForEach(sapi_list, async function (sapi: string) {
sapi = sapi.toLowerCase();
switch (os_version) {
case 'linux':
case 'darwin':
script += '\nadd_sapi ' + sapi;
break;
case 'win32':
script += '\nAdd-Sapi ' + sapi;
break;
}
});
return script;
}

View File

@ -257,9 +257,11 @@ add_composertool() {
fi
}
# Function to get PHP version in semver format.
# Function to get versions of PHP binaries in semver format.
php_semver() {
php"$version" -v | grep -Eo -m 1 "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1
binary=${1:-"php$version"}
arg=${2:-'-v'}
"$binary" "$arg" | grep -Eo -m 1 "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1
}
# Function to get the tag for a php version.

View File

@ -2,16 +2,20 @@
add_couchbase_libs() {
if [ "$(uname -s)" = "Linux" ]; then
if [[ ${version:?} =~ 5.[3-6]|7.[0-1] ]]; then
trunk="http://packages.couchbase.com/ubuntu"
list="deb $trunk ${DISTRIB_CODENAME:?} ${DISTRIB_CODENAME:?}/main"
release="2.10.9"
trunk="https://github.com/couchbase/libcouchbase/releases/download"
package="libcouchbase-${release}_ubuntu${DISTRIB_RELEASE/./}_${DISTRIB_CODENAME}_amd64.tar"
get -q -n /tmp/libcouchbase.tar "$trunk/$release/$package"
sudo tar -xf /tmp/libcouchbase.tar -C /tmp
install_packages libev4
sudo dpkg -i /tmp/libcouchbase-*/*.deb
else
trunk="http://packages.couchbase.com/clients/c/repos/deb"
list="deb $trunk/ubuntu${DISTRIB_RELEASE/./} ${DISTRIB_CODENAME:?} ${DISTRIB_CODENAME:?}/main"
get -s -n "" "$trunk/couchbase.key" | sudo apt-key add
echo "$list" | sudo tee /etc/apt/sources.list.d/couchbase.list
sudo apt-get update
fi
add_pecl
get -s -n "" "$trunk/couchbase.key" | sudo apt-key add
echo "$list" | sudo tee /etc/apt/sources.list.d/couchbase.list
sudo apt-get update
${apt_install:?} libcouchbase-dev
else
if [[ ${version:?} =~ 5.[3-6]|7.[0-1] ]]; then

View File

@ -7,6 +7,15 @@ add_license_log() {
echo "::endgroup::"
}
# Function to setup gcc-7 and g++-7
setup_compiler() {
if ! command -v gcc-7 >/dev/null || ! command -v g++-7 >/dev/null; then
add_ppa ubuntu-toolchain-r/test
add_packages gcc-7 g++-7 -y
fi
printf "gcc g++" | xargs -d ' ' -I {} sudo update-alternatives --install /usr/bin/{} {} /usr/bin/{}-7 7
}
# Function to set cubrid repo for the extension.
set_cubrid_repo() {
case "${ext:?}" in
@ -30,11 +39,13 @@ add_cubrid_helper() {
status='Installed and enabled'
set_cubrid_repo
set_cubrid_branch
[ "$DISTRIB_RELEASE" = "16.04" ] && setup_compiler
(
git clone -b "$cubrid_branch" --recursive "https://github.com/CUBRID/$cubrid_repo" "/tmp/$cubrid_repo"
cd "/tmp/$cubrid_repo" || exit
! [[ "$version" =~ ${old_versions:?} ]] && add_devtools
phpize && ./configure --with-php-config="$(command -v php-config)" --with-"${ext/_/-}"=shared
phpize
sudo ./configure --with-php-config="$(command -v php-config)" --with-"${ext/_/-}"=shared
make -j"$(nproc)"
sudo make install
)

View File

@ -1,17 +1,16 @@
# Helper function to add gearman extension.
add_gearman_helper() {
sudo "${debconf_fix:?}" add-apt-repository ppa:ondrej/pkg-gearman -y
if [ -e "${ext_dir:?}/gearman.so" ] && [ "$DISTRIB_RELEASE" != "16.04" ]; then
${apt_install:?} libgearman-dev
echo "extension=gearman.so" | sudo tee -a "${scan_dir:?}/20-gearman.ini" >/dev/null 2>&1
else
add_ppa ondrej/pkg-gearman
install_packages libgearman-dev
enable_extension gearman extension
if ! check_extension gearman; then
status="Installed and enabled"
if [ "$DISTRIB_RELEASE" = "16.04" ]; then
sudo "${debconf_fix:?}" apt-get update -y
${apt_install:?} php"${version:?}"-gearman
if [[ "${version:?}" =~ 5.[3-5] ]]; then
pecl_install gearman-1.1.2
else
${apt_install:?} libgearman-dev php"${version:?}"-gearman
install_packages php"${version:?}"-gearman || pecl_install gearman
fi
enable_extension gearman extension
fi
}

View File

@ -6,8 +6,7 @@ add_phalcon_helper() {
if [ "$extension" = "phalcon4" ]; then
${apt_install:?} "php${version:?}-psr" "php${version:?}-$extension"
else
get -q -e /tmp/phalcon.deb "https://packagecloud.io/phalcon/stable/packages/ubuntu/bionic/php${version:?}-phalcon_3.4.5-1+php${version:?}_amd64.deb/download.deb"
sudo dpkg -i /tmp/phalcon.deb
${apt_install:?} "php${version:?}-$extension"
fi
else
sed -i '' '/extension.*psr/d' "${ini_file:?}"

View File

@ -4,15 +4,16 @@ self_hosted_helper() {
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
fi
install_packages curl make software-properties-common unzip autoconf automake gcc g++
add_ppa
add_ppa ondrej/ppa
}
# Function to backup and cleanup package lists.
cleanup_lists() {
ppa_prefix=${1-ondrej}
if [ ! -e /etc/apt/sources.list.d.save ]; then
sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save
sudo mkdir /etc/apt/sources.list.d
sudo mv /etc/apt/sources.list.d.save/*ondrej*.list /etc/apt/sources.list.d/
sudo mv /etc/apt/sources.list.d.save/*"${ppa_prefix}"*.list /etc/apt/sources.list.d/
sudo mv /etc/apt/sources.list.d.save/*dotdeb*.list /etc/apt/sources.list.d/ 2>/dev/null || true
trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/ 2>/dev/null" exit
fi
@ -20,15 +21,33 @@ cleanup_lists() {
# Function to add ppa:ondrej/php.
add_ppa() {
if ! apt-cache policy | grep -q ondrej/php; then
cleanup_lists
LC_ALL=C.UTF-8 sudo apt-add-repository ppa:ondrej/php -y
ppa=${1:-ondrej/php}
if ! apt-cache policy | grep -q "$ppa"; then
cleanup_lists "$(dirname "$ppa")"
LC_ALL=C.UTF-8 sudo apt-add-repository ppa:"$ppa" -y
if [ "$DISTRIB_RELEASE" = "16.04" ]; then
sudo "$debconf_fix" apt-get update
fi
fi
}
# Function to add SAPI
add_sapi() {
sapi=$1
status='true'
if [ "$sapi" != "cli" ]; then
# shellcheck source=.
. "${dist}"/../src/scripts/sapi.sh
setup_sapi "$sapi" >/dev/null 2>&1
fi
check_sapi "$sapi"
if check_sapi "$sapi"; then
add_log "${tick:?}" "$sapi" "Added $sapi"
else
add_log "${cross:?}" "$sapi" "Could not setup $sapi"
fi
}
# Function to update the package lists.
update_lists() {
if [ ! -e /tmp/setup_php ]; then
@ -200,14 +219,14 @@ add_packaged_php() {
IFS=' ' read -r -a packages <<<"$(echo "cli curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")"
$apt_install "${packages[@]}"
else
run_script "php-ubuntu" "$version"
run_script "test-setup-php" "$version"
fi
}
# Function to update PHP.
update_php() {
initial_version=$(php_semver)
use_package_cache="false" add_packaged_php
add_packaged_php
updated_version=$(php_semver)
if [ "$updated_version" != "$initial_version" ]; then
status="Updated to"

View File

@ -0,0 +1,116 @@
#!/bin/bash
install_httpd() {
sudo mkdir -p /var/www/html
sudo chown -R _www:_www /var/www
brew services stop nginx 2>/dev/null || true
if ! command -v httpd >/dev/null; then
brew install httpd
fi
sudo sed -Ei '' 's/Listen.*/Listen 80/' "$httpd_conf"
sudo sed -Ei '' 's/DirectoryIndex.*/DirectoryIndex index.php index.html/' "$httpd_conf"
}
install_nginx() {
sudo mkdir -p /var/www/html
sudo chown -R "$(id -un)":"$(id -gn)" /var/www
brew services stop httpd 2>/dev/null || true
if ! command -v nginx >/dev/null; then
brew install nginx
fi
sudo sed -Ei '' 's/listen.*/listen 80;/' "$nginx_conf"
}
setup_sapi() {
sapi=$1
conf_dir="${dist:?}"/../src/configs
case $sapi in
apache*:apache*)
install_httpd
(
echo "LoadModule proxy_module lib/httpd/modules/mod_proxy.so"
echo "LoadModule proxy_module lib/httpd/modules/mod_proxy_fcgi.so"
) | sudo tee -a "$httpd_conf"
echo "Include $httpd_extra/httpd-php.conf" | sudo tee -a "$httpd_conf"
sudo cp "$conf_dir"/default_apache /etc/apache2/sites-available/000-default.conf
sudo a2dismod mpm_event 2>/dev/null || true
sudo a2enmod mpm_prefork php"${version:?}"
sudo service apache2 restart
;;
fpm:apache*)
install_httpd
sudo cp "$conf_dir"/default_apache /etc/apache2/sites-available/000-default.conf
sudo a2dismod php"${version:?}" 2>/dev/null || true
sudo a2enmod proxy_fcgi
sudo a2enconf php"${version:?}"-fpm
sudo service apache2 restart
;;
cgi:apache*)
install_httpd
sudo cp "$conf_dir"/default_apache /etc/apache2/sites-available/000-default.conf
echo "Action application/x-httpd-php /cgi-bin/php${version:?}" | sudo tee -a /etc/apache2/conf-available/php"${version:?}"-cgi.conf
sudo a2dismod php"${version:?}" mpm_event 2>/dev/null || true
sudo a2enmod mpm_prefork actions cgi
sudo a2disconf php"${version:?}"-fpm 2>/dev/null || true
sudo a2enconf php"${version:?}"-cgi
sudo service apache2 restart
;;
fpm:nginx)
install_nginx
sudo cp "$conf_dir"/default_nginx /etc/nginx/sites-available/default
sudo sed -i "s/PHP_VERSION/${version:?}/" /etc/nginx/sites-available/default
sudo service nginx restart
;;
apache* | fpm | cgi | phpdbg) ;;
esac
}
check_service() {
service=$1
if ! pidof "$service"; then
return 1
fi
(
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$service" "Click to check $service status"
sudo service "$service" status
echo "::endgroup::"
) | sudo tee -a /tmp/sapi.log >/dev/null 2>&1
return 0
}
check_version() {
sapi=$1
sapi_version=$(php_semver "$sapi")
if [ ${sapi_version%.*} != "${version:?}" ]; then
return 1
fi
add_log "${tick:?}" "$sapi" "Added $sapi $sapi_version" | sudo tee -a /tmp/sapi.log >/dev/null 2>&1
return 0
}
check_sapi() {
sapi=$1
sudo rm /tmp/sapi.log
if [[ "$sapi" =~ fpm|cgi ]]; then status=$(check_version php-"$sapi"); fi
if [[ "$sapi" =~ ^phpdbg$ ]]; then status=$(check_version phpdbg); fi
if [[ "$sapi" =~ .*fpm.* ]]; then status=$(check_service php"${version:?}"-fpm); fi
if [[ "$sapi" =~ .*:apache.* ]]; then status=$(check_service apache2); fi
if [[ "$sapi" =~ .*:nginx.* ]]; then status=$(check_service nginx); fi
if [ "$status" = "0" ]; then
if [[ "$sapi" =~ .*:.* ]]; then
add_log "${tick:?}" "$sapi" "Added $sapi"
fi
cat /tmp/sapi.log && sudo rm /tmp/sapi.log
else
add_log "${cross:?}" "$sapi" "Could not setup $sapi"
fi
}
httpd_conf=${brew_prefix:?}/etc/httpd/httpd.conf
httpd_extra=${brew_prefix:?}/etc/httpd/extra
nginx_conf=${brew_prefix:?}/etc/nginx/nginx.conf

View File

@ -0,0 +1,117 @@
#!/bin/bash
install_apache2() {
sudo mkdir -p /var/www/html
sudo service nginx stop 2>/dev/null || true
if ! command -v apache2 >/dev/null; then
install_packages apache2-bin apache2 -y;
else
if ! [[ "$(apache2 -v 2>/dev/null | grep -Eo "([0-9]+\.[0-9]+)")" =~ 2.[4-9] ]]; then
sudo "${debconf_fix:?}" apt-get purge apache* apache-* >/dev/null
install_packages apache2-bin apache2 -y;
fi
fi
}
install_nginx() {
sudo mkdir -p /var/www/html
sudo service apache2 stop 2>/dev/null || true
if ! command -v nginx >/dev/null; then
install_packages nginx -y
fi
}
setup_sapi() {
sapi=$1
conf_dir="${dist:?}"/../src/configs
if [[ "${version:?}" =~ ${old_versions:?}|${nightly_versions:?} ]]; then
switch_sapi "$sapi"
else
case $sapi in
apache*:apache*)
install_apache2
sudo cp "$conf_dir"/default_apache /etc/apache2/sites-available/000-default.conf
install_packages libapache2-mod-php"${version:?}" -y
sudo a2dismod mpm_event 2>/dev/null || true
sudo a2enmod mpm_prefork php"${version:?}"
sudo service apache2 restart
;;
fpm:apache*)
install_apache2
sudo cp "$conf_dir"/default_apache /etc/apache2/sites-available/000-default.conf
install_packages libapache2-mod-fcgid php"${version:?}"-fpm -y
sudo a2dismod php"${version:?}" 2>/dev/null || true
sudo a2enmod proxy_fcgi
sudo a2enconf php"${version:?}"-fpm
sudo service apache2 restart
;;
cgi:apache*)
install_apache2
install_packages php"${version:?}"-cgi -y
sudo cp "$conf_dir"/default_apache /etc/apache2/sites-available/000-default.conf
echo "Action application/x-httpd-php /cgi-bin/php${version:?}" | sudo tee -a /etc/apache2/conf-available/php"${version:?}"-cgi.conf
sudo a2dismod php"${version:?}" mpm_event 2>/dev/null || true
sudo a2enmod mpm_prefork actions cgi
sudo a2disconf php"${version:?}"-fpm 2>/dev/null || true
sudo a2enconf php"${version:?}"-cgi
sudo service apache2 restart
;;
fpm:nginx)
install_nginx
install_packages php"${version:?}"-fpm -y
sudo cp "$conf_dir"/default_nginx /etc/nginx/sites-available/default
sudo sed -i "s/PHP_VERSION/${version:?}/" /etc/nginx/sites-available/default
sudo service nginx restart
;;
apache*)
install_packages libapache2-mod-php"${version:?}" -y
;;
fpm|embed|cgi|phpdbg)
install_packages php"${version:?}"-"$sapi" -y
;;
esac
fi
}
check_service() {
service=$1
if ! pidof "$service"; then
return 1
fi
(
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$service" "Click to check $service status"
sudo service "$service" status
echo "::endgroup::"
) | sudo tee -a /tmp/sapi.log >/dev/null 2>&1
return 0
}
check_version() {
sapi=$1
sapi_version=$(php_semver "$sapi")
if [ "${sapi_version%.*}" != "${version:?}" ]; then
return 1;
fi
add_log "${tick:?}" "$sapi" "Added $sapi $sapi_version" | sudo tee -a /tmp/sapi.log >/dev/null 2>&1
return 0
}
check_sapi() {
sapi=$1
sudo rm /tmp/sapi.log
if [[ "$sapi" =~ fpm|cgi ]]; then status=$(check_version php-"$sapi"); fi
if [[ "$sapi" =~ ^phpdbg$ ]]; then status=$(check_version phpdbg); fi
if [[ "$sapi" =~ .*fpm.* ]]; then status=$(check_service php"${version:?}"-fpm); fi
if [[ "$sapi" =~ .*:apache.* ]]; then status=$(check_service apache2); fi
if [[ "$sapi" =~ .*:nginx.* ]]; then status=$(check_service nginx); fi
if [ "$status" = "0" ]; then
if [[ "$sapi" =~ .*:.* ]]; then
add_log "${tick:?}" "$sapi" "Added $sapi"
fi
cat /tmp/sapi.log && sudo rm /tmp/sapi.log
else
add_log "${cross:?}" "$sapi" "Could not setup $sapi"
fi
}

View File

@ -234,20 +234,20 @@ export async function writeScript(
/**
* Function to break extension csv into an array
*
* @param extension_csv
* @param package_csv
*/
export async function extensionArray(
extension_csv: string
export async function packageArray(
package_csv: string
): Promise<Array<string>> {
switch (extension_csv) {
switch (package_csv) {
case '':
case ' ':
return [];
default:
return extension_csv
return package_csv
.split(',')
.map(function (extension: string) {
return extension
.map(function (package_name: string) {
return package_name
.trim()
.toLowerCase()
.replace(/^php[-_]/, '');