Configure LEMP+Redis+telnet+openssh under Linux system

  First install openssh server, and then you can access Linux through XShell. You can also upload and download files through the scp command

sudo apt-get install openssh-server

Installing nginx

sudo apt install nginx 

OpenResty is a high-performance Web platform based on Nginx and Lua. It integrates a large number of sophisticated Lua libraries, third-party modules and most dependencies. It is used to easily build dynamic Web applications, Web services and dynamic gateways that can handle ultra-high concurrency and high scalability. With the help of Nginx's event driven model and non blocking IO, high-performance Web applications can be realized. Moreover, OpenResty provides a large number of components, such as Mysql, Redis, Memcached, etc., which makes it easier and easier to develop Web applications on Nginx. At present, the Nginx+Lua architecture is used in JD, such as real-time price, second kill, dynamic service, single product page, list page, etc. other companies, such as Taobao, qunar, etc.

telnet tests whether the remote host port is open

sudo apt install telnet

Install mysql5.7

sudo apt install mysql-server

Modify the password of root and add skip grant tables

>sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

  After configuration, restart MySQL to log in without password

>mysql -uroot
mysql>update mysql.user set plugin="mysql_native_password" where user="root";
mysql>update mysql.user set authentication_string=password('0rb!t') where user='root' and Host = 'localhost';

Delete skip grant tables and restart mysql.

sudo service mysql restart

MySQL allows remote access settings

>sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
# bind-address          =
grant all privileges on *.* to 'root'@'%' identified by '0rb!t' with grant option;

navicat expiration cracking

rm ~/.navicat64/*.reg #If not, delete the directory

Install php

sudo apt install -y php-cli php-fpm php-dev libmcrypt-dev php-pear php-mysql php-sqlite3 php-uuid php-zip php-intl php-xml php-zmq php-imagick php-mcrypt php-curl php-bz2 php-memcached php-gd php-mbstring php-bcmath php-redis php-mongodb php-amqp
pecl install mcrypt
ln -s  /etc/php/7.2/mods-available/mcrypt.ini /etc/php/7.2/fpm/conf.d/
ln -s  /etc/php/7.2/mods-available/mcrypt.ini /etc/php/7.2/cli/conf.d/

  In order to avoid trouble (too lazy for high soft links), we simply save the site configuration files to conf.d for unified management

sudo cp /etc/nginx/sites-enabled/default /etc/nginx/conf.d/default.conf
sudo rm -rf /etc/nginx/sites-available/
sudo rm -rf /etc/nginx/sites-enabled/

  Backup default profile

sudo cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.bak

In linux, nginx server and PHP FPM can be implemented through tcp socket and unix socket.

unix socket configuration

# vi /etc/php/7.2/fpm/pool.d/www.conf 
listen       = /var/run/php5-fpm.sock 
listen.owner = www-data = www-data

If you use tcp to access, you can use the above comments, and use the following

listen =
user   = www-data 
group  = www-data

#Set the default number and maximum number of PHP FPM child processes to start
pm.max_children = 200
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 30

Since 5.3.9, php has officially added a configuration "security.limit_extensions". By default, only files with the extension ". php" are allowed to be executed, resulting in the problem that other types of files are not supported

security.limit_extensions=.php .html .js .css .jpg .jpeg .gif .png .htm

Prompt failed to retrieve TCP when starting PHP FPM_ Info for socket: for the problem of protocol not available, modify php-fpm.conf file and set log_level = alert, restart PHP FPM

php multi version coexistence switch

sudo update-alternatives --config php 


View PHP FPM TCP port number

netstat -tln | grep 900*

  Check the service list. The + sign indicates that it has been started, and the - sign indicates that it has not been started

service --status-all

  Restart PHP FPM service

service php7.2-fpm restart

View the file location of PHP FPM

ps -ef | grep php-fpm.conf

Modify the default configuration file and add php support

sudo vim /etc/nginx/conf.d/default.conf

Restart nginx

sudo service nginx restart

  Save configuration access   http://localhost/phpinfo.php  , If the phpinfo page appears, you are done. If it cannot be started, find the reason in the / var/log/nginx/error.log file

pkill -9 nginx

  View nginx process commands

ps -ef | grep  nginx

PHP FPM belongs to the WWW data user group by default, but its permission is very low. For example, it cannot create folders, so it needs to be authorized

sudo chown -R www-data:www-data /data/www
sudo chmod -R 775 /data/www

  You can execute the following command to see how your current PHP FPM runs

ps aux | grep -v root | grep php-fpm | cut -d\  -f1 | sort | uniq

Install Redis

1. Install Redis service

apt-get install redis-server

2. Start service

/etc/init.d/redis-server start

3. Connection service


redis-cli -h host -p port -a password

Install PHP redis extension

sudo apt install php-redis

Redis configuring remote password connection

Modify redis.conf  

The default path in Ubuntu is / etc/redis/redis.conf, or you can use whereis redis.conf to find it directly and comment on this line

bind ::1 

Change the protected mode to no. It is recommended to set the password for Redis and uncomment this line

protected-mode no
requirepass 0rb!t

0rb!t is the current password. You can modify it yourself, and then restart the Redis service. Now you can use the password to remotely connect to Redis

Error while reading line from the server. [tcp://]

Set read_write_timeout=-1 and timeout parameter of redis.conf = 0.

Tags: PHP lua

Posted on Thu, 30 Sep 2021 19:18:14 -0400 by monke