├── README.md └── ubuntu-16.06-lamp-laravel.sh /README.md: -------------------------------------------------------------------------------- 1 | # Server Deploy Scripts 2 | Most required shell scripts to setup your server for the first time, install all the required components such as Apache, PHP, MySQL, Git even setup virtual host easily with single click. 3 | -------------------------------------------------------------------------------- /ubuntu-16.06-lamp-laravel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04 4 | # https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04 5 | 6 | # PHP My Admin Secure 7 | # https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-16-04 8 | 9 | # ================================================= 10 | # At many places it will ask for your inputs for using disk space 11 | # or for configurations 12 | # ================================================= 13 | 14 | # Update 15 | sudo apt-get update 16 | 17 | # Install cURL & ZIP/UNZIP 18 | sudo apt-get install curl 19 | sudo apt-get install zip unzip 20 | 21 | # Install Apache 22 | sudo apt-get install apache2 23 | # Y to allow to use disk space 24 | echo "Apache Installed Successfully!" 25 | 26 | # Check Firewall Configurations 27 | echo "Your firewall configuration is." 28 | sudo ufw app list 29 | sudo ufw app info "Apache Full" 30 | sudo ufw allow in "Apache Full" 31 | sudo ufw allow 22 32 | sudo ufw allow 80 33 | sudo ufw allow 443 34 | 35 | echo "You can check whether the apache is installed properly by accessing public URL/server IP address." 36 | # If you can see the page then Apache installation is successful. 37 | 38 | # To Remove Existing MySQL Server 39 | #sudo apt-get remove --purge mysql-server mysql-client mysql-common 40 | #sudo apt-get remove --purge mysql-* 41 | #sudo apt-get autoremove 42 | #sudo apt-get autoclean 43 | # Other Important Commands 44 | # sudo dpkg --configure mysql-server-5.5 45 | 46 | 47 | # Install MySQL Server 48 | sudo apt-get install mysql-server 49 | # Y to allow to use disk space 50 | # Enter password for MySQL Root User, Please remeber the password. (Sample ROOT Password: T1umoN23X8W9tPAlQS9) 51 | 52 | sudo mysql_secure_installation 53 | # This asks you if you want to enable secured password for your server. 54 | # Press y|Y, if you want to allow VALIDATE PASSWORD PLUGIN to be used. 55 | # If you select Yes, then it will ask you for password strength 56 | # And to reset password if required (Sample Secure Password : Haksfuh@sfeGa23VhP3) 57 | 58 | echo "MySQL Server Installed Successfully!" 59 | 60 | # Install PHP 61 | sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql 62 | # Y to allow to use disk space 63 | 64 | # Inform Apache to prefer php files over html files 65 | # sudo nano /etc/apache2/mods-enabled/dir.conf 66 | # Move the index.php at first place 67 | 68 | # Install PHP Required Extensions 69 | sudo apt-get install php-cli php-mbstring php-gettext php-curl 70 | sudo phpenmod mcrypt 71 | sudo phpenmod mbstring 72 | sudo phpenmod curl 73 | echo "php-cli, curl, mcrypt, mbstring Installed Successfully!" 74 | 75 | sudo a2enmod rewrite 76 | sudo a2enmod ssl 77 | 78 | # Install PHP Dev 79 | sudo apt install php7.0-dev 80 | echo "php7.0-dev Installed Successfully!" 81 | 82 | sudo apt-get install php7.0-intl 83 | echo "php7.0-intl Installed Successfully!" 84 | 85 | # Install PHP Zip Extension 86 | # sudo apt-get install php7.0-zip 87 | # echo "PHP Zip Extension Installed Successfully!" 88 | 89 | 90 | # Restart Apache Server 91 | sudo systemctl restart apache2 92 | # To See Apache Status 93 | # sudo systemctl status apache2 94 | 95 | echo "Your Home Directory is /var/www/html/. You can start using that Home Directory." 96 | 97 | # PHPMyAdmin & Other Extensions 98 | echo "Installing PHPMyAdmin for DB Access & Other Extensions." 99 | sudo apt-get install phpmyadmin 100 | # For the server selection, choose apache2. 101 | # Select yes when asked whether to use dbconfig-common to set up the database 102 | # You will be prompted for your database administrator's password 103 | # You will then be asked to choose and confirm a password for the phpMyAdmin application itself 104 | 105 | # ================================================= 106 | # Installing Laravel Specific and other required things 107 | # such as Git, Composer, Redis for easy PHP Development 108 | # ================================================= 109 | 110 | # Install Redis 111 | # We will need to compile redis from its source. Thus need to install other two packages 112 | sudo apt-get install build-essential 113 | sudo apt-get install tcl8.5 114 | 115 | cd /usr/local/bin 116 | sudo wget http://download.redis.io/releases/redis-3.2.0.tar.gz 117 | sudo tar xzf redis-3.2.0.tar.gz 118 | cd redis-3.2.0 119 | sudo make 120 | sudo make test 121 | sudo make install 122 | cd utils 123 | sudo ./install_server.sh 124 | echo "Redis Server Installed Successfully!" 125 | # To Start/Stop Server 126 | # sudo service redis_6379 start 127 | # sudo service redis_6379 stop 128 | echo "Disable Redis to listen 127.0.0.1 for security purposes." 129 | sudo nano /etc/redis/6379.conf 130 | 131 | sudo update-rc.d redis_6379 defaults 132 | echo "Redis Server Set to Start at boot!" 133 | 134 | # Install GIT 135 | sudo apt-get install git 136 | echo "Git Installed Successfully!" 137 | git config --global user.name "Your Name" 138 | git config --global user.email "youremail@domain.com" 139 | 140 | # Install Composer 141 | curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer 142 | echo "Composer Installed Successfully!" 143 | 144 | # Install Supervisord 145 | # https://www.digitalocean.com/community/tutorials/how-to-install-and-manage-supervisor-on-ubuntu-and-debian-vps 146 | sudo apt-get install supervisor 147 | sudo service supervisor restart 148 | # Can add the superviser configs to /etc/supervisor/conf.d 149 | # sudo supervisorctl reread 150 | # sudo supervisorctl update 151 | 152 | # ================================================== 153 | # Attach a new HDD and mount it to var/www 154 | # ================================================== 155 | sudo lshw -C disk 156 | sudo fdisk /dev/sdc 157 | # Default inputs sequence 158 | # n = new partition 159 | # p = primary 160 | # w = write to partition table & exit 161 | # p = view partitions 162 | # Format disk 163 | sudo mkfs -t ext3 /dev/sdc1 164 | # Mount disk 165 | sudo mount /dev/sdc1 /var/www/folder 166 | # Automatic mount at startup, Add this line to file 167 | # sudo nano -Bw /etc/fstab 168 | # /dev/sdc1 /var/www/folder ext3 defaults 0 2 169 | # Change owner of disk 170 | sudo chown -R root:root /var/www/folder 171 | 172 | 173 | # ================================================== 174 | # Google Page Speed Module install 175 | # ================================================== 176 | sudo dpkg -i mod-pagespeed-*.deb 177 | sudo apt-get -f install 178 | 179 | # ================================================== 180 | # Create Virtual Host for the server 181 | # ================================================== 182 | 183 | # Downloading Script to Create Virutal Hosts 184 | cd /usr/local/bin 185 | sudo wget -O virtualhost https://raw.githubusercontent.com/RoverWire/virtualhost/master/virtualhost.sh 186 | sudo chmod +x virtualhost 187 | 188 | # Set Virtual Host Name 189 | sudo virtualhost create mysite.dev 190 | sudo systemctl restart apache2 191 | 192 | # Git Clone your Site 193 | git clone https://github.com/git/git.git /var/www/mysite.dev 194 | 195 | # Composer Update 196 | cd /var/www/mysite.dev 197 | composer install 198 | 199 | 200 | # ================================================== 201 | # Add a Monitor to keep MySQL, Apache, Supervisor, Redis started in case of any failure 202 | # ================================================== 203 | 204 | # https://www.digitalocean.com/community/tutorials/how-to-use-a-simple-bash-script-to-restart-server-programs --------------------------------------------------------------------------------