The setup installs the following software:
The setup installs the following software:
- Apache
- MySQL
- PHP
- Node
- Composer
- Git
apt-get update && apt-get dist-upgrade -y
apt-get autoremove -y
Instead of using root as the user, we add a new one.
adduser <username>
usermod -aG sudo <username>
apt-get install -y \
build-essential \
python-software-properties \
python \
g++ \
make \
fail2ban \
curl \
git \
htop \
ntp \
ntpdate \
unzip \
nano
dpkg-reconfigure tzdata
sudo apt-get install apache2
sudo ufw app list
sudo ufw allow in "Apache Full"
sudo ufw allow in "OpenSSH"
sudo ufw enable
sudo ufw status verbose
Open up the Apache main configuration file
sudo nano /etc/apache2/apache2.conf
Inside, at the bottom of the file, add a ServerName directive, pointing to your primary domain name or your server's public IP address
```
. . .
ServerName server_domain_or_IP
```
Test the config and restart apache
sudo apache2ctl configtest
sudo systemctl restart apache2
Enable Apache mod_rewrite
sudo a2enmod rewrite
sudo systemctl restart apache2
sudo apt-get install mysql-server
sudo mysql_secure_installation
You should check the instructions for the php version you need
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
Tweak how apache serves files
sudo nano /etc/apache2/mods-enabled/dir.conf
Change From
```
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
```
To
```
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
```
Restart & Check status
sudo systemctl restart apache2
sudo systemctl status apache2
Install php-cli
sudo apt-get install php-cli
This does all the tricks
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
apt-get install -y nodejs
Install npm
npm update -g
Create the file
sudo fallocate -l 4G /swapfile
Enable the swap file and set the correct permissions
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Make the the Swap File Permanent, edit the following file
sudo nano /etc/fstab
Go to the bottom of the file and add the following line
/swapfile none swap sw 0 0
Tweak how much of the swap the system uses
sudo nano /etc/sysctl.conf
Insert the following lines at the bottom of the file
vm.swappiness=10
vm.vfs_cache_pressure = 50
###(Good Idea to take the Snapshot of your droplet at this point)
Upload your laravel project to the webroot folder and configure the correct right permissions
sudo chgrp -R www-data /var/www/html/project
sudo chmod -R 775 /var/www/html/project/storage
Now configure the vhost for your project
cd /etc/apache2/sites-available
sudo nano laravel.conf
Paste this in the file
<VirtualHost *:80>
ServerName domain or server_ip
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/project/public
<Directory /var/www/html/project>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Disable the default.conf & Enable the laravel.conf file. Enable mod_rewrite & restart apache.
sudo a2dissite 000-default.conf
sudo a2ensite laravel.conf
sudo a2enmod rewrite
sudo service apache2 restart
Good people it is done, go to the ip address or domain to check if things are sane. If not look for minor things like db config, keys etc.
If you get errors when running comppser install, this steps will do the trick
sudo apt-get update
sudo apt-get install mcrypt php7.0-mcrypt
sudo apt-get upgrade
sudo apt-get install php-mbstring
sudo apt-get install phpunit
The above step installs the missing dependecies.
##Thanks #Notes
- Try using laravel forge or cloudways if this process was a pain to you. I highly recommend Ploi.io
- Check out Docker
- Test extensively and create a snapshot or create a backup of this point as well
Thank you very much, help me alot