Last active
August 12, 2019 14:17
-
-
Save izshreyansh/91d0b3bc92736c287f86e2a4517c6d60 to your computer and use it in GitHub Desktop.
Laravel Deployment Checklist
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
# laravel-deployment | |
- [ ] Install apache | |
- `sudo systemctl start apache2`: Manage apache [stop,status,restart,reload,disable,enable] | |
- [Install apache](https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04) | |
- `sudo a2enmod rewrite` enable mod rewrite | |
- `<Directory /var/www/domain.com/public> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride All | |
Require all granted | |
</Directory> | |
RewriteEngine on | |
RewriteCond %{SERVER_NAME} =domain.com | |
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] | |
</VirtualHost>` Keep mod rewrite on within conf file | |
[ ] Fix permissions | |
- `sudo chown -R $USER:$USER /var/www/your_domain.com` | |
- `sudo usermod -a -G ubuntu www-data` add www-data user to `ubuntu` group | |
- `sudo chmod -R 775 /var/www/your_domain.com` Elevate `ubuntu` group permission | |
- [ ] Enable Firewall | |
- `ufw enable`: Enable firewall [status,app list,disable] | |
- `ufw allow Apache Full`: update rules to accomodate apache | |
- `ufw allow OpenSSH` : Make sure you don't get locked out | |
- [ ] Install PHP | |
- `sudo apt-get install -y php libapache2-mod-php7.2 php7.2-cli php7.2-common php7.2-mbstring php7.2-gd php7.2-intl php7.2-xml php7.2-mysql php7.2-zip` | |
OR | |
- `sudo apt install php libapache2-mod-php php-mysql` Install PHP | |
- `sudo apt-get install php7.2-curl` install curl for php | |
- Change the `/etc/apache2/mods-enabled/dir.conf` file | |
- `apt search php- | less` browse additional packages. | |
- `install sudo apt install php-cli` install additional package of your requirement. | |
- [ ] Install mysql-server | |
- `mysql_secure_installation`: run this command after installation for better security. | |
In the interactive promt, create new user & assign password to root user,Choose to remove annonymous user. | |
- `mysql -u USER -p` check if user was created properly. | |
- [ ] Install GIT :octocat: | |
- [ ] Install nodejs & npm | |
- `sudo apt install nodejs npm` | |
- [ ] Install [composer](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-16-04) | |
- [ ] Install redis | |
- Install redis on [ubuntu 16.04](https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04) | |
- [ ] Setup [virtual host](https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts) | |
- `sudo nano /etc/apache2/sites-available/example.com.conf` | |
- `sudo a2ensite sitename.conf` | |
- Don't forget to add the following to enable [mod_rewrite](https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite-for-apache-on-ubuntu-14-04) : | |
``` | |
<VirtualHost *:80> | |
<Directory /var/www/html> | |
Options Indexes FollowSymLinks MultiViews | |
AllowOverride All | |
Require all granted | |
</Directory> | |
</VirtualHost> | |
``` | |
- `sudo a2enmod rewrite` | |
- [ ] Install [supervisor](https://laravel.com/docs/5.7/queues#supervisor-configuration) & set up queue | |
- [ ] Start [cron](https://laravel.com/docs/5.7/scheduling#introduction) service | |
- [ ] Install [certbot](https://certbot.eff.org/lets-encrypt/ubuntubionic-apache) | |
- [ ] Setup cron to run this command: `sudo certbot renew` every 80 days | |
- [ ] Add [Swap](https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-18-04) Space if necessary | |
- [ ] Setup basic [FTP server](https://askubuntu.com/questions/1722/basic-ubuntu-ftp-server) [Second Reference](https://help.ubuntu.com/community/PureFTP) | |
> I'm going to recommend PureFTPD because it's been the simplest and easiest to use in my opinion. You'll need to install it first: `sudo apt-get install pure-ftpd` once it's installed it'll start itself up. By default it uses PAM Authentications - meaning it uses the accounts which already exist on the system for it's auth. All you'll need to do is create a user account with the home directory being your www path and set the password for that account. You should then be able to connect with that user/pass combination to upload/download files. | |
Something like this: | |
`sudo adduser ftpman --home /var/www/ --ingroup www-data` | |
Which will create the ftpman user and put him in the www-data group which Apache uses and will walk you through the rest of the setup script. Once that's defined make sure to chmod the WWW folder if you get errors about it already existing to the user/group combination you created. | |
- [ ] Improve Performance | |
- Cache: [view,route,config] | |
- use `composer install --no-dev -a` which will optimize autoloader classes. (And stop looking for classes in filesystem) | |
- PHP is converted into OPCODE & then executed by your server. In prod your files won't change, Therefore you wouldn't want to convert them every single time. | |
In order to change that: In your `php.ini` file: `opcache_enable=1` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment