sh Scriptparainstalaçãodospacotes Apache,MySQL e PHP 7.2 mais phpMyAdmin e xDebug no siste
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Scriptparainstalaçãodospacotes Apache,MySQL e PHP 7.2 mais phpMyAdmin e xDebug no siste相关的知识,希望对你有一定的参考价值。
#!/usr/bin/env bash
# Script para instalação dos pacotes Apache, MySQL e PHP 7.2
# mais phpMyAdmin e xDebug no sistema operacional Ubuntu 16.04
# Por Alex Jesus <aljesti@gmail.com> em 16/01/2018.
echo "--- Iniciando a instalação do ambiente de Desenvolvimento PHP 7.2 [Ubuntu 16.04] ---"
export DEBIAN_FRONTEND=noninteractive
export COMPOSER_ALLOW_SUPERUSER=1
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
basepath=$1
dirweb=$2
hostname=$3
echo "--- Adicionando repositórios dos pacotes Apache, MySQL, PHP e extensões PECL ---"
add-apt-repository -y ppa:ondrej/apache2
add-apt-repository -y ppa:ondrej/mysql-5.6
add-apt-repository -y ppa:ondrej/php
echo "--- Atualizando lista de pacotes ---"
apt-get -qq update
echo "--- Atualizando pacotes ---"
apt-get -yu upgrade
echo "--- Instalando pacotes básicos ---"
sudo apt-get install software-properties-common vim curl python-software-properties git-core --assume-yes --force-yes
apt-get install -yq software-properties-common ca-certificates curl debconf-utils git libexpat1 locales make mcrypt memcached openssl sqlite3 ssl-cert tar unzip vim wget zip
echo "--- Instalando o Apache ---"
apt-get install -yq apache2
echo "--- Definindo a senha padrão para o MySQL ---"
debconf-set-selections <<< "mysql-server-5.6 mysql-server/root_password password \"''\""
debconf-set-selections <<< "mysql-server-5.6 mysql-server/root_password_again password \"''\""
echo "--- Instalando MySQL ---"
apt-get install -yq mysql-server-5.6
echo "--- Configurando o MySQL ---"
cp /etc/mysql/my.cnf /etc/mysql/my.bkup.cnf
sed -i 's/bind-address/bind-address = 0.0.0.0#/' /etc/mysql/my.cnf
mysql -u root -Bse "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '' WITH GRANT OPTION;"
echo "--- Reiniciando o MySQL ---"
service mysql restart
echo "--- Instalando o PHP e pacotes adicionais ---"
apt-get install -yq php7.2 libapache2-mod-php7.2 php7.2-bcmath php7.2-bz2 php7.2-cli php7.2-common php7.2-curl php7.2-dba php7.2-dev php7.2-enchant php7.2-fpm php7.2-gd php7.2-gmp php7.2-imap php7.2-interbase php7.2-intl php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-odbc php7.2-opcache php7.2-pgsql php7.2-phpdbg php7.2-pspell php7.2-readline php7.2-recode php7.2-snmp php7.2-soap php7.2-sqlite3 php7.2-sybase php7.2-tidy php7.2-xml php7.2-xmlrpc php7.2-xsl php7.2-zip php-pear php-apcu php-imagick php-memcached php-redis php-yaml
echo "--- Alterando o canal de atualização PECL ---"
pecl channel-update pecl.php.net
echo "--- Configurando o PHP ---"
sed -i 's/short_open_tag = Off/short_open_tag = On/' /etc/php/7.2/apache2/php.ini
sed -i 's/error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL/' /etc/php/7.2/apache2/php.ini
sed -i 's/display_errors = Off/display_errors = On/' /etc/php/7.2/apache2/php.ini
sed -i '/\[Session\]/a session.save_path = "/tmp"' /etc/php/7.2/apache2/php.ini
phpenmod -v 7.2 -s ALL yaml mbstring intl curl soap
echo "--- Configurando o Apache para o usuário vagrant ---"
sed -i 's/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=vagrant/' /etc/apache2/envvars
sed -i 's/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=vagrant/' /etc/apache2/envvars
echo "--- Criando pasta Vagrant para o Apache ---"
DIR="$basepath/$dirweb"
if [ ! -d $DIR ]; then
mkdir $DIR
fi
echo "--- Criando index.php (phpinfo) ---"
cd $DIR
FILE='index.php'
if [ ! -f $FILE ]; then
echo '<?php phpinfo();' > $FILE
fi
cd ~
echo "--- Criando host virtual ---"
cat > "/etc/apache2/sites-available/vagrant.conf" << EOF
<VirtualHost *:80>
ServerAdmin webmaster@$hostname
ServerName $hostname
DocumentRoot $basepath/$dirweb
ErrorLog $basepath/$dirweb/$hostname-error.log
CustomLog $basepath/$dirweb/$hostname-access.log combined
<Directory "$basepath/$dirweb">
Options -Indexes +FollowSymLinks
AddDefaultCharset utf-8
SetEnv ENVIRONMENT "development"
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EOF
a2ensite vagrant
a2dissite 000-default
# AH00558: apache2: Could not reliably determine the server's fully qualified
echo "ServerName localhost" >> /etc/apache2/apache2.conf
echo "--- Habilitando os módulos mod-rewrite, headers, php7.2 e ssl ---"
a2enmod rewrite headers php7.2 ssl
echo "--- Baixando e instalando xDebug ---"
wget http://xdebug.org/files/xdebug-2.6.0beta1.tgz
tar -xvzf xdebug-2.6.0beta1.tgz
cd xdebug-2.6.0beta1
phpize
./configure
make
cp modules/xdebug.so /usr/lib/php/20170718
echo 'zend_extension = /usr/lib/php/20170718/xdebug.so' >> /etc/php/7.2/apache2/php.ini
echo "--- Definindo a senha padrão para o phpMyAdmin ---"
debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true"
debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password \"''\""
debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password \"''\""
debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password \"''\""
debconf-set-selections <<< "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2"
echo "--- Instalando o phpMyAdmin ---"
apt-get install -yq phpmyadmin
sed -i -e "s/\/\/ \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/\$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\]/g" /etc/phpmyadmin/config.inc.php
echo "--- Reiniciando o Apache ---"
service apache2 restart
echo "--- Baixando e instalando Composer ---"
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
echo "--- Removendo pacotes que não serão mais usados ---"
apt-get -yq clean
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
echo "--- Limpando ---"
apt-get -yq autoremove
apt-get -yq autoclean
echo "[OK] --- Ambiente de desenvolvimento concluido ---"
以上是关于sh Scriptparainstalaçãodospacotes Apache,MySQL e PHP 7.2 mais phpMyAdmin e xDebug no siste的主要内容,如果未能解决你的问题,请参考以下文章