Linux (ix) LNMP environment Nginx Server

Source: Internet
Author: User

One , download and install the lnmp One-click installation package:

#tar-ZXVF lnmp1.2-full.tar.gz

#cd Lnmp1.2-full

#./install.sh LNMP

Installation Lnmp execution:wget-c http://soft.vpser.net/lnmp/lnmp1.2-full.tar.gz && tar zxf lnmp1.2-full.tar.gz && CD lnmp1.2-full &&./install.sh lnmp
If you need to install LNMPA or lamp, replace the./install.sh parameter with Lnmpa or lamp.

two. LNMP Related Software installation directory
Nginx Directory:/usr/local/nginx/
MySQL Directory:/usr/local/mysql/
MySQL Database directory:/usr/local/mysql/var/
PHP Directory:/usr/local/php/
phpMyAdmin Directory:/home/wwwroot/default/phpmyadmin/

Default Site Directory:/home/wwwroot/default/
Nginx Log directory:/home/wwwlogs/

three. LNMP Related configuration file location
Nginx Main configuration file:/usr/local/nginx/conf/nginx.conf
MySQL configuration file:/etc/my.cnf
PHP configuration file:/usr/local/php/etc/php.ini
PHP-FPM configuration file:/usr/local/php/etc/php-fpm.conf

four . LNMP State management Commands

LNMP State Management: LNMP {start|stop|reload|restart|kill|status}
LNMP Individual Program state management: LNMP {nginx|mysql|mariadb|php-fpm|pureftpd} {Start|stop|reload|restart|kill|status}

Five . configuration file

#vi/usr/local/nginx/conf/nginx.conf

User www www;

Worker_processes Auto;

# START Process

Error_log/home/wwwlogs/nginx_error.log Crit;

#错误日志

Pid/usr/local/nginx/logs/nginx.pid;

#主进程PID保存文件

#Specifies the value for maximum file descriptors the can is opened by this process.
Worker_rlimit_nofile 51200;

#文件描述符数量

Events
{
Use Epoll;

#网络I/O model, it is recommended that Linux use Epoll,freebsd kqueue

# Epoll is a way of multiplexing Io (I/O multiplexing), but only for linux2.6 on the inside can greatly improve the performance of Nginx
Worker_connections 51200;

#单个工作进程最大允许连接数

Multi_accept on;


}

http

#整体环境配置
{
Include Mime.types;
Default_type Application/octet-stream;
# set the MIME type, File Transfer type is defined by the Mime.type file

Server_names_hash_bucket_size 128; #保存服务器名字的hash表 size

Client_header_buffer_size 32k; #客户端请求头部缓冲区大小

Large_client_header_buffers 4 32k; #最大客户端头缓冲大小

Client_max_body_size 50m; #客户端最大上传文件大小 (M)

Sendfile on;

#sendfile directive Specifies whether Nginx calls the Sendfile function (zero copy mode) to output the text for normal applications, must be set to on . If you are using a disk IO heavy load application for download, you can set it off to balance disk and network I/O processing speed and reduce the uptime of the system.

#高效文件传输

Tcp_nopush on;

#这个是默认的, the result is that the packet is not delivered immediately, and when the packet is maximum, a one-time transmission, which helps to resolve network congestion. (only valid when sendfile on)

Keepalive_timeout 60;

#连接超时时间

Tcp_nodelay on;

# disables the Nagle algorithm, that is, the data is not cached. effectively address network congestion

Fastcgi_connect_timeout 300;

Fastcgi_send_timeout 300;

Fastcgi_read_timeout 300;

Fastcgi_buffer_size 64k;

Fastcgi_buffers 4 64k;

Fastcgi_busy_buffers_size 128k;

Fastcgi_temp_file_write_size 256k;

#fastcgi设置

gzip on;

Gzip_min_length 1k;

Gzip_buffers 4 16k;

Gzip_http_version 1.1;

Gzip_comp_level 2;

Gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml applic Ation/xml+rss;

Gzip_vary on;

Gzip_proxied expired No-cache No-store private auth;

Gzip_disable "MSIE [1-6]\.";

#limit_conn_zone $binary _remote_addr zone=perip:10m;

# #If Enable Limit_conn_zone,add "Limit_conn Perip" to the server section.

Server_tokens off;

#隐藏nginx版本号 ( curl-i 192.168.4.154 can be viewed, more secure)

#log format

Log_format access ' $remote _addr-$remote _user [$time _local] "$request"

' $status $body _bytes_sent ' $http _referer '

' "$http _user_agent" $http _x_forwarded_for ';

#定义日志格式

Server

{

Listen default_server;

#listen [::]:80 default_server Ipv6only=on;

#监听80端口

server_name www.lnmp.org;

#服务器名

Index index.html index.htm index.php;

#默认网页文件

Root/home/wwwroot/default;

#网页主目录

#error_page 404/404.html;

Include enable-php.conf;

Location/nginx_status

{

Stub_status on;

Access_log off;

}

#开启status状态监测

Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $

{

Expires 30d;

}

#静态文件处理, shelf life 30 days

Location ~. *\. (JS|CSS)? $

{

Expires 12h;

}

#js和css文件处理, shelf life 12 hours

Location ~/\.

{

Deny all;

}

Access_log/home/wwwlogs/access.log access;

#正确访问日志

}

Include vhost/*.conf;

#vhost/Down configuration file is in effect

}

Check nginx configuration file statement error

#/usr/local/nginx/sbin/nginx-t

Smooth restart nginx Process

1) pkill-hup Nginx (Common)

2) kill-hup ' Pgrep-uroot nginx '

Pgrep-uroot nginx to remove nginx main process PID

3)/usr/local/nginx/sbin/nginx-s Reload

Linux (ix) LNMP environment Nginx Server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.