[LNMP] Architecture and application deployment to build a movie website

Prepare environment


A virtual machine 192.168.108.67

Turn off firewall

systemctl stop firewalld

iptables -F

setenforce 0

Check disc

View yum repository

Install nginx dependencies

[root@localhost ~]# yum -y install pcre-devel zlib-devel

 

Create an administrative nginx user (used to run nginx)

[root@localhost ~]# useradd -M -s /sbin/nologin nginx

- `useradd`: command to create a user.

- `-M`: Indicates not to create the user's home directory.

- `-s /sbin/nologin`: Specify the user's login shell as `/sbin/nologin`, which means that the user cannot log in to the system through the login shell. It is usually used to create a system service account.

- `nginx`: the username of the new user.

To sum up, the function of this command is to create a user named `nginx`, but not create its home directory, and set its login shell to `/sbin/nologin`, which is usually used to create a system service account

 

Then drag the prepared nginx source code package into the virtual machine

 

Unpack

[root@localhost ~]# tar xf nginx-1.16.0.tar.gz -C /usr/src

Enter the unzipped nginx directory

[root@localhost ~]# cd /usr/src/nginx-1.16.0/

Configure nginx

[root@localhost nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --user=nginx

By executing this command, you can compile and install the Nginx server with the HTTP stub status module, install it in the `/usr/local/nginx` directory, and specify the user where Nginx runs as `nginx`

If you need other dependencies during the installation process, you can choose to install them yourself.

yum -y install gcc-c++

yum -y install pcre-devel

yum -y install zlib-devel

Compile and install

[root@localhost nginx-1.16.0]# make && make install

Optimize Nginx command and make a command link

[root@localhost ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/

Optimize Nginx commands

[root@localhost ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/

Check the configuration file for errors

[root@localhost ~]# nginx -t

[root@localhost etc]# vim /etc/init.d/nginx ——Enter nginx script

#!/bin/bash

#chkconfig:2345 99 20

# description: Nginx Server Control Script

PROG="/usr/local/nginx/sbin/nginx"

PIDF="/usr/local/nginx/logs/nginx.pid"

PROG_FPM="/usr/local/sbin/php-fpm"

PIDF_FPM="/usr/local/php5/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

[root@localhost ~]# chmod +x /etc/init.d/nginx

[root@localhost ~]# chkconfig --add nginx

Install mysql database


 

First check whether there are libaio dependency packages and install them if not.

[root@localhost conf]# yum -y install libaio

Upload the MySQL binary installation package for binary installation

 

 

Unzip

[root@localhost ~]# tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local

[root@localhost ~]# cd /usr/local/

change name

[root@localhost local]# mv mysql-5.7.24-linux-glibc2.12-x86_64/ /usr/local/mysql

Create a system user to run it

[root@localhost local]# useradd -s /sbin/nologin mysql

cd to /usr/local and change mysql permissions to the user we just created

[root@localhost ~]# cd /usr/local/

[root@localhost ~]# chown -R mysql:mysql mysql

 

 Initialize database to generate password

[root@localhost ~]# /usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize

Modify configuration file

[root@localhost mysql]# vim /etc/my.cnf

[mysqld]

datadir=/usr/local/mysql/data

socket=/tmp/mysql.sock

[mysqld_safe]

log-error=/usr/local/mysql/data/mysql.log

pid-file=/usr/local/mysql/data/mysql.pid

To restart the service, first cd to mysql and then execute the restart command.

[root@localhost ~]# cd /usr/local/mysql

[root@localhost mysql]# ./support-files/mysql.server start

Add execution permissions to the script

[root@localhost mysql]# chmod +x /etc/init.d/mysqld

start up

[root@localhost ~]# systemctl start mysqld

Make command connection

[root@localhost ~]# ln -s /usr/local/mysql/bin/* /usr/bin/

Change MySQL password

[root@localhost mysql]# mysqladmin -uroot -p'ay_iLLjr7eRB' password 123456

Install PHP


Install dependency packages

[root@localhost ~]# yum -y install gd libxml2-devel.x86_64 libjpeg-devel libpng-devel

 

 

Drag the PHP source code package into the virtual machine

Unzip

[root@localhost ~]# tar xf php-5.6.39.tar.gz -C /usr/src

cd into the PHP directory

[root@localhost ~]# cd /usr/src/php-5.6.39/

 

Then compile and install

[root@localhost php-5.6.39]# ./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php5 --enable-mbstring --enable-fpm --with-jbeg-dir=/usr/lib && make && make install

Copy the main configuration file

[root@localhost php-5.6.39]# cp php.ini-production /usr/local/php5/php.ini

Then do command optimization

[root@localhost php-5.6.39]# ln -s /usr/local/php5/bin/* /usr/local/bin/

[root@localhost php-5.6.39]# ln -s /usr/local/php5/sbin/* /usr/local/sbin/

 

Drag this package to the root of the virtual machine

 

Unzip

[root@localhost ~]# tar xf zend-loader-php5.6-linux-x86_64_update1.tar.gz

cd to its path

 cd zend-loader-php5.6-linux-x86_64/

copy

[root@localhost zend-loader-php5.6-linux-x86_64]#

cp ZendGuardLoader.so /usr/local/php5/lib/php

Enter the php configuration file

[root@localhost zend-loader-php5.6-linux-x86_64]# vim /usr/local/php5/php.ini

On the last line write the adder's

zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so

zend_loader.enable=1

 

 

 

Go to etc

[root@localhost zend-loader-php5.6-linux-x86_64]# cd /usr/local/php5/etc/

[root@localhost etc]# ls

Adjust and rename

[root@localhost etc]# mv php-fpm.conf.default php-fpm.conf

 

Enter the php configuration file

[root@localhost etc]# vim php-fpm.conf

Modify the content of the following lines

149 user = php

150 group = php

241 pm.max_children = 50

246 pm.start_servers = 20

251 pm.min_spare_servers = 5

256 pm.max_spare_servers = 35

 

 

Create php user

[root@localhost etc]# useradd -M -s /sbin/nologin php

start up

[root@localhost etc]# /usr/local/sbin/php-fpm

Modify nginx configuration file

[root@localhost html]# vim /usr/local/nginx/conf/nginx.conf

Now change the username in the first line to nginx

user  nginx;
worker_processes  1;
 

add a location

location ~ \.php$ {

            root html;

            fastcgi_pass 127.0.0.1:9000;

            fastcgi_index index.php;

            include fastcgi.conf;

        }

 

 

Start nginx

[root@localhost etc]# /usr/local/nginx/sbin/nginx -t (Displaying the following two lines indicates that there is no problem with the configuration file)

 [root@localhost etc]# /usr/local/nginx/sbin/nginx (start command)

Reload nginx configuration file

killall -HUP nginx

Write test files

[root@localhost html]# vim /usr/local/nginx/html/php.php

Write the following

<?php

phpinfo();

?>

 

 

connect mysql

[root@localhost html]# vim /usr/local/nginx/html/mysql.php

write

<?php

$link=mysqli_connect('localhost','root','123456');

if($link) echo "<h1>Done</h1>";

mysqli_close();

?>

 

Visit: http://192.168.1.125/mysql.php

 

Deploying WEB applications in LNMP platform- 1

Push the prepared SKYUC application source code package into the virtual machine

 

Unzip

[root@localhost ~]# unzip SKYUC.v3.4.2.SOURCE.zip

[root@localhost ~]# cd SKYUC.v3.4.2.SOURCE

[root@localhost SKYUC.v3.4.2.SOURCE]# rm -rf /usr/local/nginx/html/*

[root@localhost SKYUC.v3.4.2.SOURCE]# cp -rf wwwroot/ /usr/local/nginx/html/

[root@localhost SKYUC.v3.4.2.SOURCE]# cd /usr/local/nginx/html 

 

Owner

[root@localhost html]#cd wwwroot

[root@localhost wwwroot]# chown -R php:php admincp/ data/ templates/ upload/ 

 

Create database and authorized users 

 [root@localhost html]# mysql -u root -p123456

  mysql> create database skyuc;

  mysql> grant all on skyuc.* to skyuc@localhost identified by '123';

  mysql> flush privileges;

 

4.Access _

IE --> http://192.168.100.20/wwwroot/index.php

 

Follow the steps and fill in the information and click Install Now

 

 

After the installation is complete, choose where to enter

 

front page

 

Fill in the administrator user and password we created in the background

 

then enter

 

Guess you like

Origin blog.csdn.net/2302_77750172/article/details/131562281