Skip to content

Instantly share code, notes, and snippets.

@guiyomh
Last active January 25, 2016 15:43
Show Gist options
  • Save guiyomh/757b8791118db470b59f to your computer and use it in GitHub Desktop.
Save guiyomh/757b8791118db470b59f to your computer and use it in GitHub Desktop.
Install PHP 5.6 and Apache on Centos7 with Webtatic repo
--- PDO_OCI-1.0/config.m4 2005-09-24 23:23:24.000000000 +0000
+++ config.m4 2016-01-23 17:54:09.825493667 +0000
@@ -7,6 +7,8 @@
if test -s "$PDO_OCI_DIR/orainst/unix.rgs"; then
PDO_OCI_VERSION=`grep '"ocommon"' $PDO_OCI_DIR/orainst/unix.rgs | sed 's/[ ][ ]*/:/g' | cut -d: -f 6 | cut -c 2-4`
test -z "$PDO_OCI_VERSION" && PDO_OCI_VERSION=7.3
+ elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.2; then
+ PDO_OCI_VERSION=11.2
elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
PDO_OCI_VERSION=10.1
elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.9.0; then
@@ -119,6 +121,9 @@
10.2)
PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
;;
+ 11.2)
+ PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
+ ;;
*)
AC_MSG_ERROR(Unsupported Oracle version! $PDO_OCI_VERSION)
;;
--- pdo_oci.c.ori 2016-01-23 18:57:45.934238236 +0000
+++ pdo_oci.c 2016-01-23 19:00:45.638654016 +0000
@@ -31,7 +31,7 @@
#include "php_pdo_oci_int.h"
/* {{{ pdo_oci_functions[] */
-function_entry pdo_oci_functions[] = {
+zend_function_entry pdo_oci_functions[] = {
{NULL, NULL, NULL}
};
/* }}} */
#!/usr/bin/env bash
# Installation d'apache
echo -e "\n--- Installing Apache ---\n"
yum -y install httpd mod_ssl > /dev/null 2>&1
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.ori
cp /etc/httpd/conf.modules.d/00-base.conf /etc/httpd/conf.modules.d/00-base.conf.ori
echo -e "-> Starting and enabling Apache service \n"
systemctl start httpd.service
systemctl enable httpd.service > /dev/null 2>&1
#firewall-cmd --permanent --zone=public --add-service=http
#firewall-cmd --permanent --zone=public --add-service=https
#firewall-cmd --reload
echo -e "-> Disabling modules not used \n"
for module in mod_actions.so mod_allowmethods.so mod_auth_digest.so mod_authn_anon.so mod_authn_core.so mod_authn_dbd.so mod_authn_dbm.so mod_authn_file.so mod_authn_socache.so mod_authz_dbd.so mod_authz_dbm.so mod_authz_groupfile.so mod_authz_host.so mod_authz_owner.so mod_authz_user.so mod_autoindex.so mod_cache.so mod_cache_disk.so mod_data.so mod_dbd.so mod_dumpio.so mod_echo.so mod_env.so mod_ext_filter.so mod_filter.so mod_info.so mod_remoteip.so mod_reqtimeout.so mod_slotmem_shm.so mod_socache_dbm.so mod_socache_memcache.so mod_status.so mod_substitute.so mod_userdir.so
do
sed -i -E "s/(.+$module)/# \1/" /etc/httpd/conf.modules.d/00-base.conf
done
mv /etc/httpd/conf.modules.d/00-dav.conf /etc/httpd/conf.modules.d/00-dav.conf.disable
mv /etc/httpd/conf.modules.d/00-lua.conf /etc/httpd/conf.modules.d/00-lua.conf.disable
mv /etc/httpd/conf.modules.d/00-proxy.conf /etc/httpd/conf.modules.d/00-proxy.conf.disable
mv /etc/httpd/conf.modules.d/01-cgi.conf /etc/httpd/conf.modules.d/01-cgi.conf.disable
mv /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/autoindex.conf.ori
mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.ori
mv /etc/httpd/conf.d/userdir.conf /etc/httpd/conf.d/userdir.conf.ori
#Installation de php
echo -e "\n--- Installing PHP ---\n"
echo -e "-> Add Webtatic repo"
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm > /dev/null 2>&1
echo -e "-> Installing package"
yum -y --enablerepo=webtatic-archive install php56w-5.6.10-1.w7 php56w-common-5.6.10-1.w7 php56w-opcache-5.6.10-1.w7 php56w-bcmath-5.6.10-1.w7 \
php56w-cli-5.6.10-1.w7 php56w-gd-5.6.10-1.w7 php56w-intl-5.6.10-1.w7 php56w-imap-5.6.10-1.w7 \
php56w-mbstring-5.6.10-1.w7 php56w-mcrypt-5.6.10-1.w7 php56w-pdo-5.6.10-1.w7 php56w-mysql-5.6.10-1.w7 \
php56w-snmp-5.6.10-1.w7 php56w-soap-5.6.10-1.w7 php56w-xml-5.6.10-1.w7 php56w-process-5.6.10-1.w7 \
php56w-pear php56w-pecl-xdebug > /dev/null 2>&1
echo -e "-> Installing oci8 (from pecl)"
yum -y --enablerepo=webtatic-archive install php56w-devel-5.6.10-1.w7 > /dev/null 2>&1
pecl update-channels > /dev/null 2>&1
printf "\n" | pecl install oci8-1.4.10 > /dev/null 2>&1
echo "extension=oci8.so" > /etc/php.d/oci8.ini
mkdir -p /tmp/pear/download
cd /tmp/pear/download/
pecl download pdo_oci > /dev/null 2>&1
tar xzf PDO_OCI*.tgz
cd PDO_OCI-*
cp config.m4 config.m4.ori
cp pdo_oci.c pdo_oci.c.ori
cp oci_statement.c oci_statement.c.ori
patch -i /vagrant/vagrant/dotfiles/patches/pdo_oci/config.m4.patch config.m4
patch -i /vagrant/vagrant/dotfiles/patches/pdo_oci/pdo_oci.c.patch pdo_oci.c
phpize > /dev/null 2>&1
./configure --with-pdo-oci=instantclient,/usr,11.2 > /dev/null 2>&1
make > /dev/null 2>&1
make install > /dev/null 2>&1
echo "extension=pdo_oci.so" > /etc/php.d/pdo_oci.ini
# Voir http://www.cyberciti.biz/tips/php-security-best-practices-tutorial.html
echo -e "-> Configuring PHP \n"
cp /etc/php.ini /etc/php.ini.ori
mkdir -p /data/php/log/
mkdir -p /data/php/session/
mkdir -p /data/php/tmp/
mkdir -p /data/www/
sed -i "s#^;date.timezone.*#date.timezone = Europe/paris#" /etc/php.ini
echo -e "-> Securisation for PHP \n"
sed -i "s/^expose_php = .*/expose_php = Off/" /etc/php.ini
sed -i "s/^memory_limit = .*/memory_limit = 512M/" /etc/php.ini
sed -i "s/^max_execution_time = .*/max_execution_time = 30/" /etc/php.ini
sed -i "s#^;error_log = syslog#;error_log = syslog\nerror_log = /data/php/log/scripts-error.log#" /etc/php.ini
sed -i "s/^file_uploads = .*/file_uploads = On/" /etc/php.ini
sed -i "s/^upload_max_filesize = .*/upload_max_filesize = 2M/" /etc/php.ini
sed -i "s/^allow_url_fopen = .*/allow_url_fopen = Off/" /etc/php.ini
sed -i "s/^allow_url_include = .*/allow_url_include = Off/" /etc/php.ini
sed -i "s/^sql.safe_mode = .*/sql.safe_mode = On/" /etc/php.ini
sed -i "s/^post_max_size = .*/post_max_size = 5K/" /etc/php.ini
sed -i "s/^session.name = .*/session.name = PSID/" /etc/php.ini
sed -i "s#^;session.save_path = .*#session.save_path = /data/php/session#" /etc/php.ini
sed -i "s/^session.cookie_httponly.*/session.cookie_httponly = On/" /etc/php.ini
sed -i "s#^;upload_tmp_dir.*#upload_tmp_dir = /data/php/tmp#" /etc/php.ini
sed -i "s#^;open_basedir.*#open_basedir = /data/www/:/var/www/html#" /etc/php.ini
echo -e "-> Only for development add error \n"
sed -i "s/^display_errors = .*/display_errors = On/" /etc/php.ini
cp /etc/php.ini /etc/php-cli.ini
sed -i "s#^open_basedir.*#;open_basedir = #" /etc/php-cli.ini
sed -i "s/^max_execution_time = .*/max_execution_time = 0/" /etc/php-cli.ini
sed -i "s/^allow_url_fopen = .*/allow_url_fopen = On/" /etc/php-cli.ini
#echo "alias php=php -n $(grep -ri 'extension=' /etc/php.d/ | grep -v 'xdebug' | awk -F ':' '{print "-d "$2" "}' | tr -d '\n')" > /etc/profile.d/php-cli.sh
# Utilitaires
echo -e "\n--- Installing PHP tools ---\n"
echo -e "-> Composer \n"
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer > /dev/null 2>&1
echo -e "-> php-cs-fixer \n"
COMPOSER_HOME="/usr/local/composer" composer global require fabpot/php-cs-fixer:dev-master > /dev/null 2>&1
echo -e "-> symfony-console-autocomplete \n"
COMPOSER_HOME="/usr/local/composer" composer global require bamarni/symfony-console-autocomplete > /dev/null 2>&1
echo -e "-> phpunit \n"
COMPOSER_HOME="/usr/local/composer" composer global require "phpunit/phpunit=5.1.*" > /dev/null 2>&1
COMPOSER_HOME="/usr/local/composer" composer global require "phpunit/php-invoker" > /dev/null 2>&1
echo -e "-> phpmd \n"
COMPOSER_HOME="/usr/local/composer" composer global require "phpmd/phpmd" "@stable" > /dev/null 2>&1
echo -e "-> phpdcd \n"
COMPOSER_HOME="/usr/local/composer" composer global require "sebastian/phpdcd" > /dev/null 2>&1
echo -e "-> phpcpd \n"
COMPOSER_HOME="/usr/local/composer" composer global require "sebastian/phpcpd" > /dev/null 2>&1
echo "export PATH=/usr/local/composer/vendor/bin:$PATH" > /etc/profile.d/composer.sh
chmod +x /etc/profile.d/composer.sh
echo "eval \"\$(symfony-autocomplete)\"" > /etc/profile.d/symfony.sh
chmod +x /etc/profile.d/symfony.sh
systemctl restart httpd.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment