Showing posts with label Nginx. Show all posts
Showing posts with label Nginx. Show all posts

Monday, August 29, 2016

Service nginx reload Return Fail


When I check "tail /var/log/nginx/error.log", i see notify that "could not build the server_names_hash, you should increase either server_names_hash_max_size: 512 or server_names_hash_bucket_size: 64" If you met reference, then add 2 the line:
server_names_hash_bucket_size 64;
server_names_hash_max_size 4112;


user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
 worker_connections 768;
}

http {


 sendfile on;
 tcp_nopush on;
 tcp_nodelay on;
 keepalive_timeout 65;
 types_hash_max_size 2048;
        #Enable server_names_hash_bucket_size 64;
 server_names_hash_bucket_size 64;
        #Add server_names_hash_max_size 4112;
 server_names_hash_max_size 4112;
 include /etc/nginx/mime.types;
 default_type application/octet-stream;


 access_log /var/log/nginx/access.log;
 error_log /var/log/nginx/error.log;


 gzip on;
 gzip_disable "msie6";




 


 include /etc/nginx/conf.d/*.conf;
 include /etc/nginx/sites-enabled/*;
}
Read More

Thursday, June 30, 2016

Tạo bash shell tự khởi động lại service khi bị tắt trên ubuntu

Tạo bash shell tự khởi động lại service khi bị tắt trên ubuntu
Tạo bash shell tự khởi động lại service khi bị tắt trên ubuntu
Đến đường dẫn
cd ~/
nano autorun
Tạo tập tin
#!/bin/bash
service=apache2

if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service start
fi
Tạo chạy tự động bằng crontab
crontab -e
* * * * * ~/autorun
Read More

Thursday, April 28, 2016

Tạo site wordpress chạy nhanh nhanh bằng Easy Engine

Tạo site wordpress chạy nhanh nhanh bằng Easy Engine
Tạo site wordpress chạy nhanh nhanh bằng Easy Engine

ee site create mysite.org --hhvm --pagespeed --wpredis

Google--pagespeed
Facebook--hhvm
Page Cache--wpredis
Read More

Monday, April 25, 2016

Cài đặt Nginx trên Ubuntu để dùng Phalcon

Cài đặt Nginx trên Ubuntu để dùng Phalcon
Cài đặt Nginx trên Ubuntu để dùng Phalcon

#Tải mới phiên bản Ubuntu
apt-get update && apt-get upgrade

#Cài đặt nginx
apt-get install nginx

#Cài đặt Mysql
apt-get install mariadb-server mariadb-client

#Cài đặt bảo mật cho mysql
mysql_secure_installation

#Cài đặt php và extension để bun được phalcon
apt-get install php5-fpm php5-mysql php5-dev php5

#Di chuyển đến nơi chứa thư mục mặt định của web
cd /usr/share/nginx/html

#Nếu bước này không thực hiện thì sẽ không build được phalcon
apt-get install git-core gcc autoconf make libpcre3-dev

#Di chuyển đến thư mục ~ Home
cd ~

#Tạo Swap Ram để cài đặt phalcon nhanh hơn
dd if=/dev/zero of=/swapfile bs=2048 count=1024k
mkswap /swapfile
chmod 600 /swapfile
chown root:root /swapfile
swapon /swapfile

#Kiểm Tra
free -m

#Xoá cache trên ram thật và ram ảo
echo 3 > /proc/sys/vm/drop_caches

#Tải framework phalcon về thưc mục Home
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build/
./install

#Tạo thêm file phalcon.ini
cd /etc/php5/mods-available/
nano phalcon.ini
cd ..

#Chép qua thư mục cli nữa
cd cli/

#Đây là câu lệnh tạo file shortcut
ln -s /etc/php5/mods-available/phalcon.ini .

#Chép qua thư mục conf.d
cd conf.d/
ln -s /etc/php5/mods-available/phalcon.ini .

#Chép qua thưc mục fpm
cd fpm/
ln -s /etc/php5/mods-available/phalcon.ini .
cd conf.d/
ln -s /etc/php5/mods-available/phalcon.ini .

#Khởi động lại php
service php5-fpm restart

#Tạo thêm file config
cd /etc/nginx/sites-available/

#Copy thêm mới 1 file từ file cũ
cp default phalcon.demo

#Mở lên bằng nano
nano phalcon.demo
service nginx reload
nano phalcon.demo

#Di chuyển đến html thư mục
cd /usr/share/nginx/html/

#Tạo thư mục phalcon.demo để chứa source
mkdir phalcon.demo
#Sau đó bỏ 1 file html tuỳ ý vào

#Tạo shortcut cho tệp tin config để nginx reload được
/etc/nginx/sites-available/phalcon.demo /etc/nginx/sites-enabled/

service nginx reload

#Cài đặt phalcon Dev
clone https://github.com/phalcon/phalcon-devtools.git

git clone https://github.com/phalcon/phalcon-devtools.git
/opt/phalcon-devtools/
Read More

Chỉnh Phalcon khi dùng Nginx trên Ubuntu 14.02

Chỉnh Phalcon khi dùng Nginx trên Ubuntu 14.02
Chỉnh Phalcon khi dùng Nginx trên Ubuntu 14.02

server {
        listen 80;
        #listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html/namefolder/public;
        index index.php index.html index.htm;
        server_name domain;



 # Chức năng này để giúp Nginx bật mod_rewrite


       location / {
                try_files $uri $uri/ /index.php?_url=$uri&$args;
        }





 

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}
Read More