Skip to content

Instantly share code, notes, and snippets.

@uluumbch
Last active May 27, 2023 10:35
Show Gist options
  • Save uluumbch/41646e12f77ed5e12b457a19553f5e89 to your computer and use it in GitHub Desktop.
Save uluumbch/41646e12f77ed5e12b457a19553f5e89 to your computer and use it in GitHub Desktop.
Cara install NGINX PHP Composer NPM dan Node JS di ubuntu
#!/bin/bash
# Update the system
sudo apt update
sudo apt upgrade -y
# Install PHP dependencies
sudo apt install -y software-properties-common
# Add the ondrej/php repository for PHP 8.2
sudo add-apt-repository ppa:ondrej/php -y
# Update the package lists
sudo apt update
# Install PHP 8.2 and required extensions
sudo apt install -y php8.2 php8.2-fpm php8.2-mysql php8.2-curl php8.2-gd php8.2-mbstring php8.2-xml php8.2-zip php8.2-bcmath php8.2-common
# Install Nginx
sudo apt install -y nginx
# Start and enable PHP-FPM service
sudo systemctl start php8.2-fpm
sudo systemctl enable php8.2-fpm
# Create a new Nginx configuration file
sudo tee /etc/nginx/sites-available/my-site <<EOF
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.php index.html index.htm;
server_name _;
location / {
try_files \$uri \$uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
EOF
# Create a symlink to enable the new configuration
sudo ln -s /etc/nginx/sites-available/my-site /etc/nginx/sites-enabled/
# Remove the default configuration symlink
# sudo rm /etc/nginx/sites-enabled/default
sudo unlink /etc/nginx/sites-enabled/default
# Restart Nginx service
sudo systemctl restart nginx
# Enable firewall
sudo ufw enable
# Allow SSH (port 22)
# sudo ufw allow OpenSSH
# Allow HTTP (port 80)
sudo ufw allow 'Nginx Full'
# Reload firewall rules
sudo ufw reload
#!/bin/bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
nvm install node
# instalasi composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
  1. Jalankan perintah
wget https://gist.github.com/uluumbch/41646e12f77ed5e12b457a19553f5e89/raw/1174c79a45bf670a7b875d983f6631c35fe41f08/install_php_nginx.sh
  1. kemudian
wget https://gist.github.com/uluumbch/41646e12f77ed5e12b457a19553f5e89/raw/1174c79a45bf670a7b875d983f6631c35fe41f08/node-composer.sh
  1. instalasi nginx dan php
sudo chmod +x ./install_php_nginx.sh
./install_php_nginx.sh
  1. instalasi composer dan node
sudo chmod +x ./node-composer.sh.sh
./node-composer.sh.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment