دستورات مدیریت Nginx که هر کاربر لینوکس باید بداند
Nginx یک HTTP و reverse proxy سرور رایگان، متن باز، با کارایی بالا، مقیاس پذیر، قابل اعتماد، کامل و به خاطر پیکربندی ساده آن معروف می باشد.مصرف کم منابع و عملکرد بالای آن دلیل استفاده ی وب سایت های معروف و ترافیک بالا مانند GitHub، SoundCloud، Dropbox، Netflix، WordPress و بسیاری دیگر از انجین ایکس می باشد. در این مقاله به معرفی دستورات پر کاربرد به منظور مدیریت Nginx در لینوکس می پردازیم.
نصب انجین ایکس
انجین ایکس در مخزن سیستم عامل های لینوکس وجود دارد، پس با مدیریت پکیج لینوکس می توان به راحتی انجین ایکس رو نصب کرد :
1 2 3 | $ sudo yum install epel-release && yum install nginx [On CentOS/RHEL] $ sudo dnf install nginx [On Debian/Ubuntu] $ sudo apt install nginx [On Fedora] |
بررسی نسخه ی انجین ایکس
1 | $ nginx -v |
خروجی :
1 | nginx version: nginx/1.12.2 |
یا برای جزئیات بیشتر :
1 | nginx -V |
خروجی :
1 2 3 4 5 | nginx version: nginx/1.12.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' |
بررسی syntax کانفیگ انجین ایکس
قبل از start کردن سرویس nginx می توان کانفیگ رو با دستور زیر بررسی کرد که در آن مشکلی از لحاظ syntax وجود نداشته باشد :
1 | sudo nginx -T |
خروجی :
1 2 3 4 | $ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful |
استارت سرویس انجین ایکس
1 2 3 | $ sudo systemctl start nginx #systemd یا $ sudo service nginx start #sysvinit |
ری استارت سرویس انجین ایکس
1 2 3 | $ sudo systemctl restart nginx #systemd یا $ sudo service nginx restart #sysv init |
مشاهده ی وضعیت انجین ایکس
1 2 3 | $ sudo systemctl status nginx #systemd یا $ sudo service nginx status #sysvinit |
خروجی :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. [root@tecmint ~]# systemctl status nginx ● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2019-03-05 05:27:15 EST; 2min 59s ago Main PID: 31515 (nginx) CGroup: /system.slice/nginx.service ├─31515 nginx: master process /usr/sbin/nginx └─31516 nginx: worker process Mar 05 05:27:15 tecmint.com systemd[1]: Starting The nginx HTTP and reverse proxy server... Mar 05 05:27:15 tecmint.com nginx[31509]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok Mar 05 05:27:15 tecmint.com nginx[31509]: nginx: configuration file /etc/nginx/nginx.conf test is successful Mar 05 05:27:15 tecmint.com systemd[1]: Failed to read PID from file /run/nginx.pid: Invalid argument Mar 05 05:27:15 tecmint.com systemd[1]: Started The nginx HTTP and reverse proxy server. |
[line]
تیم فنی آلما هاست، در تمام ایام سال به صورت 24 ساعته در خدمت شما هستند تا برای خریدمیزبانی وب (هاست اشتراکی) پرسرعت شما را یاری کنند و جدیدترین آفر های موجود را برای شما متناسب با نیازتان ارائه کنند. برای دریافت آخرین آفر های ویژه و تخفیف های ما، می توانید از طریق تیکت با ما در ارتباط باشید تا آفر های موجود را بر اساس نیاز شما برایتان ارسال کنیم.
پرتال کاربری آلما هاست ( پاسخگویی 24 ساعته ) : پورتال مشتریان آلما هاست