LNMP environment setup (php7.3 installation under Centeros 7.7, PHP installation sqlsrv extension)

Keywords: PHP yum Nginx MySQL

The article concludes with the material information and installation instructions for this project

Article Directory

1. Basic preparation

  1. System Environment

    CenterOs7.7 x64

  2. Software preparation

    Upload the following files to the server/usr/local/src directory

  3. Configure the web server base library

    Perform the following command to install common dependency libraries for web servers.

    sudo yum -y install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc+±devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch cmake

    Completion Tip

2. Install Mysql

Handle slow download problem Change yum source

Backup source yum source

If it is a domestic downloaded entOS, it is likely that the domestic YUM source has been set up.
Back up the *.repo file under / etc/yum.repos.d/.

Configure Open Source Mirrors for NetEase and Arie in CentOS
wget http://mirrors.aliyun.com/repo/Centos-7.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
 Or manually download the repo file and upload it to / etc/yum.repos.d/directory

Clear the system yum cache and generate a new yum cache
 yum clean all #Clear all yum caches on the system
 yum makecache #Generate yum cache

Install epel source
yum list | grep epel-release
yum install -y epel-release

Clear the system yum cache again and regenerate the new yum cache
yum clean all
yum makecache

View system available yum sources and all yum sources
yum repolist enabled
yum repolist all

Test Installation
yum install openssh-server

Download Source
wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

Install rpm source
rpm -ivh mysql57-community-release-el7-7.noarch.rpm

install server
yum -y install mysql-community-server

Start the database
systemctl start mysqld.service

Get a random password
grep "password" /var/log/mysqld.log

Change Password


alter user 'root'@'localhost' identified by 'Cmm11111%%';

Refresh Permissions
flush privileges

Completion Tip

3. Install PHP

  1. Compile and install php

    Enter directory/usr/local/src to perform decompression

    tar -vxf php-7.3.3.tar.bz2

    cd cd php-7.3.3

    Configuration (select appropriate parameters according to your actual needs, recommend not moving)

    ./configure --prefix=/usr/local/php --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql-sock=/var/lib/mysql/mysql.sock --with-libxml-dir=/usr --with-iconv-dir --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-fpm --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir 
    

    The following prompt appears

  2. Compile Installation

    sudo make&&make install

    Successful installation is indicated by the following prompts

4. Install Nginx

  1. Installation steps

    Follow these steps in turn

cd /usr/local/src
tar -zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2 
./configure --prefix=/usr/local/nginx --with-http_ssl_module
make && make install

Start nginx/usr/local/nginx/sbin/nginx

Access (indicates nginx was installed successfully!)

5. Nginx Integration php

  • Nginx Configuration

    nginx configuration directory display

    The configuration under configuration file/usr/local/nginx/conf/nginx.conf is as follows

#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

Note: If you cannot find nginx.conf and fastcgi.conf files, copy their.default files directly

The operation is as follows;

cd /usr/local/nginx/conf
cp ./fastcgi.conf.default  ./fastcgi.conf
cp ./nginx.conf.default ./nginx.conf

  • PHP Configuration

    Configuration file (copy.default file as.conf file if no.conf file exists)

  • Start php-fpm and nginx services

    Start php-fpm and nginx services

    [External chain picture transfer failed, source station may have anti-theft chain mechanism, it is recommended to save the picture and upload it directly (img-nKy882pF-1580349238061) (assets15789858830.png)]

  • Test results

    Write phpinfo file

    <?php
    echo phpinfo();
    ?>
    

    Access web address: server ip/index.php

    Great Italy with the following results

6. Install PHP extensions

For a better operating system php often operates on third-party extension libraries, so compiling and installing extension skills is an essential skill for developers like me.

Example 1: Install Microsoft Database Extensions Example

  1. Download the installation file sqlsrv-5.6.1.tgz


3. Operation:

cd /usr/local/src
tar -zxvf sqlsrv-5.6.1.tgz
cd sqlsrv-5.6.1
/usr/local/php/bin/phpize 
./configure --with-php-config=/usr/local/php/bin/php-config


  1. Error handling hint missing sql.h

Tips for missing header files, simply install the unixodbc toolkit, yum install unixODBC-devel.

Compile the installation again

4. Modify php.ini file to add sqlsrv extension

 vi /usr/local/php/etc/php.ini


5. View the effect

Extension added

View phpinfo from page

END

Focus on the public number "buttonman" to reply to LNMP to get the source code of this information.

Published 5 original articles, received 0 reviews, and visited 155
Private letter follow

Posted by crickettdt on Wed, 29 Jan 2020 18:56:20 -0800