Skip to content

Instantly share code, notes, and snippets.

@wmfairuz
Last active October 2, 2019 13:18
Show Gist options
  • Save wmfairuz/4d474de281a3b40e6975465c0d931d72 to your computer and use it in GitHub Desktop.
Save wmfairuz/4d474de281a3b40e6975465c0d931d72 to your computer and use it in GitHub Desktop.
PHP 7.3 on Ubuntu 18.04
apt update
apt install -y software-properties-common language-pack-en-base
add-apt-repository ppa:ondrej/php
apt update
apt install -y nginx curl git unzip composer mysql-client supervisor
apt install -y php7.3 php7.3-fpm php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-mysql php7.3-mbstring php7.3-soap php7.3-zip php7.3-gd php7.3-intl php7.3-xml php7.3-curl php7.3-ldap php7.3-sybase
apt install -y php-dev libmcrypt-dev php-pear
pecl channel-update pecl.php.net
mkdir /root/tmp
pear config-set temp_dir /root/tmp
pecl install mcrypt-1.0.2
## put extension=mcrypt.so in both /etc/php/7.3/cli/php.ini and /etc/php/7.3/fpm/php.ini
systemctl restart nginx
systemctl restart php7.3-fpm
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security 'max-age=15768000; preload';
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.cloudflare.com https://ssl.google-analytics.com https://assets.zendesk.com https://connect.facebook.net; img-src 'self' https://ssl.google-analytics.com https://s-static.ak.facebook.com https://assets.zendesk.com; style-src 'self' 'unsafe-inline' https://unpkg.com https://fonts.googleapis.com https://assets.zendesk.com; font-src 'self' data: https://fonts.gstatic.com https://themes.googleusercontent.com; frame-src https://assets.zendesk.com https://www.facebook.com https://s-static.ak.facebook.com https://tautt.zendesk.com; object-src 'self'";
server {
listen 80;
listen [::]:80;
root /opt/myproject/public;
server_name _;
index index.html index.htm index.php;
charset utf-8;
client_max_body_size 10M;
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php {
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment