In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following content mainly brings you the relevant linux7.4+nginx1.13.9+mysql5.7.20+php7.1.10 handouts, the knowledge here is slightly different from the books, are summed up by professional and technical personnel in the process of contact with users, have a certain experience sharing value, hope to bring help to the majority of readers.
I. Environment
Download address of installation package: http://nginx.org/en/download.html
Service firewalld stop
Systemctl disable firewalld
Transfer the installation package to the virtual machine via WinSCP
II. Nginx installation
Yum-y install\
Gcc\
Gcc-c++\
Make\
Pcre-devel\
Zlib-devel
[root@lss02 ~] # useradd-M-s / sbin/nologin nginx / / Creator user nginx, unable to log in, no home directory
[root@lss02 ~] # tar xzvf nginx-1.13.9.tar.gz
[root@lss02 ~] # cd nginx-1.13.9
[root@lss02 nginx-1.13.9] #. / configure\
-- prefix=/usr/local/nginx\
-- user=nginx\
-- group=nginx\
-- with-http_stub_status_module / / log analysis module
[root@lss02 nginx-1.13.9] # make & & make install / / compilation and installation
[root@lss02 nginx-1.13.9] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ make a soft connection for the nginx executable program so that the system can recognize
Nginx-t / / profile syntax check
Nginx / / start the service
Killall-1 nginx / / secure restart
Killall-3 nginx / / stop service
-- production management role book--
[root@lss02 nginx-1.13.9] # vi / etc/init.d/nginx
#! / bin/bash
Chkconfig: 35 99 20 / / 3 chkconfig runs automatically at level 5, the 99th process starts and the 20th process ends description: Nginx Service Control Script
PROG= "/ usr/local/nginx/sbin/nginx"
PIDF= "/ usr/local/nginx/logs/nginx.pid"
Case "$1" in
Start)
$PROG
Stop)
Kill-s QUIT $(cat $PIDF)
Restart)
$0 stop
$0 start
Reload)
Kill-s HUP $(cat $PIDF)
*)
Echo "Usage: $0 {start | stop | restart | reload}"
Exit 1
Esac
Exit 0
: x
[root@lss02 nginx-1.13.9] # chmod + x / etc/init.d/nginx / / add execution permissions to administrative scripts
[root@lss02 nginx-1.13.9] # chkconfig-- add nginx / / add nginx to the chkconfig system management tool
-the following is the initial configuration of the nginx configuration file
[root@lss02 nginx-1.13.9] # vi / usr/local/nginx/conf/nginx.conf
User nginx nginx; / / modify the owner and group of the nginx startup process
Worker_processes 1; / / the number of CPU kernels, set to several cores.
Error_log logs/error.log info; / / modify the level of the error log
Note: there are several log levels: debug info notice warn error crit, where the rule is to record upwards, that is, info-level logs cover notice warn error crit, while low-level logs include high-level ones and are not included in the configuration file.
Events {
Use epoll; / / add this line to use select/poll by default
Worker_connections 1024; / / indicates that a process allows 1024 connections. If the setting exceeds 1024, the upper limit of ulimit needs to be modified, otherwise an error will be reported (ulimit-n 65500) / View and change the number of resources opened locally in the system.
Ulimit-n 65500 > > / etc/rc.local)
Log_format main / / define the log format and remove the previous #
[root@lss02 nginx-1.13.9] # service nginx restart
Restart after configuration, and now the nginx CVM can be accessed.
-- configure the log statistics module that comes with nginx--
[root@lss02 nginx-1.13.9] # vi / usr/local/nginx/conf/nginx.conf
Location ~ / status {
Stub_status on
Access_log off
}
[root@lss02 nginx-1.13.9] # service nginx reload
[root@lss02 nginx-1.13.9] # cat / usr/local/nginx/logs/access.log
Browser: http://IP/status / / current number of active connections, number of connections handled, number of successful TCP handshakes, number of requests handled.
-the following configure the authentication function of nginx--
[root@lss02 nginx-1.13.9] # yum install httpd-tools-y / / install tools for apache and create access users with the help of tools
[root@lss02 nginx-1.13.9] # htpasswd-c / usr/local/nginx/passwd.db jack / / create a database authentication file and add jack users to it
New password: enter the password
Re-type new password: confirm password
Adding password for user jack
[root@lss02 nginx-1.13.9] # chmod 400 / usr/local/nginx/passwd.db / / improve data security
[root@lss02 nginx-1.13.9] # chown nginx/ usr/local/nginx/passwd.db / / change ownership
[root@lss02 nginx-1.13.9] # vi / usr/local/nginx/conf/nginx.conf
Location / {
Root html
Index index.html index.htm
Allow 192.168.80.0/24
Deny all
Auth_basic "secret"
Auth_basic_user_file / usr/local/nginx/passwd.db; / / Note that the file here must be consistent with the database verification file created above.
}
[root@lss02 nginx-1.13.9] # service nginx restart
To access again, you need to enter a user name and password
3. Configure the virtual host function as follows
-based on domain name-IP and port are the same but domain name is different-
[root@lss02 nginx-1.13.9] # vi / usr/local/nginx/conf/nginx.conf
"insert above the last line, which is a} with a total of 4} at the end."
Server {
Listen 80
Server_name www.aa.com
Charset utf-8
Access_log logs/aa.access.log main
Location / {
Root / usr/local/nginx/html
Index index.html index.htm
Error_page 500 502 503 504 / 50x.html
Location = / 50x.html {
Root html
}
}
}
Server {
Listen 80
Server_name www.bc.com
Charset utf-8
Access_log logs/bc.access.log main
Location / {
Root / var/www/bc
Index index.html index.htm
Error_page 500 502 503 504 / 50x.html
Location = / 50x.html {
Root html
}
}
}
Remove the comments below
Http {
Include mime.types
Default_type application/octet-stream
Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"'
[root@lss02 nginx-1.13.9] # mkdir / var/www/aa-p
[root@lss02 nginx-1.13.9] # mkdir / var/www/bc
Add a home page to the website directory of the two virtual hosts
[root@lss02 nginx-1.13.9] # vi / var/www/aa/index.html
Www.aa.com
[root@lss02 nginx-1.13.9] # vi / var/www/bc/index.html
Www.bc.com
Modify Microsoft's hosts file to test the virtual host:
The windows xp/2003/vista/2008/7/8 user HOSTS file is located in "c:\ windows\ system32\ drivers\ etc"
Add this sentence to the hosts file: 192.168.80.102 www.aa.com www.bc.com
[root@lss02 nginx-1.13.9] # nginx- t
[root@lss02 nginx-1.13.9] # service nginx restart
[root@lss02 nginx-1.13.9] # killall-1 nginx
Fourth, install MySQL
[root@lss02 ~] # yum-y install ncurses ncurses-devel bison cmake
[root@lss02 ~] # useradd-s / sbin/nologin mysql / / manually create an account
[root@lss02] # tar xf mysql-boost-5.7.20.tar.gz-C / opt/ the unzipped directory should be large enough, otherwise an error will be reported.
[root@lss02 mysql-5.7.20] # cd / opt/mysql-5.7.20/
Cmake\
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock\ / / specify the road strength of the sock file
-DSYSCONFDIR=/etc\
-DSYSTEMD_PID_DIR=/usr/local/mysql\
-DDEFAULT_CHARSET=utf8\
-DDEFAULT_COLLATION=utf8_general_ci\
-DWITH_INNOBASE_STORAGE_ENGINE=1\
-DWITH_ARCHIVE_STORAGE_ENGINE=1\
-DWITH_BLACKHOLE_STORAGE_ENGINE=1\
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1\
-DMYSQL_DATADIR=/usr/local/mysql/data\ / / data folder
-DWITH_BOOST=boost\
-DWITH_SYSTEMD=1
[root@lss02 mysql-5.7.20] # make & & make install
[root@lss02 mysql-5.7.20] # chown-R mysql:mysql / usr/local/mysql/
[root@lss02 mysql-5.7.20] # vi / etc/my.cnf
[client]
Port = 3306
Default-character-set=utf8
Socket = / usr/local/mysql/mysql.sock
[mysql]
Port = 3306
Default-character-set=utf8
Socket = / usr/local/mysql/mysql.sock
[mysqld]
User = mysql
Basedir = / usr/local/mysql
Datadir = / usr/local/mysql/data
Port = 3306
Character_set_server=utf8
Pid-file = / usr/local/mysql/mysqld.pid
Socket = / usr/local/mysql/mysql.sock
Server-id = 1
Sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES / / fixed format
: x
[root@lss02 mysql-5.7.20] # chown mysql:mysql / etc/my.cnf
[root@lss02 mysql-5.7.20] # echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' > > / etc/profile / / add these two paths to the environment variable and put them in the profile file to make them boot and run automatically, otherwise they will not take effect.
[root@lss02 mysql-5.7.20] # echo 'export PATH' > > / etc/profile / / can also be soft linked
[root@lss02 mysql-5.7.20] # source / etc/profile / / effective immediately
[root@lss02 mysql-5.7.20] # cd / usr/local/mysql/
Bin/mysqld\
-- initialize-insecure\
-- user=mysql\
-- basedir=/usr/local/mysql\
-- datadir=/usr/local/mysql/data / / mysql initialization
[root@lss02 mysql] # cp usr/lib/systemd/system/mysqld.service / usr/lib/systemd/system/
[root@lss02 mysql] # systemctl daemon-reload
[root@lss02 mysql] # systemctl start mysqld
[root@lss02 mysql] # netstat-anpt | grep 3306
[root@lss02 mysql] # systemctl enable mysqld
[root@lss02 mysql] # mysqladmin-u root-p password "123"
Enter password: (the initial password is empty, just enter directly)
[root@lss02 mysql] # mysql-u root-p
Mysql >
Mysql >
Mysql > quit
Bye
5. Install PHP
[root@lss02 mysql] # yum-y install\
Libjpeg\
Libjpeg-devel\
Libpng libpng-devel\
Freetype freetype-devel\
Libxml2\
Libxml2-devel\
Zlib zlib-devel\
Curl curl-devel\
Openssl openssl-devel / / install plug-ins that need to be supported
[root@lss02 ~] # yum-y install bzip2
[root@lss02] # tar xjvf php-7.1.10.tar.bz2-C / opt/
[root@lss02 ~] # cd / opt/php-7.1.10
[root@lss02 php-7.1.10] #. / configure\
-- prefix=/usr/local/php\
-- with-mysql-sock=/usr/local/mysql/mysql.sock\
-- with-mysqli\
-- with-zlib\
-- with-curl\
-- with-gd\
-- with-jpeg-dir\
-- with-png-dir\
-- with-freetype-dir\
-- with-openssl\ / / configure collaboration
-- enable-mbstring\
-- enable-xml\
-- enable-session\
-- enable-ftp\
-- enable-pdo\
-- enable-tokenizer\
-- enable-zip\ / / supports compression
-- enable-fpm / / supports the fpm function of dynamic pages (note that this should be typed by hand, as direct copy is easy to fail)
[root@lss02 php-7.1.10] # make & & make install
[root@lss02 php-7.1.10] # cp php.ini-development / usr/local/php/lib/php.ini / / copy php profile template as php configuration file
[root@lss02 php-7.1.10] # vi / usr/local/php/lib/php.ini / / Edit php configuration file
Mysqli.default_socket = / usr/local/mysql/mysql.sock / / Edit the sock file location of mysql
Date.timezone = Asia/Shanghai / / Select time zone
[root@lss02 php-7.1.10] # / usr/local/php/bin/php-m / / verify the installed module
-configure and optimize the FPM module-
[root@lss02 php-7.1.10] # cd / usr/local/php/etc/
[root@lss02 etc] # cp php-fpm.conf.default php-fpm.conf / / the configuration file template for copying the fpm module of php is a configuration file. Php only recognizes php-fpm.conf as a configuration file
[root@lss02 etc] # cd / usr/local/php/etc/php-fpm.d/
[root@lss02 php-fpm.d] # cp www.conf.default www.conf / / copy the www profile template of fpm is a configuration file, and fpm only recognizes the configuration file of www.conf
[root@lss02 php-fpm.d] # cd / usr/local/php/etc/
[root@lss02 etc] # vi php-fpm.conf / / configure fpm module
Pid = run/php-fpm.pid / / remove the semicolon
; user = nginx
; group = nginx / / add user and group
[root@lss02 etc] # / usr/local/php/sbin/php-fpm-c / usr/local/php/etc/php.ini / / start the fpm module
[root@lss02 etc] # netstat-anpt | grep 9000
[root@lss02 etc] # ln-s / usr/local/php/bin/* / usr/local/bin/ put the executable program of php into the system recognizable environment to facilitate execution
[root@lss02 etc] # ps aux | grep-c "php-fpm" / / count the number of processes
-update the startup script so that the fpm module can also perform startup management-
[root@lss02 etc] # vi / etc/init.d/nginx
#! / bin/bash
Chkconfig: 35 99 20description: Nginx Service Control Script
PROG= "/ usr/local/nginx/sbin/nginx"
PIDF= "/ usr/local/nginx/logs/nginx.pid"
PROG_FPM= "/ usr/local/php/sbin/php-fpm"
PIDF_FPM= "/ usr/local/php/var/run/php-fpm.pid"
Case "$1" in
Start)
$PROG
$PROG_FPM
Stop)
Kill-s QUIT $(cat $PIDF)
Kill-s QUIT $(cat $PIDF_FPM)
Restart)
$0 stop
$0 start
Reload)
Kill-s HUP $(cat $PIDF)
)
Echo "Usage: $0 {start | stop | restart | reload}"
Exit 1
Esac
Exit 0
-the following is to enable nginx to support the PHP feature-
[root@lss02 etc] # vi / usr/local/nginx/conf/nginx.conf
Location ~ .php ${
Root / usr/local/nginx/html
Fastcgi_pass 127.0.0.1:9000
Fastcgi_index index.php
Fastcgi_param SCRIPT_FILENAME / usr/local/nginx/html$fastcgi_script_name; / / Note the directory name. The root directory of the website must be an absolute path.
Include fastcgi_params
}
[root@lss02 etc] # vi / usr/local/nginx/html/index.php
[root@lss02 etc] # nginx-t
[root@lss02 etc] # service nginx restart
Note that in order to prevent interference, the virtual host configuration needs to be deleted
Test "http://192.168.80.193/index.php" on the web page
-- the following tests whether the database is working properly-
[root@lss02 etc] # mysql-u root-p
Enter password: password
Mysql > CREATE DATABASE bbs; / / create database as bbs
Mysql > GRANT all ON bbs. TO 'bbsadm'@'%' IDENTIFIED BY' admin123'; / / give all database permissions to bbsadm with a password of admin123
Mysql > GRANT all ON bbs.* TO 'bbsadm'@'localhost' IDENTIFIED BY' admin123'; / / allow
Mysql > flush privileges; / / refresh permissions
Mysql > quit
[root@lss02 etc] # vi / usr/local/nginx/html/index.php
Test "http://IP/index.php"" on the web page
-the following installation forums-
[root@lss02 etc] # yum install-y unzip
[root@lss02 etc] # unzip Discuz_X3.4_SC_UTF8_0101.zip-d / opt / / decompress
[root@lss02 ~] # cd / opt/dir_SC_UTF8/ enter the decompression directory
[root@lss02 dir_SC_UTF8] # cp-r upload/ / usr/local/nginx/html/bbs
[root@lss02 dir_SC_UTF8] # cd / usr/local/nginx/html/bbs
[root@lss02 bbs] # chown-R root:nginx. / config/
[root@lss02 bbs] # chown-R root:nginx. / data/
[root@lss02 bbs] # chown-R root:nginx. / uc_client/
[root@lss02 bbs] # chown-R root:nginx. / uc_server/
[root@lss02 bbs] #
[root@lss02 bbs] # chmod-R 777. / config/
[root@lss02 bbs] # chmod-R 777. / data/
[root@lss02 bbs] # chmod-R 777. / uc_client/
[root@lss02 bbs] # chmod-R 777. / uc_server/
Visit the http://IP/bbs/install/index.php / / installation forum
The access address is http://IP/bbs/index.php
Http://IP/bbs/admin.php / / manage backend
-- configure dynamic and static separation--
Delete access control
Configuration on Nginx host: transfer b.jpg to server
[root@lss02 html] # vi / usr/local/nginx/conf/nginx.conf
Location ~ .php ${
Proxy_pass http://192.168.80.101;
} / / transfer the PHP dynamic request to 192.168.80.101
[root@lss02 html] # rm index.php
[root@lss02 html] # service nginx restart
The configuration above the Apache server:
[root@lss01 ~] # cd / usr/local/httpd/htdocs/
[root@lss01 htdocs] # vi index.html
[root@lss01 htdocs] # service httpd restart
Browser input nginx server ip test:
Nginx server modification:
[root@lss02 html] # vi / usr/local/nginx/conf/nginx.conf
Location. *. (gif | jpg | jpeg | png | bmp | swf) ${
Root html
Expires 1d
} / / these static contents are read locally
[root@lss02 html] # service nginx restart
The configuration above the Apache server:
[root@lss01 htdocs] # vi / usr/local/httpd/htdocs/index.php
[root@lss01 htdocs] # service httpd restart
Bag grab test:
For the above linux7.4+nginx1.13.9+mysql5.7.20+php7.1.10 handouts, if you need to know more, you can continue to pay attention to the innovation of our industry. If you need professional answers, you can contact the pre-sales and after-sales on the official website. I hope this article can bring you some knowledge updates.
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
© 2024 shulou.com SLNews company. All rights reserved.