当前位置:网站首页>LNMP compilation and installation

LNMP compilation and installation

2022-06-25 19:13:00 Getting drunk and getting better

Create package storage address

sudo mkdir /usr/local/software

1、Nginx install
Installation dependency

apt-get install gcc automake autoconf make

install gcc g++ The dependent libraries

sudo apt-get install build-essential
sudo apt-get install libtool

install pcre Dependency Library

sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev

install zlib Dependency Library

sudo apt-get install zlib1g-dev

install SSL Dependency Library

sudo apt-get install openssl

The formal installation nginx

cd /usr/local/software
#  Download stable version 
sudo wget http://nginx.org/download/nginx-1.14.2.tar.gz
#  decompression 
sudo tar -zxvf nginx-1.14.2.tar.gz
#  cut-in   Unpack the directory 
cd /usr/local/software/nginx-1.14.2
#  Be careful :  To switch to root The user executes the configuration command 
#  To configure , This last nginx All installation files for , Including configuration files , Will be installed to /usr/local/nginx Directory 
./configure --prefix=/usr/local/nginx
make && make install

start-up nginx And look at the process

sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#  Be careful :-c  Specify the path of the configuration file , If not ,nginx The configuration file for the default path will be loaded automatically , Can pass -h View help command .
#  Check the process :
ps -ef | grep nginx

Check the port

netstat -lntp

Configure boot up

sudo vim /etc/rc.local 
#  Add the following code 
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf &

Add environment variables ( Others are separated by colons )

sudo vim /etc/profile
#  Join in nginx  route 
export PATH=$PATH:/usr/local/nginx/sbin

install php (php 7.2)
Installation dependency

apt-get install libxml2-dev gcc autoconf

Get the source code and compile and install
Upload directly from local php Source code , perhaps wget Get online resources

sudo mkdir /usr/local/php
cd /usr/local/software
#  Switch to  root  user   Perform the following actions 
wget https://www.php.net/distributions/php-7.2.16.tar.gz
tar -zxvf php-7.2.16.tar.gz
cd php-7.2.16
# Installation dependency 
sudo apt update
sudo apt install gcc
sudo apt install make
sudo apt install openssl
sudo apt install curl
sudo apt install libbz2-dev
sudo apt install libxml2-dev
sudo apt install libjpeg-dev
sudo apt install libpng-dev
sudo apt install libfreetype6-dev
sudo apt install libzip-dev
sudo apt install libssl-dev

precompile

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl-dir=/usr/bin/curl --enable-mbregex --enable-mbstring --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

Until you see this interface , Precompile successful
 Insert picture description here
Compile and install , Parameters -j Specify the number of compilation threads for multi-threaded compilation

sudo make -j4 

See this to complete the compilation
 Insert picture description here
Execute the following command to install

sudo make install

After the installation is completed, enter the command to view the version

/usr/local/php/bin/php -v

Successfully compiled and installed from source code .
Finally, copy a configuration file compiled from the source code

sudo cp php.ini-development /usr/local/php/etc/php.ini

To configure php-fpm command :

cd /usr/local/php/etc      cp php-fpm.conf.default php-fpm.conf
cd php-fpm.d            cp www.conf.default www.conf
 
groupadd www
useradd -g www www

start-up

/usr/local/php/sbin/php-fpm

verification

ps -ef |grep php-fpm

Nginx analysis PHP Multisite configuration

cd /usr/local/nginx/conf

Edit the configuration file to multiple files

vim nginx.conf

hold nginx.conf Inside server{} Comment out in , Then import the following files
 Insert picture description here
New folder

mkdir vhosts
cd vhosts/

New configuration file , It is recommended that the file name be recognized , One file, one site

vim 1.com.conf

Profile contents

server {
    
    listen    8080;            #  Listening port 
    server_name 127.0.0.1;  #  Site domain name 
    root /home/wwwroot/test/public;       #  Site root 
    index index.html index.htm index.php default.html default.htm default.php;  #  The default navigation page 
    location / {
    
         if (!-e $request_filename) {
    
            rewrite ^(.+?\.php)(/.+)$ /$1?s=$2 last;
            rewrite ^(.*)$ /index.php?s=$1 last;
            break;
        }
    }
    # PHP To configure 
    location ~ ^(.+.php)(.*)$ {
    
            fastcgi_split_path_info ^(.+.php)(.*)$;
            include fastcgi.conf;
            fastcgi_pass  127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param  PATH_INFO          $fastcgi_path_info;
    }
    
    location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ {
    
        access_log off;
        root /home/wwwroot/test/public;
        expires 7d;
    }
}

restart

cd /usr/local/nginx
./sbin/nginx -s reload

Successful visit
Configure boot up

sudo vim /etc/rc.local
#  Add code 
/usr/local/php/sbin/php-fpm &

Add environment variables

sudo vim /etc/profile
#  Join in nginx  route 
export PATH=$PATH:/usr/local/nginx/sbin:/usr/local/php/bin

mysql install
Installation dependency ( If you compile and install ) Be careful : MySQL8.0 Need to use gcc The version is 5.3 above

sudo apt install gcc g++ libxml2 libxml2-dev libssl-dev curl libcurl4-openssl-dev libgd-dev
sudo apt install numactl
sudo apt install libaio-dev
sudo apt install cmake

Download binaries Unzip and move

sudo wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz
sudo xz -d mysql-8.0.15-linux-glibc2.12-x86_64.tar.xz
sudo tar xvf mysql-8.0.15-linux-glibc2.12-x86_64.tar
sudo mv mysql-8.0.15-linux-glibc2.12-x86_64 /usr/local/mysql

add to mysql Users and groups and grant permissions

groupadd mysql
useradd -r -g mysql -s /bin/false mysql
cd /usr/local/mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files
sudo passwd mysql

Initialization operation

sudo bin/mysqld --initialize --user=mysql

After implementation, it is as follows : ( The second line The last part is Randomly generated passwords )

2022-02-13T12:53:04.809140Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.15) initializing of server in progress as process 7638
2022-02-13T12:53:07.799894Z 5 [Note] [MY-010454] [Server] A temporary password is generated for [email protected]localhost: laBnPPN)3dIh
2022-02-13T12:53:09.210107Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.15) initializing of server has completed

Copy service file

cp support-files/mysql.server /etc/init.d/mysql.server

Configure boot service

sudo vim /etc/rc.local
#  increase mysql Open command 
/usr/local/mysql/bin/mysqld_safe --user=mysql &

Add environment variables

sudo vim /etc/profile
#  Add the following path 
/usr/local/mysql/bin
#  Update variables and take effect 
source /etc/profile

Turn on mysql The server

bin/mysqld_safe --user=mysql &

Log in with the password you just recorded

bin/mysql -uroot -p

modify root password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'
原网站

版权声明
本文为[Getting drunk and getting better]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202190519469690.html

随机推荐