Skip to content

Instantly share code, notes, and snippets.

@hiendnguyen
hiendnguyen / Virtual-RAM.sh
Last active April 22, 2020 20:39
CentOS 7 Virtual RAM
# In this case, I use 2G swapfile or virtual RAM
sudo dd if=/dev/zero of=/swapfile count=1024 bs=1MiB
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
@hiendnguyen
hiendnguyen / LEMP.sh
Last active January 11, 2018 13:43
CentOS 7 LEMP
# Install Nginx
sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
# Install MySQL (MariaDB)
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb
@hiendnguyen
hiendnguyen / reCAPTCHA_Wooc.php
Last active May 5, 2017 21:50
Add reCAPTCHA to WooCommerce Signup Form
<?php
/* wooc_reCAPTCHA */
// Add reCAPTCHA to WooCommerce Signup Form
function wooc_reCAPTCHA(){
?>
<script src='https://www.google.com/recaptcha/api.js' defer'></script>
<label>ARE YOU HUMAN?</label>
<div class="g-recaptcha" data-sitekey="[reCAPTCHA Site Key]"></div>
@hiendnguyen
hiendnguyen / nginx-uwsgi-django.conf
Last active November 3, 2019 06:21
NGINX config for uWSGI and Django
vi /etc/nginx/conf.d/django.conf
# Put below content in it.
# the upstream component NGINX needs to connect to
upstream django {
server unix:/run/uwsgi/django.sock;
}
# configuration of the server
server {
@hiendnguyen
hiendnguyen / djangodemo_uwsgi.ini
Last active November 3, 2019 06:22
Configure uWSGI as service
# Create 'uwsgi' user: unprivileged user
useradd -s /bin/false -r uwsgi
# Emperor mode
## create a directory for the vassals
- mkdir -p /etc/uwsgi/vassals
## Configuring uWSGI to run with a .ini file
vi /var/www/example/djangodemo/djangodemo_uwsgi.ini
### Put below content in djangodemo_uwsgi.ini
@hiendnguyen
hiendnguyen / uwsgi.service
Last active November 3, 2019 05:11
Configure uWSGI server and let's make it runs as a service
vi /etc/systemd/system/uwsgi.service
# Put below as its content
[Unit]
Description=uWSGI Emperor service
[Service]
ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown uwsgi:nginx /run/uwsgi'
ExecStart=/var/www/p3venv/bin/uwsgi --emperor /etc/uwsgi/vassals
from selenium import webdriver
driver = webdriver.Chrome(executable_path="C:/VNTesters/chromedriver.exe")
driver.get ("https://vntesters.com/")
print (driver.title)
driver.quit()
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /var/www/vndeveloper/djangodemo/
# Django's wsgi file
module =djangodemo.wsgi
# the virtualenv (full path)
home = /var/www/p3venv
# the upstream component NGINX needs to connect to
upstream django {
server unix:/run/uwsgi/django.sock;
}
server {
listen 80;
server_name www.vndeveloper.com;
charset utf-8;