Day 22nd: Basic configuration of the LNMP architecture (i)

Source: Internet
Author: User

Small Q: the grievance and tears are swallowed down, can not afford to lose, you can not die to stand up, tell all to see

Your man: I'm fine.


LNMP architecture and lamp architecture, in fact, is the configuration of Web services Nginx or Apache virtual host configuration file, because the configuration of Apache for a long time to understand, so in Nginx, feel a lot easier, the configuration of the same content; now introduce the first configuration.



Nginx User authentication:

"After a"

Similar to Apache certification, for example, we want to double-encrypt in the background management interface (that is, add a user authentication to the www.test.com/admin.php interface).


Cd/usr/local/nginx/conf/vhosts Vim test.com

Location ~. */admin\.php$ Matching Background management URLs

{auth_basic "Teng auth";

AUTH_BASIC_USER_FILE/USR/LOCAL/NGINX/CONF/.HTPASSWD;

Include Fastcgi_params; The following four paragraphs as long as the authentication interface has PHP to parse, it is necessary to add,

Otherwise the Open interface will download automatically

Fastcgi_pass Unix:/tmp/www.sock; The way to listen, sometimes to change the format of Ip+port

#Fastcgi_pass 127.0.0.1;

Fastcgi_index index.php;

Fastcgi_param Script_filename/data/www$fastcgi_script_name;

}

Detection:/USR/LOCAL/NGINX/SBIN/NGINX-T

Reload:/etc/init.d/nginx Reload

Add authenticated User: Htpasswd-c/usr/local/nginx/conf/.htpasswd user Name

Enter the password, and then add the user pressure to remove the-C (create)


Verify that PHP can parse: Go to the Background management interface (if you still download and clean up the cache)

Or curl-x127.0.0.1:80 www.test.com/admin.php is the source word indicates a configuration error

We can also use the important directory for user authentication encryption, protect our data, plus location/directory name/{if there is a PHP file to parse, then add the four lines};

And the matching way behind location is the next link;

Http://blog.sina.com.cn/s/blog_97688f8e0100zws5.html


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/1C/wKiom1YT1tLDTcftAAHYSiXgkSc000.jpg "style=" float: none; "Title=" FFDG. PNG "alt=" Wkiom1yt1tldtcftaahysixgksc000.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/19/wKioL1YT1ufAtWmxAAEE0hLogNE759.jpg "style=" float: none; "Title=" GDGFG. PNG "alt=" Wkiol1yt1ufatwmxaaee0hlogne759.jpg "/>



Nginx Domain Jump:

"After a"

In front of Apache when we mentioned in detail, in fact, is to set up a primary domain name, so that the other domain names are jumping to this.


Enter the virtual host profile:

Vim/usr/local/nginx/conf/vhosts/test.conf

To add a configuration:

server_name www.test.com www.aaa.com www.bbb.com; Add a secondary domain after the primary domain name

if ($host! = ' www.test.com ')

{

Rewrite ^/(. *) $ http://www.test.com/$1 permanent; $1= in front of the permanent; see details below

}

Detection:/USR/LOCAL/NGINX/SBIN/NGIINX-T

Reload:/etc/init.d/nginx Reload

Inspection: Enter the website with the sub-domain name, or curl-x127.0.0.1:80 www.aaa.com/dsfjfddgid view


Http://www.apelearn.com/bbs/thread-4840-1-1.html




The log does not record the specified file type:

"After a"

Sometimes when viewing the website access log, there is too much information that is not seen to disturb the line of sight, so we have to filter them out and not let the log record.

To enter the Nginx master configuration file:

Vim/usr/local/nginx/conf/nginx.conf

Locate the Log_format custom format name log format under the HTTP module

To enter the host configuration file:

Vim/usr/local/nginx/conf/vhosts/test.conf

To add a module:

as shown, the other modules added to the location is also fastidious, you can try more;650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/74/19/ Wkiol1yt2jfd0y4maaewelaqar4526.jpg "title=" FDGDG. PNG "style=" Float:none; "alt=" wkiol1yt2jfd0y4maaewelaqar4526.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/19/wKioL1YT2JeyB6OyAAHsytXN8xY437.jpg "style=" float: none; "title=" Bu jilu. PNG "alt=" Wkiol1yt2jeyb6oyaahsytxn8xy437.jpg "/>




Log cutting:

"After a"

When we have too much traffic, the log takes up too many disks, so we cut and delete them regularly, and Apache uses the command tool, and Nginx needs a script implementation.

We usually put the script under the default file

vim/usr/local/sbin/nginx_logrotate.sh

Write content:

#!/bin/bash script file Opening language

D= ' date-d '-1 day "+%f ' d" means date; today cut yesterday's ( -1)

[-d/usr/local/nginx/nginx_log] | | Mkdir/usr/local/nginx/nginc_log

To determine if the log storage path exists after the cut, or to create a new

mv/usr/local/nginx/access_log/usr/local/nginx/nginx_log/$d. Log

Move the post-cut log, $d. Log after the cut name

/etc/init.d/nginx Reload >/dev/null reload output to dev

cd/usr/local/nginx/nginx_log/

Gzip-f $d. Log compressed after cut file,-F forced overwrite


Execute script:

Sh-x/usr/local/sbin/nginx_logrotate.sh-x is able to see the detailed process


Then we just have to put the script to the scheduled task, just fine;




650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/19/wKioL1YT2Z_xjo85AAMH_PUamnA141.jpg "title=" DFVDG. PNG "alt=" Wkiol1yt2z_xjo85aamh_puamna141.jpg "/>







Day 22nd: Basic configuration of the LNMP architecture (i)

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.