Created
December 21, 2012 17:18
-
-
Save mariusv/4354186 to your computer and use it in GitHub Desktop.
Install apache/mysql/php
This file contains hidden or 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
#!/bin/bash | |
set -e | |
MY_PATH="$( cd "$( dirname "$0" )" && pwd )" | |
echo Now w are updating the system please wait till the process will end | |
apt-get update && apt-get upgrade -y | |
read -p "What path would you like to use for Apache virtualhosts? (For example, /srv or /var/www) " VHOST_PATH | |
echo | |
echo Install Apache and PHP5 | |
echo | |
apt-get -y install apache2 php5 php5-mysql php5-gd libapache2-mod-php5 php5-curl | |
echo | |
echo Set Hostname | |
echo | |
read -p "What hostname would you like to use? " MY_HOSTNAME | |
echo $MY_HOSTNAME > /etc/hostname | |
hostname -F /etc/hostname | |
echo "ServerName $MY_HOSTNAME" >> /etc/apache2/httpd.conf | |
echo | |
echo Install MySQL | |
echo | |
sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y install mysql-server | |
echo | |
echo PHP configuration | |
echo | |
sed -i'-orig' 's/memory_limit = [0-9]\+M/memory_limit = 128M/' /etc/php5/apache2/php.ini | |
sed -i'-orig' 's/session.gc_maxlifetime = [0-9]\+/session.gc_maxlifetime = 7776000/' /etc/php5/apache2/php.ini | |
sed -i'-orig' 's/session.cookie_lifetime = [0-9]\+/session.cookie_lifetime = 7776000/' /etc/php5/apache2/php.ini | |
echo | |
echo Apache configuration | |
echo | |
a2enmod rewrite | |
/etc/init.d/apache2 restart | |
echo | |
echo Apache virtualhost logrotate config | |
echo | |
cat > /etc/logrotate.d/virtualhosts << EOF | |
$VHOST_PATH/logs/*.log { | |
weekly | |
missingok | |
rotate 3 | |
nocompress | |
notifempty | |
create 644 root root | |
sharedscripts | |
postrotate | |
if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then | |
/etc/init.d/apache2 reload > /dev/null | |
fi | |
endscript | |
} | |
EOF | |
echo | |
echo Please provide an MySQL server password for the root user | |
echo | |
dpkg-reconfigure mysql-server-5.5 | |
echo | |
echo Done! | |
echo | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment