you can follow this blog to quick and easy install Nginx mysql php

 http://www.codecoder.top/linux/how-to-install-the-lnmp-one-click-installation-package.html 

1, the environment description

CentOS 7 or above
SELinux closed
Firewall closed

2, install Nginx

Add the EPEL package’s repository source
yum -y install epel-release 

to install Nginx 

yum -y install nginx via EPEL repository

 

3, install PHP7 and PHP7-FPM

Add the PHP7-FPM webtatic repository and install PHP7 and feature-related packages.

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php72w-fpm php72w-cli php72w-gd php72w-mcrypt php72w-mysql php72w-pear php72w-xml php72w-mbstring php72w-

 

4, configure PHP-FPM

We need to configure php-fpm to work with Nginx. Php7-fpm will run with the nginx user and listen on port 9000.
Use vim to edit the default php7-fpm configuration file.
Vim /etc/php-fpm.d/www.conf 

 

modifies the following non-contiguous record points, modifies users, specifies ports, and enables environment variables.

#Line 8-10
user = nginx
group = nginx
#Line 22
listen = 127.0.0.1:9000
#Line 366-370
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

 

Save the file and exit the vim editor. You
need to create a new folder session in the /var/lib/ directory and change its owner to a nginx user. Finally start php-fpm and Nginx and set them to the service that starts with the boot.
mkdir -p /var/lib/php/session
chown nginx:nginx -R /var/lib/php/session/

systemctl start php-fpm
systemctl start nginx

systemctl enable php-fpm
systemctl enable nginx

 

5, install mysql5.7

Download the mysql source installation package
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

Install mysql source

Yum localinstall mysql57-community-release-el7-8.noarch.rpm 

Check if the mysql source is successfully installed 

yum repolist enabled | grep "mysql. -community. " 

See the above figure indicating that the installation was successful. 

2, install MySQL
yum install mysql-community-server

 

3, start MySQL service
systemctl start mysqld 

view MySQL startup state 

systemctl status mysqld 

● mysqld.service – MySQL Server 

Loaded: loaded (/usr/lib/systemd/system/mysqld.service ; disabled; vendor preset: disabled)
Active: active (running) since 52016-06-24 04:37:37 CST; 35min ago
Main PID: 2888 (mysqld)
CGroup: /system.slice/mysqld.service
└─2888 /usr/sbin/mysqld –daemonize –pid-file=/var/run/mysqld/mysqld.pid
 localhost.localdomain systemd[1]: Starting MySQL Server…
localhost.localdomain systemd[1]: Started MySQL Server.
4, boot
systemctl enable mysqld 
systemctl daemon-reload 

5, modify the root local login password

After the mysql installation is complete, a default password is generated for root in the /var/log/mysqld.log file. Find the root default password in the following way, and then log in to mysql to modify: 

shell> grep 'temporary password' /var/log/mysqld.log

the shell> MySQL -uroot--p 
MySQL> the ALTER the USER 'the root' @ 'localhost' the IDENTIFIED BY 'xxxxx'; 
or 
mysql> set password for 'root' @ 'localhost' = password ( 'xxxxx'); 

Note :mysql5.7 installs the password security check plugin (validate_password) by default. The default password check policy requires that the password must contain: uppercase and lowercase letters, numbers and special symbols, and the length cannot be less than 8 digits. Otherwise, you will be prompted with ERROR 1819 (HY000): Your password does not satisfy the current policy requirements error, as shown below:

Install MariaDB
Here, MariaDB is used as the database for Nextcloud. You can install the mariadb-server package from the CentOS default remote repository directly using the yum command.
yum -y install mariadb mariadb-server

systemctl start mariadb
systemctl enable mariadb

 

6, configure MariaDB

Initialize the root user with the MySQL initialization directive. The default password is blank.
mysql_secure_installation
#process
Set root password? [Y/n] Y
New password:
Re-enter new password:

Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

 

First log in to MySQL using the command
mysql -u root –p

Enter the following mysql query statement to create a new database and user. 

Create database nextcloud_db; 
create user nextcloud@localhost identified by 'password'; 
grant all privileges on nextcloud_db.* to nextcloud@localhost identified by 'password'; 
flush privileges; 
exit;  

 

this sets the password, log in now Go to the mysql shell and create a new database and user for Nextcloud. Here I create a database named nextcloud_db and a user named nextcloud with the user password liaojun@YANG. Of course, choose a safer password for your own system.

7, install the SSL certificate

Create a new directory for the SSL file:
Mkdir -p /etc/nginx/cert/ 

can use OpenSSL self-signed certificate, but it is recommended to use officially certified SSL certificate.
openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/nextcloud.crt -keyout /etc/nginx/cert/nextcloud.key

 

Store the applied SSL certificate in this directory and set the permissions of the certificate:
chmod 700 /etc/nginx/cert 
chmod 600 /etc/nginx/cert/* 

 

8. Download and install Nextcloud

find the correct official download library: https ://download.nextcloud.com/server/releases/Install the
necessary download and unzip tool
yum -y install wget unzip

Use wget to download the latest Nextcloud 14 from the official website.

wget https://download.nextcloud.com/server/releases/nextcloud-14.0.3.zip

Unzip Nextcloud and move it to the /var/www directory.

Unzip nextcloud-14.0.3.zip 
mv nextcloud/ /var/www/ 

Create a file storage folder for NextCloud and grant certain permissions.

cd /var/www
mkdir -p nextcloud/data
chown nginx:nginx -R nextcloud/

 

Manually specify the file storage location
If you want to modify the location of the file storage (such as you purchased another cloud hard disk),
you need to edit the nextcloud configuration file and modify the folder pointed to by datadirectory.
/var/www/nextcloud/config/config.sample.php Vim
to ‘datadirectory’ => ‘/ var / www / owncloud_data /’
modify ‘datadirectory’ => ‘your path’

9 , configure Nginx forwarding rules

We need to write the forwarding protocol for nextcloud in the Nginx configuration file.
We can create a new configuration file and write the information directly. When Nginx is reloaded, we can use the configuration file.
Cd /etc/nginx/conf.d/ 
vim nextcloud.conf

 

Modify and write the configuration according to individual needs:
 server_name needs to be changed to the domain name
ssl_certificate and ssl_certificate_key need to be changed to the corresponding file of the SSL certificate
root needs to be changed to the path of the nextcloud folder

upstream php-handler {
server 127.0.0.1:9000;
#server unix:/var/run/php/php7.0-fpm.sock;
}

server {
listen 80;
listen [::]:80;
server_name 172.16.12.105;
# enforce https
return 301 https://serverna m e server_nameserver 
n
​
 of m is REQUEST_URI; 
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name 172.16.12.105;
# Use Mozilla's guidelines for SSL/TLS settings
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
# NOTE: some settings below might be redundant
ssl_certificate /etc/nginx/cert/nextcloud.crt;
ssl_certificate_key /etc/nginx/cert/nextcloud.key;

# Add headers to serve security related headers
# Before enabling Strict-Transport-Security headers please read into this
# topic first.
# add_header Strict-Transport-Security "max-age=15768000;
# includeSubDomains; preload;";
#
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Referrer-Policy no-referrer;

# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;

# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;

# Path to the root of your installation
root /var/www/nextcloud/;

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
# last;

location = /.well-known/carddav {
  return 301 $scheme://$host/remote.php/dav;
}
location = /.well-known/caldav {
  return 301 $scheme://$host/remote.php/dav;
}

# set max upload size
client_max_body_size 512M;
fastcgi_buffers 64 4K;

# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;

location / {
    rewrite ^ /index.php$request_uri;
}

location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
    deny all;
}
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
    deny all;
}

location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param HTTPS on;
    #Avoid sending the security headers twice
    fastcgi_param modHeadersAvailable true;
    fastcgi_param front_controller_active true;
    fastcgi_pass php-handler;
    fastcgi_intercept_errors on;
    fastcgi_request_buffering off;
}

location ~ ^/(?:updater|ocs-provider)(?:$|/) {
    try_files $uri/ =404;
    index index.php;
}

# Adding the cache control header for js and css files
# Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff|svg|gif)$ {
    try_files $uri /index.php$request_uri;
    add_header Cache-Control "public, max-age=15778463";
    # Add headers to serve security related headers (It is intended to
    # have those duplicated to the ones above)
    # Before enabling Strict-Transport-Security headers please read into
    # this topic first.
    # add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
    #
    # WARNING: Only add the preload option once you read about
    # the consequences in https://hstspreload.org/. This option
    # will add the domain to a hardcoded list that is shipped
    # in all major browsers and getting removed from this list
    # could take several months.
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
    add_header Referrer-Policy no-referrer;

    # Optional: Don't log access to assets
    access_log off;
}

location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
    try_files $uri /index.php$request_uri;
    # Optional: Don't log access to other assets
    access_log off;
}
After checking the correctness of the configuration, you can use the domain name to access the network disk.
nginx -t 
systemctl restart nginx

 

10 LDAP integration

1, the installation package solution depends on
yum install openldap 
yum install openldap-devel 

 

2, copy library file
cp -frp /usr/lib64/libldap* /usr/lib/  

 

3, download the PHP version source package
http://php.net /downloads.php
can view your own version with php –v
Upload and unzip
tar jxvf php-7.2.11.tar.bz2

 

4. Find /ext/ldap/ from the extracted package and
go to the folder.
Use
/usr/bin/phpize  
yum install gcc 

 

5. Add the new module to the current PHP.
./configure --with-php-config=/usr/bin/php-config --with-ldap

 

6、
make && make install

 

7. Add
vim /etc/php.ini 
extension / ldap.so in /etc/php.ini 

 

8 Restart php
systemctl restart php-fpm 
systemctl restart nginx

9Check if the installation is successful php -m