Linux Lnmp Construction and interpretation

Source: Internet
Author: User
Tags fpm

The construction of LNMP
Linux nginx MySQL (mariaDB) php

Install MySQL dependency:
Yum-y Install CMake (CMake Compilation tool)
Yum-y Install GCC gcc-c++
Yum-y Install Ncurses-devel
Install MySQL
[Email protected]]# useradd MySQL
[Email protected]]# tar-xf mysql-5.6.26.tar.gz
[[Email protected]]# cd MySQL
[Email protected] mysql]# CMake
[[email protected] mysql]# make
[[email protected] mysql]# make install
[[email protected] mysql]# chown-r mysql.mysql/usr/local/mysql/(set permissions, owner, owning master)
Initializing the database
[[email protected] mysql]#./scripts/mysql_install_db--user=mysql--datadir=/usr/local/mysql/data (run script to scripts directory)
[[Email protected]]# ls data/(view database, default, run script only)
AUTO.CNF ib_logfile0 MySQL Test web2.pid
。。。。。。。。
[[email protected] ~]# vim/etc/ld.so.conf (to the search path plus MySQL library)
/usr/local/mysql/lib/
[Email protected] ~]# Ldconfig
[[Email protected] mysql]# MV Support-files/mysql.server/etc/init.d/mysqld (Put the startup script in ETC/INIT.D)
[Email protected]]# ln-s/usr/local/mysql/bin/*/usr/bin/
[[Email protected]]# ldconfig-v (Update link library)
[[Email protected]]# Server mysqld start (start MySQL)
[[email protected]]# MySQL (default is no password)
mysql> show databases; (see which databases, each instruction with a semicolon ending)
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.12 sec)
mysql> use MySQL; (Enter database)
Mysql> show tables; (View data sheet)
......
Mysql> select * from user; (see information from the User data table)
mysql> CREATE database MyDB; (creating new databases)
mysql> use MyDB; (Enter database)
Mysql> CREATE table MYT (name char (ten), id int (3)); (Create data table)
mysql> INSERT INTO MYT ("jerry,001"); (data stored in the data table)
Mysql> select * from MYT; (query)
Mysql> exit (Exit)

Installing PHP Extensions
[[Email protected]]# tar-xf mhash....tar.gz (hash function library)
[[Email protected]]# CD Mhash
[Email protected]]#./configure
[[Email protected]]# make
[[Email protected]]# make install
[Email protected]]# tar-xf libmcrypt. tar.gz (library file with encryption capability)
[[Email protected]]# CD Libmcrypt
[Email protected] libmcrypt]#./configure
[[email protected] libmcrypt]# make
[[email protected] libmcrypt]# make install
[Email protected]]# ln-s/usr/local/lib/libmcrypt*/usr/lib/(link dependent library file)
[Email protected]]# ln-s/usr/local/lib/libmhash.*/usr/lib/(link to library file)
[[Email protected]]# ldconfig (Update link library)
Install PHP
[Email protected]]# tar-xf php...tar.gz
[[Email protected]]# cd PHP
[[email protected] php]#./configure--enable-fpm (default listening 9000 port)
[[email protected] php]# make
[[email protected] php]# make install
[[Email protected]]# CD LNMP_SOFT/PHP-5.4.24/SAPI/FPM (enter startup script file)
[[email protected] fpm]# CP INIT.D.PHP-FPM/ETC/INIT.D/PHP-FPM (Put the startup script under Init)
[[email protected] fpm]# chmod +x/etc/init.d/php-fpm (give execute permission)
[[Email protected] ~]# Service PHP-FPM start (start service)
[Email protected] ~]# NETSTAT-NUTLP | grep 9000 (check if port 9000 is listening and the service starts successfully)
TCP 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 21153/php-fpm


To link a service:
The Nginx and PHP binding, if it is a static page, the Nginx directly processing
If it is a PHP page, forward to the php9000 port
[Email protected] conf]# vim nginx.conf
Location ~ \.php$ {
root HTML;
Fastcgi_pass 192.168.2.200:9000; (Transfer php page to 192.168.2.200:9000 Port)
Fastcgi_index index.php;
Include fastcgi_conf;
}
[[email protected] ~]# Firefox http://192.168.2.200/hydra.php (test access to PHP pages and linked databases)
[Email protected] html]# vim hydra.php
<?php
$a =mysql_connect (127.0.0.1,root.pass);
if ($a) {
echo "Hail Hydra!!!"
else{
echo "Error";
}
}
?>

——————————————————————————————————————————————————————————————————————

Address rewriting:
Get a URL request for a visit,
Then rewrite the process to another URL that the server can handle

Benefits of Address rewriting:
Improve security by shortening URLs and hiding actual paths
Easy user memory and typing
Easily indexed by search engines

Common web Site applications:
When the site anthology that move or file directory name changes, in the SEO need,
You need to keep the old URL.
Website revision, site navigation and links have changed,
In order to continue to hold the traffic generated by the original link, you need to keep the old URL

Rewrite module
Rewrite statement:
Rewrite regular adjusted page [options]
Options:
Redirect: temporary redirect, Address bar change, crawler does not update URL
Permanent: Permanent redirect, Address bar change, crawler update URL
Last: Stop executing other rewrite rules, continue to search other location according to the URL, the address bar unchanged
Break: Stop executing other rewrite rules to complete this request

Regular expressions
Syntax format:
Rewrite regular adjusted page [options]
The regular expression matching pattern is as follows:
Case-sensitive matching: ~
Case-insensitive matching: ~*
Case-sensitive mismatch:!~
Non-differentiated size mismatch:!~*
Determine if the file exists:-F
Determine if the directory exists:-D
Determine if the file is executable:-X
Determine whether a file, directory, connection exists:-E

if (condition) {...}
Conditional judgment
Record rewrite log in rewrite--log:error log
Rewrite--log on | Off

Format: Rewrite regular adjusted page [options]

Example:
Requirements: Turn a.html into b.html
server {
Listen 80;
server_name www.Anonymous.net;
Location/{
root HTML;
Index index.html index.htm;
Rewrite a\.html/b.html redirect; (jump, add redirect Address bar will change)
}
Example:
Requirements: Turn www.Anonymous.net into www.Anonymous.org
server {
Listen 80;
server_name www.Anonymous.net;
Location/{
root HTML;
Index index.html index.htm;
Rewrite ^/(. *) http://www.anonymous.org/$1; (entire site and subdirectory file jumps)
}
Example:
Location/{
root HTML;
Index index.html index.htm;
if ($http _user_agent ~ cirl) {(judging as the fruit IE browser, the content of a.html is displayed, and if it is curl, the content of curl/a.html is displayed)
Rewrite (. *) $/curl/$1;
}
}
[email protected] nginx]# Firefox http://127.0.0.1/a.html
Hail Hydra!!!
[Email protected] nginx]# Curl http://127.0.0.1/curl/a.html
Anonymous

——————————————————————————————————————————————————————————————

Linux Lnmp Construction and interpretation

Related Article

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.