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 \
mcedit \
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 -y
sudo mysql_secure_installation
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.1 php7.1-common -y
sudo apt-get install php7.1-curl php7.1-xml php7.1-zip php7.1-gd php7.1-mysql php7.1-mbstring -y
Tweak how apache serves files
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
This does all the tricks
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
Note: On Linux, after running the install script, if you get nvm: command not found, simply close your current terminal, open a new terminal, and try verifying again.
Install npm
nvm install node
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
sudo mkdir /var/www/html/projects
cd /var/www/html/projects
composer create-project laravel/laravel <my-project-name> --prefer-dist
sudo chgrp -R www-data /var/www/html/projects
sudo chmod -R 775 /var/www/html/projects/<my-project-name>/storage/
Now configure the vhost for your project
cd /etc/apache2/sites-available
sudo nano <my-project-name>.conf
Paste this in the file
<VirtualHost *:80>
ServerName <domain or server IP>
ServerAdmin <my-email>
DocumentRoot /var/www/html/projects/<my-project-name>/public
<Directory /var/www/html/projects/<my-project-name>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Disable the default.conf & Enable the .conf file. Enable mod_rewrite & restart apache.
sudo a2dissite 000-default.conf
sudo a2ensite <my-project-name>.conf
sudo a2enmod rewrite
sudo service apache2 restart
sudo apt-get install git
git config --global user.name "<your-name>"
git config --global user.email "<your-email>"
git config --list
As you can see, this has a slightly different format. The information is stored in your git configuration file, which you can optionally edit by hand with your text editor like this:
nano ~/.gitconfig