Compile LNMP manually (details of the experimental steps can be followed)
LNMP represents the web server architecture of Nginx+MySQL+PHP under the Linux system.
Linux is a kind of Unix computer operating system, which is the most popular free operating system at present. Representative versions are: debian, centos, ubuntu, fedora, gentoo and so on.
Nginx is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server.
Mysql is a small relational database management system.
PHP is a scripting language that embeds HTML documents executed on the server side.
These four kinds of software are all free and open source software, which are combined into a free, efficient and scalable website service system.
In this chapter, we will take you to compile LNMP manually.
The experimental steps are four steps:
Install the nginx service
Install the mysql service
Install and configure the PHP parsing environment
Deploy the discuz Community Forum web application
Experimental environment: centos7.5 nginx-1.12 mysql-boot-5.7 php-7.1
The experiment begins.
[install nginx service]
1. The installation environment depends on the installation package:
[root@localhost ~] # yum-y install pcre-devel zlib-devel gcc gcc-c++
2. Create and run users and groups
[root@localhost] # useradd-M-s / sbin/nologin nginx
3. Extract the installation package
Tar zxvf nginx-1.12.2.tar.gz-C / opt/
4. Compilation, installation and configuration optimization
Cd nginx-1.12.2/./configure\-- prefix=/usr/local/nginx\-- user=nginx\-- group=nginx\-- with-http_stub_status_module make & & make install / / compile and install nginxln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ / / create the soft connection systemctl stop firewalld.service of the command / / turn off the firewall setenforce 0 nginx-t / / check if there is something wrong with the configuration file to facilitate the management of nginx services Edit the nginx service script and add it to the systemctl service vim / lib/systemd/system/ nginx.service [Unit] Description=nginxAfter= network.target [Service] Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStart=/usr/local/nginx/sbin/nginxExecReload=/usr/bin/kill-s HUP $MAINPIDExecStop=/usr/bin/ki11-s QUIT $MATNPIDPrivateTmp= true [install] WantedBy=multi-user.targetchmod 754 nginx.service / / Grant execute permission
[install mysql service]
1. Install compilation tools
Yum-y install\ ncurses\ ncurses-devel\ bison\ cmake\ make
2. Decompress the package
Tar zxvf mysql-boost-5.7.20.tar.gz-C / opt
3. Custom configuration
Cd / opt/mycmake\-DCMAKE_INSTALL_PREFIX=/usr/local/mysql\-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock\-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\-DWITH_ BOOST=boost\-DWITH_SYSTEMD=1 / / version 5.7 must add this parameter
4. Compile and install
Make & & make install
5. Add program users and permissions-related settings
Useradd-s / sbin/nologin mysqlchown-R mysql:mysql / usr/local/mysql/ sets the master group
6. Modify the configuration file (delete the original content and copy the following)
Vi / etc/ my.cnf [client] port = 3306default-character-set=utf8socket = / usr/local/mysql/ mysql.socks [mysql] port = 3306default-character-set=utf8socket = / usr/local/mysql/ mysql.socks [mysqld] user = mysqlbasedir = / usr/local/mysqldatadir = / usr/local/mysql/dataport = 3306character_set_server=utf8pid-file = / usr/local/mysql/mysqld.pidsocket = / usr/local/mysql/mysql.sockserver-id = 1sqlcards modeworthy NORICTICTRANSUBSTITIONCONTRICTION codes NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
7. Set environment variables
Echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' > > / etc/profileecho' export PATH' > > / etc/profilesource / etc/profile
8. Initialize the database
Cd / usr/local/mysql/bin/mysqld\-- initialize-insecure\-- user=mysql\-- basedir=/usr/local/mysql\-- datadir=/usr/local/mysql/datacp usr/lib/systemd/system/mysqld.service / usr/lib/systemd/system/
9. Database self-startup, shutdown and status
Systemctl enable mysqldsystemctl start mysqldsystemctl stop mysqldnetstat-natp | grep 3306
10. Set the password
Mysqladmin-uroot-p password mysql-uroot-p / / enter the database
[install PHP service]
1. Install the environment dependency package
Yum install-y\ libjpeg\ libjpeg-devel\ libpng libpng-devel\ freetype freetype-devel\ libxml2\ libxml2-devel\ zlib zlib-devel\ curl curl-devel\ openssl openssl-devel
2. Extract the installation package
Tar jxvf php-7.1.10.tar.bz-C / opt
3. Custom configuration
Cd / opt/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\-- enable-fpm\-- enable-mbstring\-- enable-xml\-- enable-session \-enable-ftp\-enable-pdo\-enable-tokenizer\-enable-zip
4. Modify the configuration file
/ / php has three configuration files:
Php.ini / / Core configuration file
Php-fpm.conf / / process service profile
Www.conf / / extension profile
Cp php.ini-development / usr/local/php/lib/php.ini / / configure core module vim / usr/local/php/lib/php.inimysqli.default_socket = / usr/local/mysql/mysql.sockdate.timezone = Asia/Shanghai / / set the path, just in time / usr/local/php/bin/php-m / / verify the installation of the module
Configure and optimize the fpm module
Cd / usr/local/php/etc/cp php-fpm.conf.default php-fpm.confvim php-fpm.confpid = run/php-fpm.pid / / remove Note Open pidcd / usr/local/php/etc/php-fpm.d/cp www.conf.default www.conf/usr/local/php/sbin/php-fpm-c / usr/local/php/lib/php.ini / / Open the php-fpm module netstat-natp | grep 9000ln-s / usr/local/php/bin/* / usr/local/bin/ create a soft connection. The system recognition command ln-s / usr/local/php/bin/* / usr/local/bin/ creates a soft connection. System identification command
Let nginx support php function
In the vim / usr/local/nginx/conf/nginx.conf / / configuration file, you only need to remove the comment # modify the path location ~\ .php$ {root html; fastcgi_pass 127.0.0.1 php$ 9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME / usr/local/nginx/html$fastcgi_script_name Include fastcgi_params;}
5. Configure the home page of the service
Killall-1 nginx/ / restart the nginx service cd / usr/local/nginx/html/mv index.html index.phpvim index.php / / change the original content 192.168.109.137/index.php / / visit the home page
6. Test whether the database is working properly.
Mysql-uroot-pCREATE DATABASE bbs;GRANT all ON bbs.* TO 'bbsuser' @'% 'IDENTIFIED BY' admin123';GRANT all ON bbs.* TO 'bbsuser' @' localhost' IDENTIFIED BY 'admin123';flush privileges;# enter / / configure account file show databases; / view database
7. Test connectivity
Vi / usr/local/nginx/html/index. The content of the original test page of php## was changed as follows: systemctl restart nginx tests "http://192.168.109.137/index.php"" on the web page
[deploy discuz Community Forum web application]
Unzip Discuz_X3.4_SC_UTF8.zip-d / opt # # extract the installation package cd / tmp/dir_SC_UTF8/cp-r upload/ / usr/local/nginx/html/bbs## add permissions Enables the service to install cd / usr/local/nginx/html/bbs/chown-R root:nginx. / config/chown-R root:nginx. / data/chown-R root:nginx. / uc_client/chown-R root:nginx. / uc_server/chmod-R 777. / config/chmod-R 777. / data/chmod-R 777. / uc_client/chmod-R 777. / uc_server/192.168.109.137/bbs/install/index.php / / after the permission is set Install 192.168.109.137/bbs/index.php / / installation is complete, login to use
Manual compilation of LNMP is completed. Other services about nginx can be viewed on my home page.