web2iran.ir
July 27th, 2015, 11:37
آموزش نصب و کانفیگ NGINX به عنوان REVERSE *****
Nginx یک وب سرور ، reverse ***** و mail ***** قدرتمند، متن باز ، کم حجم و با کارایی بالا برای پروتکل های HTTP ، SMTP ، POP3 و IMAP می باشد که به عنوان جایگزینی برای آپاچی عمل میکند. هم Nginx و هم آپاچی (http://compiler.ir/%d8%a2%d9%be%d8%a7%da%86%db%8c-%d9%86%d8%b3%d8%ae%d9%87-apache-httpd-2-4-7-%d8%b1%db%8c%d9%84%db%8c%d8%b2-%d8%b4%d8%af/)سرورهای قدرتمند و موثری هستند. دلایل محبوبیت هردو سرور روشن است، آپاچی به دلیل قدرت و Nginx به دلیل سرعت آن ، به خوبی شناخته شده هستند. Nginx در سرویس دهی به فایل های استاتیک سریعتر عمل کرده و حافظه ی بسیار کمتری برای درخواست های همزمان مصرف میکند و به دلیل ساختارش قادر است با منابع کمتر به درخواست های بیشتری در هر ثانیه سرویس دهی کند.
آموزش نصب و کانفیگ NGINX به عنوان REVERSE *****
Nginx (http://compiler.ir/%D9%88%D8%A8-%D8%B3%D8%B1%D9%88%D8%B1-nginx/) را میتوان در ساده ترین شکل به عنوان یک reverse ***** برای هر سایت استفاده کرد؛ که به منظور امنیت، کش کردن و فشرده سازی به صورت یک لایه واسط عمل می کند. یعنی به طور بالقوه کیفیت کلی سایت را بدون هیچ گونه تغییری در کد منبع برنامه، بالا می برد. reverse ***** یک نوع از ****** سرور است که منابع را برای یک کلاینت از یک یا چند سرور بازیابی میکند.
http://compiler.ir/wp-content/uploads/2015/03/4965os_abr1_1-300x228.png (http://compiler.ir/wp-content/uploads/2015/03/4965os_abr1_1.png)
آموزش نصب و کانفیگ nginx به عنوان reverse *****Nginx به عنوان ریورس پراکسی برای نصب، به CustomBuild 2.0 و php mode نیاز دارد. Custombuild اجازه می دهد که بدون نیاز به هیچ گونه اسکریپت یا پلاگینی یک reverse پراکسی Nginx سر راه آپاچی در دایرکت ادمین داشته باشیم. دایرکت ادمین (http://www.directadmin.com/) یکی از ساده ترین کنترل پنل های موجود است که دسترسی آسان به ایمیل، گزینه های مدیریتی، فایل منیجر و … را فراهم می کند و با سرور لینوکس RedHat ، CentOS ، FreeBSD و Debian سازگاری کامل دارد .
آموزش نصب و کانفیگ NGINX به عنوان REVERSE *****
نصب Nginx :
برای نصب Nginx به CustomBuild 2.0 نیاز خواهید داشت . درصورتی که در سیستم شما نصب نباشد، از راهنمای زیر برای ارتقاء به CustomBuild 2.0 استفاده کنید :
ارتقاء CustomBuild :
اگر از CustomBuild 1.1 یا ۱٫۲ استفاده میکنید و میخواهید آن را به نسخه ی ۲٫۰ ارتقا دهید ،باید در نظر داشته باشید که فرآیند ارتقا، فقط تغییر تنظیمات options.conf نیست، چون مقادیر option.conf در نسخه ۲٫۰ متفاوت است.
برای ارتقا به نسخه ۲٫۰ به همراه تمام گزینه های پیشفرض دستورات زیر را اجرا کنید :
1
2
3
4
5
6
cd /usr/local/directadmin
mv custombuild custombuild_1.x
wget –O custombuild.tar.gzhttp://files.directadmin.com/services/custombuild/2.0/custombuild.tar.gz
tar xvzf custombuild.tar.gz
cd custombuild
./build
در این مرحله، conf به طور پیش فرض ایجاد شد. اگر می خواهید از تمام گزینه های پیش فرض استفاده کنید ، از مرحله ۳ چشم پوشی کنید .
دستورات زیر را اجرا کنید:
1
2
./build all d
./build rewrite_confs
عملکرد بین نسخه های مختلف CustomBuild متفاوت است، بنابراین برای اینکه بدانید از کدام نسخه CustomBuild استفاده میکنید (۱٫۱، ۱٫۲ و یا ۲٫۰) دستور زیر را اجرا کنید:
1
2
cd /usr/local/directadmin/custombuild
./build version
برای مثال :
1
2
[root@server custombuild]# ./build version
2.0.0–RC7 (rev: 798)
برای اسکریپت های قدیمی تر بجای دستور فوق ، دستور زیر را اجرا کنید :
1
2
cd /usr/local/directadmin/custombuild
grep BUILDSCRIPT_VER build
شما می توانید مرحله دوم نصب CB2 را هم اکنون یا در زمان دیگری اجرا کنید . دستورات زیر را به منظور استفاده از Nginx و php-fpm برای تنظیم conf اجرا کنید :
1
2
3
4
5
./build set webserver nginx
./build set php1_mode php–fpm
./build update
./build all d
./build rewrite_confs
https://blog.web4asia.in/?p=116
- - - Updated - - -
و در اخر nginx رو ریست کنید تا فعال شه .service nginx restart
کانفیگ های nginx
#user nginx;
# The number of worker processes is changed automatically by CustomBuild, according to the number of CPU cores, if it's set to "1"
worker_processes 1;
pid /var/run/nginx.pid;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
events {
include /etc/nginx/nginx-events.conf;
}
http {
include /etc/nginx/mime.types;
# For user configurations not maintained by DirectAdmin. Empty by default.
include /etc/nginx/nginx-includes.conf;
# Supplemental configuration
include /etc/nginx/nginx-modsecurity-enable.conf;
include /etc/nginx/nginx-defaults.conf;
include /etc/nginx/nginx-gzip.conf;
include /etc/nginx/directadmin-ips.conf;
include /etc/nginx/directadmin-settings.conf;
include /etc/nginx/nginx-vhosts.conf;
include /etc/nginx/directadmin-vhosts.conf;
}
- - - Updated - - -
Modify NGINX templates
Copy
/usr/local/directadmin/data/templates/nginx_server.conf
/usr/local/directadmin/data/templates/nginx_server_sub.conf
to
/usr/local/directadmin/data/templates/custom/nginx_server.conf
/usr/local/directadmin/data/templates/custom/nginx_server_sub.conf
Modify the files
/usr/local/directadmin/data/templates/custom/nginx_server.conf
/usr/local/directadmin/data/templates/custom/nginx_server_sub.conf
change line:
*****_pass http://|IP|:|PORT_8080|; (http://%7Cip%7C:|PORT_8080|;/)
to
*****_pass http://|IP|:6081; (http://%7Cip%7C:6081;/)
Change 6081 to any other value of TCP post where Varnish is accepting connections.
Rewrite nginx virtual hosts:
echo "action=rewrite&value=nginx" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq
Have a good day!
- - - Updated - - -
If you want to add any extra modules to nginx, they'll most likely need to be compiled in. Any module that needs to be compiled in will have a --add-module type flag which will need to be used. To add this flag, run the following:cd /usr/local/directadmin/custombuild
mkdir -p custom/nginx
cp -fp configure/nginx/configure.nginx custom/nginx/configure.nginx
Add your --add-module line to the end of the custom/nginx/configure.nginx file, and make sure the \ character exists at the end of all lines except the last one. The \ character tells the line configure line to loop to the next line, making the configure settings easier to read. Without the \ character to trigger the wrap, the next line becomes a separate command, which is not correct. (see error below). Once set, type:./build used_configs
to ensure your custom configure.nginx file is being used. Then type:./build nginx
A common error people run into looks like this:/usr/local/directadmin/custombuild/custom/nginx/configure.nginx: line 32: --add-module: command not found
which simply means that the \ character was not correctly added on the line before --add-module.
- - - Updated - - -
https://blog.web4asia.in/?p=129
Nginx یک وب سرور ، reverse ***** و mail ***** قدرتمند، متن باز ، کم حجم و با کارایی بالا برای پروتکل های HTTP ، SMTP ، POP3 و IMAP می باشد که به عنوان جایگزینی برای آپاچی عمل میکند. هم Nginx و هم آپاچی (http://compiler.ir/%d8%a2%d9%be%d8%a7%da%86%db%8c-%d9%86%d8%b3%d8%ae%d9%87-apache-httpd-2-4-7-%d8%b1%db%8c%d9%84%db%8c%d8%b2-%d8%b4%d8%af/)سرورهای قدرتمند و موثری هستند. دلایل محبوبیت هردو سرور روشن است، آپاچی به دلیل قدرت و Nginx به دلیل سرعت آن ، به خوبی شناخته شده هستند. Nginx در سرویس دهی به فایل های استاتیک سریعتر عمل کرده و حافظه ی بسیار کمتری برای درخواست های همزمان مصرف میکند و به دلیل ساختارش قادر است با منابع کمتر به درخواست های بیشتری در هر ثانیه سرویس دهی کند.
آموزش نصب و کانفیگ NGINX به عنوان REVERSE *****
Nginx (http://compiler.ir/%D9%88%D8%A8-%D8%B3%D8%B1%D9%88%D8%B1-nginx/) را میتوان در ساده ترین شکل به عنوان یک reverse ***** برای هر سایت استفاده کرد؛ که به منظور امنیت، کش کردن و فشرده سازی به صورت یک لایه واسط عمل می کند. یعنی به طور بالقوه کیفیت کلی سایت را بدون هیچ گونه تغییری در کد منبع برنامه، بالا می برد. reverse ***** یک نوع از ****** سرور است که منابع را برای یک کلاینت از یک یا چند سرور بازیابی میکند.
http://compiler.ir/wp-content/uploads/2015/03/4965os_abr1_1-300x228.png (http://compiler.ir/wp-content/uploads/2015/03/4965os_abr1_1.png)
آموزش نصب و کانفیگ nginx به عنوان reverse *****Nginx به عنوان ریورس پراکسی برای نصب، به CustomBuild 2.0 و php mode نیاز دارد. Custombuild اجازه می دهد که بدون نیاز به هیچ گونه اسکریپت یا پلاگینی یک reverse پراکسی Nginx سر راه آپاچی در دایرکت ادمین داشته باشیم. دایرکت ادمین (http://www.directadmin.com/) یکی از ساده ترین کنترل پنل های موجود است که دسترسی آسان به ایمیل، گزینه های مدیریتی، فایل منیجر و … را فراهم می کند و با سرور لینوکس RedHat ، CentOS ، FreeBSD و Debian سازگاری کامل دارد .
آموزش نصب و کانفیگ NGINX به عنوان REVERSE *****
نصب Nginx :
برای نصب Nginx به CustomBuild 2.0 نیاز خواهید داشت . درصورتی که در سیستم شما نصب نباشد، از راهنمای زیر برای ارتقاء به CustomBuild 2.0 استفاده کنید :
ارتقاء CustomBuild :
اگر از CustomBuild 1.1 یا ۱٫۲ استفاده میکنید و میخواهید آن را به نسخه ی ۲٫۰ ارتقا دهید ،باید در نظر داشته باشید که فرآیند ارتقا، فقط تغییر تنظیمات options.conf نیست، چون مقادیر option.conf در نسخه ۲٫۰ متفاوت است.
برای ارتقا به نسخه ۲٫۰ به همراه تمام گزینه های پیشفرض دستورات زیر را اجرا کنید :
1
2
3
4
5
6
cd /usr/local/directadmin
mv custombuild custombuild_1.x
wget –O custombuild.tar.gzhttp://files.directadmin.com/services/custombuild/2.0/custombuild.tar.gz
tar xvzf custombuild.tar.gz
cd custombuild
./build
در این مرحله، conf به طور پیش فرض ایجاد شد. اگر می خواهید از تمام گزینه های پیش فرض استفاده کنید ، از مرحله ۳ چشم پوشی کنید .
دستورات زیر را اجرا کنید:
1
2
./build all d
./build rewrite_confs
عملکرد بین نسخه های مختلف CustomBuild متفاوت است، بنابراین برای اینکه بدانید از کدام نسخه CustomBuild استفاده میکنید (۱٫۱، ۱٫۲ و یا ۲٫۰) دستور زیر را اجرا کنید:
1
2
cd /usr/local/directadmin/custombuild
./build version
برای مثال :
1
2
[root@server custombuild]# ./build version
2.0.0–RC7 (rev: 798)
برای اسکریپت های قدیمی تر بجای دستور فوق ، دستور زیر را اجرا کنید :
1
2
cd /usr/local/directadmin/custombuild
grep BUILDSCRIPT_VER build
شما می توانید مرحله دوم نصب CB2 را هم اکنون یا در زمان دیگری اجرا کنید . دستورات زیر را به منظور استفاده از Nginx و php-fpm برای تنظیم conf اجرا کنید :
1
2
3
4
5
./build set webserver nginx
./build set php1_mode php–fpm
./build update
./build all d
./build rewrite_confs
https://blog.web4asia.in/?p=116
- - - Updated - - -
و در اخر nginx رو ریست کنید تا فعال شه .service nginx restart
کانفیگ های nginx
#user nginx;
# The number of worker processes is changed automatically by CustomBuild, according to the number of CPU cores, if it's set to "1"
worker_processes 1;
pid /var/run/nginx.pid;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
events {
include /etc/nginx/nginx-events.conf;
}
http {
include /etc/nginx/mime.types;
# For user configurations not maintained by DirectAdmin. Empty by default.
include /etc/nginx/nginx-includes.conf;
# Supplemental configuration
include /etc/nginx/nginx-modsecurity-enable.conf;
include /etc/nginx/nginx-defaults.conf;
include /etc/nginx/nginx-gzip.conf;
include /etc/nginx/directadmin-ips.conf;
include /etc/nginx/directadmin-settings.conf;
include /etc/nginx/nginx-vhosts.conf;
include /etc/nginx/directadmin-vhosts.conf;
}
- - - Updated - - -
Modify NGINX templates
Copy
/usr/local/directadmin/data/templates/nginx_server.conf
/usr/local/directadmin/data/templates/nginx_server_sub.conf
to
/usr/local/directadmin/data/templates/custom/nginx_server.conf
/usr/local/directadmin/data/templates/custom/nginx_server_sub.conf
Modify the files
/usr/local/directadmin/data/templates/custom/nginx_server.conf
/usr/local/directadmin/data/templates/custom/nginx_server_sub.conf
change line:
*****_pass http://|IP|:|PORT_8080|; (http://%7Cip%7C:|PORT_8080|;/)
to
*****_pass http://|IP|:6081; (http://%7Cip%7C:6081;/)
Change 6081 to any other value of TCP post where Varnish is accepting connections.
Rewrite nginx virtual hosts:
echo "action=rewrite&value=nginx" >> /usr/local/directadmin/data/task.queue
/usr/local/directadmin/dataskq
Have a good day!
- - - Updated - - -
If you want to add any extra modules to nginx, they'll most likely need to be compiled in. Any module that needs to be compiled in will have a --add-module type flag which will need to be used. To add this flag, run the following:cd /usr/local/directadmin/custombuild
mkdir -p custom/nginx
cp -fp configure/nginx/configure.nginx custom/nginx/configure.nginx
Add your --add-module line to the end of the custom/nginx/configure.nginx file, and make sure the \ character exists at the end of all lines except the last one. The \ character tells the line configure line to loop to the next line, making the configure settings easier to read. Without the \ character to trigger the wrap, the next line becomes a separate command, which is not correct. (see error below). Once set, type:./build used_configs
to ensure your custom configure.nginx file is being used. Then type:./build nginx
A common error people run into looks like this:/usr/local/directadmin/custombuild/custom/nginx/configure.nginx: line 32: --add-module: command not found
which simply means that the \ character was not correctly added on the line before --add-module.
- - - Updated - - -
https://blog.web4asia.in/?p=129