Created
February 3, 2017 17:31
-
-
Save jlainezs/5bf9b9cb17de655b63e144931dfe2356 to your computer and use it in GitHub Desktop.
Provision a LAMP stack for ubuntu 14.04 with PHP 7.0 and MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# update default packages | |
apt-get update && apt-get -y upgrade | |
ROOTPASS="rootpass" | |
# MySQL | |
debconf-set-selections <<< "mysql-server mysql-server/root_password password $ROOTPASS" | |
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $ROOTPASS" | |
apt-get -y install mysql-server mysql-client | |
# Allows root access from anywhere | |
mysql -uroot -p$ROOTPASS -e "grant all privileges on *.* to 'root'@'%' IDENTIFIED by '$ROOTPASS'; flush privileges;" | |
# Configure MySQL options | |
sed -i "s/bind-address = .*/bind-address = 0.0.0.0/" /etc/mysql/my.cnf | |
service mysql restart | |
# Apache | |
apt-get -y install apache2 | |
# PHP | |
add-apt-repository ppa:ondrej/php | |
apt-get update | |
apt-get -y install php7.0 | |
apt-get -y install php7.0-fpm | |
service apache2 restart | |
apt-get -y install php7.0-mysql | |
apt-get -y install php7.0-mbstring php7.0-curl php7.0-gc php7.0-imap php7.0-mcrypt | |
apt-get -y install php7.0-xmlrpc php7.0-json php7.0-sqlite3 php7.0-bz2 php7.0-xml php7.0-zip | |
apt-get -y install php7.0-xdebug | |
# Configure PHP Options | |
sed -i "s/error_reporting = .*/error_reporting = E_ALL/" /etc/php/7.0/apache2/php.ini | |
sed -i "s/display_errors = .*/display_errors = On/" /etc/php/7.0/apache2/php.ini | |
sed -i "s/upload_max_filesize = .*/upload_max_filesize = 20M/" /etc/php/7.0/apache2/php.ini | |
sed -i "s/max_file_uploads = .*/max_file_uploads = 30/" /etc/php/7.0/apache2/php.ini | |
sed -i "s/post_max_size = .*/post_max_size = 30M/" /etc/php/7.0/apache2/php.ini | |
mkdir /home/vagrant/tmp | |
cat > /etc/php/7.0/apache2/conf.d/20-xdebug.ini << EOF | |
zend_extension=xdebug.so | |
xdebug.remote_enable = 1 | |
xdebug.remote_port=9000 (the default port is 9000) | |
xdebug.profiler_enable=0 | |
xdebug.profiler_output_dir=/home/vagrant/tmp | |
EOF | |
# Enable Apache modules | |
a2enmod rewrite | |
a2enmod proxy_fcgi setenvif | |
a2enconf php7.0-fpm | |
# Configure Apache default Virtual host | |
cat > /etc/apache2/sites-available/000-default.conf << EOF | |
<VirtualHost *:80> | |
DocumentRoot /var/www/html | |
ErrorLog ${APACHE_LOG_DIR}/error.log | |
<Directory /var/www/html/> | |
AllowOverride All | |
DirectoryIndex index.php | |
</Directory> | |
</VirtualHost> | |
EOF | |
# Finish apache configuration | |
service apache2 restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment