


linux+Nginx+Mysql+Php icon, detailed operation steps!
LNMPIntroduction
LAMP(Linux apache mysql php)---Earlierweb service.
LNMP(Linux nginx mysql php)---More trendy and new The webn service has an increasing usage rate (very popular in China).
Nginx (Engine X) is developed by Russians and is open sourcewww Service software, the software totals 780K (very small), it is a static (html, js, css, jpg, etc.) wwwSoftware, small static files have high concurrency and occupy very few resources.
NginxUse platform (linux unix windows is OK) and apacheSame.
Nginx Functions:
a.www webService---http 80
b.Load balancing (reverse proxyproxy)
c.web cache
nginxAdvantages:
1. Simple configuration and flexibility.
2.High concurrency (static small files), static 1-2W.
3. Occupies few resources, 2W concurrently opens 10 thread services, and consumes hundreds of megabytes of memory.
4.There are many types of functions (web cache proxyproxy), and each function is not very strong.
5.Supports the epoll model, making nginx support high concurrency.
6.nginxThere is a difference between working with dynamic services and apache.
7.Use nginx to limit the speed of IP. The number of connections can be limited.
Implementation principle: nginx(apache)- -》php--》mysql
nginx Application scenarios:
1.Static service (pictures, videos), the other lighttpd (the community is not active). Concurrency: 1-3W, html, js, css、.flv
2.Dynamic service: nginx+fastcgi way to run php, jsp. Concurrency: 500-1500, similar to apache+php, lighttpd+fcgi php
3.Reverse proxy, load balancing. For products below PV2000W, you can use nginx as an agent. haproxy,F5,a10
4.Cache Service, SQUID,VARNI.
nginx Comparison with other web servers:
1) apache
a. Stable and powerful
b. Prefork mode cancels the process creation overhead and has high performance.
c.When processing dynamic business data, because it is associated with the back-end engine and database, the bottleneck is not apache itself
d. High concurrency consumes relatively more system resources
e.Based on the traditional select model
2) nginx
a. Based on the asynchronous IO model (epoll, kqueue), strong performance, able Supports tens of thousands of concurrency
b. Very good support for small files, high performance (limited to small static files)
c. Beautiful code, extension library must be compiled for the main program
d. Resource consumption is relatively low
3) Lighttpd (Baidu Tieba, Douban)
a.Based on asynchronous IOModel, performance is similar to nginx
b.The extension is SO mode, better than nginxBe flexible
c.The global usage rate is low, and the security is not as good asapache andnginxGood
d.File URL address encryption can be achieved through the plug-in (mod secdownload)
How to choose web server (recommended) in enterprise production scenarios:
Static business: For high concurrency, use nginx or lighttpd
Dynamic business: use nginx and apache Both
Both dynamic and static services: nginx and apache both Yes, single choice
External businessnginx, Internal businessapache
Installation, configurationnginx
1.Installation preparation:[root@localhost ~]# yum install pcre* -y
[root@localhost ~]# yum install openssl* -y
2.Compile:
./configure --prefix=/application/nginx1. 12.0 \
--user=nginx \
--group=nginx \
--with-http_stub_status_module \
--with-http_ssl_module
3.Startup check:
[root@localhost application]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx1.12.0/conf/nginx.conf syntax is ok
nginx: the configuration file /application/nginx1.12.0/conf/nginx.conf test is successful
[root@localhost application]# /application/nginx/sbin/nginx
[root@localhost application]# netstat -lntup|grep nginx(Also80 The port can also be checked)
The appearance of this interface indicates success
[root@localhost application]# vim /application/nginx/html/index.html Modify homepage content
4.About nginx module
1)Nginx core modules(required), includingMain Events
2)Standard HTTP modules (Although it is not required, it will be installed by default and it is not recommended to change it), including Core Acess FastCGI Gzip (Compression module, performance optimization) LOG (Log module) Proxy Rewrite( URLRewriting module) Upstream (Load balancing module) etc.
Tips: Under default conditions, Both sets of modules will be installed. Modifying the configuration file mainly involves modifying the parameters of the module based on the functions of this 2 group of modules. The parameters of the module can be viewed on the official website.
5.nginx configuration
[root@localhost conf]# egrep -v "#|^$" nginx. conf.default >nginx.conf (remove the comment # line)
[root@localhost conf]# vim nginx.conf (cairui.org is an alias)
[root@localhost conf ]# mkdir /application/nginx/html/www
[root@localhost conf]# touch /application/nginx/html/www/index.html
[root@localhost conf]# vim /application/nginx/html/www/index.html
[root@localhost conf]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/ nginx1.12.0/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx1.12.0/conf/nginx.conf test is successful
[root@localhost conf]# /application/nginx/sbin/nginx -s reload
Modify the windowslocalhosts file to ensure it is in winIn the command prompt, ping can be passed from the virtual host, and then go to the web page to view
Add status server tag:
[root@localhost conf]# vim /application/nginx/conf/nginx.conf
##status
server {
Listen 80;
server_name status.cairui.org;
location / {
stub_status on;
access_log off;
}
}
在winLocalhostsAlso add ,
to the file
Solution to malicious domain name binding:
[root@localhost conf]# vim /application/nginx/conf/nginx.conf (must be placed first server)
server {
listen 80;
location / {
deny all;
}
}
Enable logging function:
[root@localhost conf]# cat /application/nginx/conf/nginx.conf.default (Find the log format)
#log_format $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
Copy tonginx.conf and remove the comments
Software for analyzing
nginxlog:syslog,rsyslog,Awstats,scribe,kafka
MysqlmysqlInstallation method:
5.1---Compile and install
configure,make,make install5.5---Compile Install
cmake, make, make install (you can install it directly with the binary package , just unzip it)
1.Installation
mysql[root@localhost conf]# useradd mysql -s /sbin/ nologin -M
[root@localhost tools]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz[root@localhost tools]# mv mysql-5.5 .32-linux2.6-x86_64 /application/mysql5.5.32[root@localhost tools]# ln -s /application/mysql5.5.32/ /application/mysql[root@ localhost tools]# chown -R mysql.mysql /application/mysql/data/[root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/application/mysql/ - -datadir=/application/mysql/data/(
libaio needs to be installed before compilation)[root@localhost mysql]# cp support -files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# vim /etc/init.d/mysqld
(The configuration file of each version is different)
cp: Do you want to overwrite
"/etc/my.cnf"? y[root@localhost mysql]# vim /etc/profile
[root@localhost mysql]# service mysqld start
Starting MySQL.. SUCCESS!
[root@localhost mysql]# mysql
Database optimization:
mysql> show databases
mysql> drop Database test;
mysql> select user,host from mysql.user;
mysql> drop user''@localhost;
[root@localhost mysql]# mysql -uroot -pnew-password
Change password (enter mysqlModify)mysql> set password for root@localhost = password('123');
PHP
php under LNMP:
apache----》libphp5.so
nginx---》fcgi php-fpm port9000(Baidu)
InstallationphpBefore making suremysql, nginx is running normally[root@localhost mysql]# netstat -lntup|egrep "nginx|mysql"
1.Software that needs to be installed
Installationlibiconv(./configure --prefix=/usr/local/libiconv)
Installationlibmcrypt (Not required, recommended to install) It is an encrypted library
./configure
make
make install
sleep2
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../cd
Installmhash
./configure
make
make install
sleep 2
cd ../
rm -fr /usr/lib64/libmcrypt.*
rm -fr /usr/lib64/libmhash*
ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la
ln -s /usr/ local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib64/ libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2
ln - s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin /libmcrypt-config
Installationmcrypt
/sbin/ldconfig
./configure LD_LIBRARY_PATH=/usr/local/ lib
make
make install
cd ../
sleep 2
2.Installphp
[root@localhost tools]# yum install libxslt* -y
./configure \
--prefix=/application/php5. 6.30 \
--with-mysql=/application/mysql \
--with-iconv-dir=/usr/local/libiconv \
--with- freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregx \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp \
--enable-opcache=no
ln - s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64
Error handling: ,,
3.phpConfiguration
[root@localhost php-5.3.27]# cp php.ini-production /application/php/lib/php.ini
Upload directly
[root@localhost etc]# /application/php/sbin/php-fpm -t
[root@localhost etc]# /application/php/sbin/php-fpm
Boot up
cat >>/etc/rc.local
#nginx+php-fpm by cairui at 2017
/etc/init.d/mysqld start
/application/php/sbin/php-fpm
/application/nginx/sbin/nginx
EOF
[root@134 extra]# cat /application/nginx/conf/extra/bbs.conf
server {
listen 80;
server_name bbs.caimengzhi.org;
root root html/bbs;
index index.html index.htmi index.php;
Location ~ .*\.(php|php5)?$ #Not specified at this time{} Directory, directly read the php file { fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
## }[root@localhost conf]# cd /application/nginx/html/www/[root@localhost www]# vim index.php
Software
[root@localhost www]# mysqlmysql> create database wiki;
mysql> grant all on wiki.* to wiki@'localhost' identified by 'wiki';mysql> flush privileges ;mysql> quit(wiki
下载HDwiki)[root@localhost www]# wget (note www
) [root@localhost www ]# unzip download.php\?n\=HDWiki-v6.0GBK-20170209.zip[root@localhost www]# rm -f download.php\?n\=HDWiki-v6.0GBK- 20170209.zip
[root@localhost www]# mv hdwiki/* .[root@localhost www]# cd ../[root@localhost html] # chown -R nginx.nginx www/The above is the detailed content of linux+Nginx+Mysql+Php icon, detailed operation steps!. For more information, please follow other related articles on the PHP Chinese website!

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.

Linux maintenance mode is entered by adding init=/bin/bash or single parameters at startup. 1. Enter maintenance mode: Edit the GRUB menu and add startup parameters. 2. Remount the file system to read and write mode: mount-oremount,rw/. 3. Repair the file system: Use the fsck command, such as fsck/dev/sda1. 4. Back up the data and operate with caution to avoid data loss.

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

This guide will guide you to learn how to use Syslog in Debian systems. Syslog is a key service in Linux systems for logging system and application log messages. It helps administrators monitor and analyze system activity to quickly identify and resolve problems. 1. Basic knowledge of Syslog The core functions of Syslog include: centrally collecting and managing log messages; supporting multiple log output formats and target locations (such as files or networks); providing real-time log viewing and filtering functions. 2. Install and configure Syslog (using Rsyslog) The Debian system uses Rsyslog by default. You can install it with the following command: sudoaptupdatesud


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use