Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure and install LNMP site-building environment

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to configure and install the LNMP site environment, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Install OpenResty

For better performance and flexibility, OpenResty chooses to compile. OpenResty is a high-performance Web platform based on Nginx and Lua, which has a very good scalability to make the server perform better. The tutorials will rely entirely on the dependencies in the build of the Linux distribution, eliminating the post-compilation maintenance costs.

PHP

The PHP installed by the software source runs in / run/php/php7.2-fpm.sock by default in the state of Unix Socket, which performs better than using TCP as localhost:9000.

Install software source extension

Install the Software Source extension tool:

Apt-y install software-properties-common

To add the PHP PPA source of Ond ej Sur arrow, press enter once:

Add-apt-repository ppa:ondrej/php

Update the software source cache:

Apt update installation software

Install PHP7.2:

Apt install php7.2-fpm php7.2-mysql php7.2-curl php7.2-gd php7.2-mbstring php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-opcache-y

Install PHP7.1:

Apt install php7.1-fpm php7.1-mysql php7.1-curl php7.1-gd php7.1-mbstring php7.1-mcrypt php7.1-xml php7.1-xmlrpc php7.1-zip php7.1-opcache-y

Install PHP7.0:

Apt install php7.0-fpm php7.0-mysql php7.0-curl php7.0-gd php7.0-mbstring php7.0-mcrypt php7.0-xml php7.0-xmlrpc php7.0-zip php7.0-opcache-y

Install PHP5.6:

Apt install php5.6-fpm php5.6-mysql php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-xml php5.6-xmlrpc php5.6-zip php5.6-opcache-y set PHP

Take PHP7.2 as an example, other versions only need to change the version number to their own. After the installation is complete, edit / etc/php/7.2/fpm/php.ini replacement; cgi.fix_pathinfo=1 is the cgi.fix_pathinfo=0 shortcut command:

Sed-I's etc/php/7.2/fpm/php.ini management PHP. Fixtures pathinfooted 1 way CGI. Fixtures pathinfores 0Compact'/ bind

Once installed, restart first! More actions:

Systemctl restart php7.2-fpm # restart systemctl start php7.2-fpm # start systemctl stop php7.2-fpm # turn off systemctl status php7.2-fpm # check status

View the current PHP version:

Php-vMariaDB

Here we use MariaDB instead of MySQL,MariaDB database management system is a branch of MySQL, mainly maintained by the open source community, the purpose of licensing MariaDB with GPL is to be fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL.

Install MariaDB reference: [1024 ways to play Cloud Computing] install MariaDB and manage it through DMS

Can achieve efficient and visual management of MariaDB database through Aliyun's DMS products, intuitive and efficient.

Set up

It doesn't make sense to just install OpenResty, MariaDB, and PHP without combining them. So how do you create a virtual subhost and have OpenResty load PHP-FPM?

PHP-FPM is enabled by default host installation probe and phpMyAdmin

Modify this paragraph in / usr/local/openresty/nginx/conf/nginx.conf to: the following PHP version is 7.2, and the anti-cross-site parameter is also included. Remember to modify other versions:

# default # # server {# # run port listen 80; # # this means that this setting server_name _; access_log / data/wwwlogs/access_nginx.log combined; # log directory root/ data/wwwroot/default is used except for the non-specified domain name # website file directory index index.html index.htm index.php; # first page file priority # # PHP location ~ [^ /]\ .php (/ | $) {fastcgi_pass unix:/run/php/php7.2-fpm.sock; fastcgi_index index.php; include fastcgi.conf; fastcgi_param PHP_VALUE "open_basedir=$document_root:/tmp/:/proc/" } # # below are cache location ~. *\. (gif | jpg | jpeg | png | bmp | swf | flv | ico) ${expires 30d; access_log off;} location ~. *\. (js | css)? ${expires 7d; access_log off;} location ~ /\ .ht {deny all;}} download probe cd / data/wwwroot/defaultwget cache tz.zip

Visit: http://yourip/tz.php can see the cordial Yahei probe.

Download phpMyAdmincd / data/wwwroot/defaultwget https://files.phpmyadmin.net/phpMyAdmin/4.7.1/phpMyAdmin-4.7.1-all-languages.zipunzip phpMyAdmin-4.7.1-all-languages.zipmv phpMyAdmin-4.7.1-all-languages pma

Visit: http://yourip/pma can see the cordial phpMyAdmin.

Virtual sub-host

Create a virtual sub-host for the domain name, and first create a directory to store the content:

Mkdir-p / data/wwwroot/ host directory name mkdir-p / usr/local/openresty/nginx/conf/vhost/

Next, create a subhost configuration file and remember to change server_name yourdomian; to server_name your domain name:

Cat > > / usr/local/openresty/nginx/conf/vhost/yourdomian.conf

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report