In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
* Nginx service
Developed specifically for performance optimization, Nginx is best known for its stability and low system resource consumption, as well as high processing capacity for HTTP concurrent connections (30000-50000 concurrent requests per physical server)
Installation and operation control
1. Compile and install Nginx
The configuration and operation of Nginx need the support of pcre,zlib and other software packages.
[root@centos1 ~] # yum-y install pcre-devel zlib-devel
Create and run users, groups
[root@centos1] # useradd-M-s / sbin/nologin nginx
* compile and install Nginx
Tar zxf / mnt/nginx-1.6.2.tar.gz-C / usr/srccd / usr/src/nginx-1.6.2 [root@centos1 nginx-1.6.2] #. / configure-- prefix=/usr/local/nginx-- user=nginx-- group=nginx-- with-http_stub_status_ module [roo t@centos1 nginx-1.6.2] # make&&make install
In order to make the operation of the Nginx server more convenient, you can create a link file for the main program Nginx, and it is convenient for the administrator to directly execute the "nginx" command to call the nginx main program.
[root@centos1 nginx-1.6.2] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin
Operation Control of 2.nginx
* Control profile
Check whether the control file is correct
[root@centos1 nginx-1.6.2] # nginx- tnginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful
* start and stop nginx
[root@centos1 nginx-1.6.2] # nginx
Check the listening port of nginx, or access it through a browser
[root@centos1 nginx-1.6.2] # netstat-anptActive Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0 anptActive Internet connections 80 0.0.0 LISTEN
3. Understand the configuration file nginx.conf of nginx
In the main configuration file / usr/local/nginx/conf/nginx of the nginx server. Conf, including global configuration, iUnip event configuration and HTTP configuration. The format of the configuration statement is' keyword value'(ending with a semicolon) and comments starting with'#'.
(1) Global configuration
It includes basic settings such as the user who runs the Nginx service, the number of worker processes, the error log, the location of the PID, and so on.
# user nobody; / / user defaults to nobodyworker_processes 1; / / the number of working processes can be specified according to the total number of cpu cores. # location of error_log logs/error.log;// error log file # location of pid logs/nginx.pid; / / PID file
(2) configuration of Icano events
Use the 'events {}' delimiter to specify the Nginx process's Icano response model and the number of connections per process. For kernels of version 2 and above, it is recommended to use the epoll model to improve performance. The number of connections per process should be determined according to actual needs, generally less than 10000 (default is 1024)
Events {use epoll / / uses the epoll model worker_connections 4096; each process handles 4096 process connections}
(3) HTTP configuration
Use the "http {}" delimiter to set the http server, including access log, HTTP port, web page directory, default character set, connection retention, and virtual WEB host, PHP parsing, etc. Most of the configuration statements are included in the delimiter "server {}" to represent a specific website.
Http {include mime.types; default_type application/octet-stream; log_format main'$remote_addr-$remote_user [$time_local] "$request" / / remove the previous #'$status $body_bytes_sent "$http_referer" / / remove the previous #'"$http_user_agent"$http_x_forwarded_for"' / / remove the previous # access_log logs/access.log main; / / remove the previous # sendfile on; # tcp_nopush on; # keepalive_timeout 0; keepalive_timeout 65; # gzip on
4. Build a virtual web host based on domain name
(1) prepare the website directory and test files
[root@centos1 nginx-1.6.2] # mkdir-p / var/www/benet [root@centos1 nginx-1.6.2] # echo "www.benet.com" > / var/www/benet/index.html [root@centos1 nginx-1.6.2] # mkdir-p / var/www/accp [root@centos1 nginx-1.6.2] # echo "www.accp.com" > / var/www/accp/index.html
(2) adjust the nginx.conf configuration file
The virtual host is configured in the server {} area, and each server {} region represents a web site configuration, specifying its own website name, listening address, website root, access log and other information, and then reloading the configuration (plus two segment nodes to www.accp. Com www.benet . Com)
Server {listen 80; server_name www.benet.com; charset utf-8; access_log logs/benet.access.log main; location / {root / var/www/benet; index index.html index.htm;} location / status {stub_status on; access_log off } error_page 500 502 503 504 / 50x.htl; location = / 50x.html {root html;}} server {listen 80; server_name www.accp.com; charset utf-8; access_log logs/accp.access.log main; location / {root / var/www/accp Index index.html index.htm;} location / status {stub_status on; access_log off;} error_page 500 502 503 504 / 50x.html; location = / 50x.html {root html;}}
(3. Reload
[root@centos1 nginx-1.6.2] # killall-s QUIT nginx
[root@centos1 nginx-1.6.2] # nginx
(4)。 test
V. Construction of LNMP architecture and application deployment
Just like building LAMP, building a LNMP platform also requires Linux server, Mysql database, and PHP parsing environment. The difference mainly lies in the protocol configuration of Nginx and PHP.
(1) enable the php-fpm process
[root@centos1 vod] # useradd-M-s / sbin/nologin php
① modifies php-fpm.conf configuration file, modifies relevant parameters, and then starts the php-fpm process. Php-fpm listens on port 9000 of this machine by default.
# cd / usr/local/php5/etc#cp php-fpm.conf.default php-tpm.confpid = run/php-fpm.pid / / confirm the location of the pid file user = php / / run user group = php / / run group pm.start_servers = 20 / / number of processes started at startup pm.min_spare_servers = 5 / / minimum idle processes pm.max_spare _ servers = 35 / / maximum number of idle processes pm.max_children = 50 / / maximum number of child processes
② starts php-fpm
[root@centos1 etc] # / usr/local/sbin/php-fpm
(2) configure nginx: fully support php parsing
Note: no matter which parsing method is used, it needs to be configured in server.
[root@centos1 Desktop] # vim / usr/local/nginx/conf/nginx.conf
Server {listen 80; server_name vod.benet.com; charset utf-8; access_log logs/vod.access.log main; location / {root / var/www/vod; index index.html index.php;} location ~\ .php$ {/ / visit the configuration segment root / var/www/vod of the .php page / / the root directory of the php page, fastcgi_pass 127.0.0.1 fastcgi_index index.php; 9000; / / php-fpm listening address fastcgi_index index.php; / / php homepage name include fastcgi.conf; / / fastcgi module configuration}
[root@centos1 vod] # killall-s QUIT nginx
[root@centos1 vod] # nginx
(3) php page access test
[root@centos1 vod] # mysqladmin-u root-p password '123456' # service mysqld start / / start the database mkdir / var/www/vod to create a test page test.phpvim / var/www/vod/test.php under / var/www/vod
then uses a browser on the client to access
VI. Application of LNMP platform-- deployment of Sky Network Film Department
1. Download and deploy the program code
[root@centos1 ~] # unzip / mnt/SKYUC_3.4.2_for_php5.3.zip-d / usr/src [root@centos1 ~] # cd / usr/src/SKYUC.v3.4.2.SOURCE/ [root@centos1 SKYUC.v3.4.2.SOURCE] # mv wwwroot/ / var/www/vod/skyuc [root@centos1 SKYUC.v3.4.2.SOURCE] # cd / var/www/vod/skyuc/ [root@centos1 skyuc] # chown-R php:php admincp/ data/ templates/ upload/
two。 Create a database
In order to reduce the risk of web application to database, it is recommended to set up dedicated database and authorized users.
[root@centos1 skyuc] # mysql-u root-pmysql > create database skyucdb;mysql > grant all on skyucdb.* to runskyuc@localhost identified by 'sky@uc123'
3. Install the web application
4. Access to web application system
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Cat / etc/redhat-releaseuname-runame-muname-an all display
© 2024 shulou.com SLNews company. All rights reserved.