centos7源碼安裝lnmp(新)-創(chuàng)新互聯(lián)

一、安裝nginx:

  1. 下載:
    a. nginx官網(wǎng)及安裝包:
    https://nginx.org/en/download.html
    或
    https://github.com/dollarphper/soft/blob/master/nginx/nginx-1.15.3.tar.gz
  2. 安裝:
    a. 安裝依賴:
    yum  -y  install  pcre-devel
    yum  -y  install  zlib-devel

    b. 安裝nginx:
    cd nginx的下載目錄

    創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站建設(shè)、網(wǎng)站設(shè)計、閬中網(wǎng)絡(luò)推廣、成都微信小程序、閬中網(wǎng)絡(luò)營銷、閬中企業(yè)策劃、閬中品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們大的嘉獎;創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供閬中建站搭建服務(wù),24小時服務(wù)熱線:13518219792,官方網(wǎng)址:muchs.cn
    tar  -xzf  nginx-1.15.3.tar.gz
    cd  nginx-1.15.3
    ./configure  &&  make  &&  make  install
  3. 配置:
    a. 創(chuàng)建nginx用戶:
    useradd  -s  /sbin/nologin  -M  nginx

    b. 修改配置文件:
    vim /usr/local/nginx/conf/nginx.conf

    user nginx;
    worker_processes  1;
    events {
    worker_connections  1024;
    }
    http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    client_max_body_size 8M;
    client_body_buffer_size 128k;
    server {
    listen       80;
    server_name  localhost;
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 2;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ { 
        access_log   off; 
        expires      1h;
    }
    location ~* ^.+\.(css|js|txt|xml|swf|wav)$ {
        access_log   off;
        expires      1h;
    }
    location ~* ^.+\.(html|htm)$ {
        expires      1h;
    }
    location ~* ^.+\.(eot|ttf|otf|woff|svg)$ {
        access_log   off;
        expires max;
    }
    location / {
        add_header 'Access-Control-Allow-Origin' '*';
        autoindex on;
        autoindex_localtime on;
        root   html;
        index  index.html index.htm;
        if (!-f $request_filename) {
            rewrite /(.*)$ /index.php/$1;
        }
        if (!-d $request_filename) {
            rewrite /(.*)$ /index.php/$1;
        }
    }
    location ~ \.php(.*)$ {
        root html;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_index   index.php;
        fastcgi_param PATH_INFO $1;
        fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
                fastcgi_param  PHP_VALUE  "open_basedir=$document_root";
        include        fastcgi_params;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
    }
    }

    c. 創(chuàng)建測試文件:

    echo  "hello world"  >  /usr/local/nginx/html/index.html
  4. 啟動命令:
    a. 啟動:
    /usr/local/nginx/sbin/nginx

    b. 停止:

    /usr/local/nginx/sbin/nginx  -s  stop

    c. 重啟:

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

    d. 添加環(huán)境變量:

    echo  'export  PATH=$PATH:/usr/local/nginx/sbin/'  >>  /etc/profile
    .  /etc/profile

    e. 添加啟動腳本:
    vim /etc/init.d/nginx

    #!/bin/bash
    function start()
    {
    /usr/local/nginx/sbin/nginx
    }
    function stop()
    {
    /usr/local/nginx/sbin/nginx  -s  stop
    }
    case "$1" in
    start)
        start
    ;;  
    stop)
        stop
    ;;  
    restart)
        stop
        start
    ;;
    *)
        echo "Usage : start | stop | restart"
    ;;
    esac

    f. 加載nginx:

    chmod  +x  /etc/init.d/nginx
    systemctl  daemon-reload

    5.測試:
    centos7源碼安裝lnmp(新)

    二、安裝mysql:

  5. 下載:
    https://dev.mysql.com/downloads/mysql/
    或
    https://github.com/dollarphper/soft/blob/master/mysql/mysql-boost-8.0.12.tar.gz
  6. 安裝:
    a. 安裝依賴:
    yum -y install cmake gcc gcc-c++ ncurses  ncurses-devel  libaio-devel  openssl openssl-devel

    b. 創(chuàng)建用戶:

    useradd mysql -s /sbin/nologin -M

    c. 創(chuàng)建文件夾:

    mkdir -p /usr/local/mysql/data

    d. 解壓:

    tar  -xzf  mysql-boost-8.0.12.tar.gz

    e. 編譯安裝:

    cd  mysql-8.0.12
    cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
    -DMYSQL_DATADIR=/usr/local/mysql/data \
    -DSYSCONFDIR=/etc \
    -DMYSQL_TCP_PORT=3306 \
    -DWITH_BOOST=./boost
    make  &&  make  install
  7. 配置:
    a. 修改mysql所屬者為mysql:
    chown  -R  mysql.mysql  /usr/local/mysql

    b. 修改配置文件:
    vim /etc/my.cnf

    [mysqld]
    server-id=1
    port=3306
    basedir=/usr/local/mysql
    datadir=/usr/local/mysql/data
    ngram_token_size=2

    c. 初始化:

    /usr/local/mysql/bin/mysqld  --initialize-insecure  --user=mysql --datadir=/usr/local/mysql/data
    /usr/local/mysql/bin/mysql_ssl_rsa_setup

    d. 啟動服務(wù):

    /usr/local/mysql/bin/mysqld_safe  --user=mysql  &

    e. 添加到環(huán)境變量:

    echo  'export  PATH=$PATH:/usr/local/mysql/bin/'  >>  /etc/profile
    .  /etc/profile

    f. 添加啟動腳本:
    vim /etc/init.d/mysqld

    #!/bin/bash
    function start()
    {
    /usr/local/mysql/bin/mysqld_safe  --user=mysql  &
    }
    function stop()
    {
    /usr/bin/pkill  mysqld
    }
    case "$1" in
    start)
        start
    ;;  
    stop)
        stop
    ;;  
    restart)
        stop
        start
    ;;
    *)
        echo "Usage : start | stop | restart"
    ;;
    esac

    g. 加載mysqld:

    chmod  +x  /etc/init.d/mysqld
    systemctl  daemon-reload

    h. 添加用戶:

    CREATE  USER `root`@`%`  IDENTIFIED  BY  '123456';

    i. 授權(quán):

    GRANT  ALL  ON *.*  TO  `root`@`%`  WITH  GRANT  OPTION;

    j. 刪除系統(tǒng)預(yù)留用戶:

    delete  from  mysql.user  where  host<>'%';

    k. 刷新權(quán)限:

    flush  privileges;

    l. 允許遠(yuǎn)程登錄:
    l-1. 設(shè)置變量:

    SET  GLOBAL innodb_fast_shutdown  =  1;

    l-2. 退出:

    quit

    l-3. 升級:

    mysql_upgrade  -u  root  -p123456
  8. 測試:
    /usr/local/mysql/bin/mysql
    centos7源碼安裝lnmp(新)
    三、安裝php:
  9. 下載:
    http://us1.php.net/downloads.php
    或
    https://github.com/dollarphper/soft/blob/master/php/php-7.2.10.tar.gz
  10. 安裝:
    a. 安裝依賴:
    yum  -y  install  libxml2  libxml2-devel
    yum  -y  install  curl-devel  libjpeg-devel  libpng-devel  freetype-devel
    yum  -y  install  libicu-devel
    yum  -y  install  libxslt-devel
    yum  -y  install  openssl  openssl-devel

    b. 解壓:

    tar  -xzf  php-7.2.10.tar.gz

    c. 編譯:

    cd  php-7.2.10
    ./configure  \
    --prefix=/usr/local/php   \
    --with-config-file-path=/usr/local/php/etc  \
    --enable-fpm  \
    --with-fpm-user=nginx  \
    --with-fpm-group=nginx  \
    --enable-mysqlnd  \
    --with-mysqli=mysqlnd  \
    --with-pdo-mysql=mysqlnd  \
    --with-iconv-dir  \
    --with-freetype-dir=/usr/local/freetype  \
    --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  \
    --enable-mbregex  \
    --enable-mbstring  \
    --enable-intl  \
    --enable-pcntl  \
    --enable-ftp  \
    --with-gd  \
    --with-openssl  \
    --with-mhash  \
    --enable-pcntl  \
    --enable-sockets  \
    --with-xmlrpc  \
    --enable-zip  \
    --enable-soap  \
    --with-gettext  \
    --disable-fileinfo  \
    --enable-opcache  \
    --enable-maintainer-zts  \
    --with-xsl

    d. 安裝:

    make  &&  make  install

    e. 下載pthreads:

    git  clone  https://github.com/krakjoe/pthreads.git

    f. 安裝pthreads:

    cd  pthreads
    phpize
    ./configure  --with-php-config=/usr/local/php/bin/php-config
    make  &&  make install

    g. 開啟pthreads擴(kuò)展:
    vim /usr/local/php/etc/php.ini

    [pthreads]
    extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/pthreads.so

    h. 安裝phpunit:
    h-1. 下載:

    wget  -O  phpunit  https://phar.phpunit.de/phpunit-6.phar

    h-2. 授權(quán):

    chmod  +x  phpunit

    h-3. 添加到環(huán)境變量:

    mv  phpunit  /usr/local/php/bin

    i. 安裝xdebug:
    i-1. 下載:

    git  clone  git://github.com/xdebug/xdebug.git

    i-2. 進(jìn)入目錄:

    cd  xdebug

    i-3. 生成編譯文件:

    /usr/local/php/bin/phpize

    i-4. 編譯:

    ./configure  --enable-xdebug  --with-php-config=/usr/local/php/bin/php-config

    i-5. 安裝:

    make  &&  make  install

    i-6. 配置:

    [xdebug]
    zend_extension=/usr/local/php/lib/php/extensions/no-debug-zts-20170718/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_host=172.20.10.2
    xdebug.remote_port=9000
    xdebug.idekey="PHPSTORM"
  11. 配置:
    a. 拷貝配置文件:
    cp  php.ini-production  /usr/local/php/etc/php.ini

    b. 配置文件參考:

    [PHP]
    engine = On
    short_open_tag = Off
    precision = 14
    output_buffering = 4096
    zlib.output_compression = Off
    implicit_flush = Off
    unserialize_callback_func =
    serialize_precision = -1
    disable_functions =
    disable_classes =
    zend.enable_gc = On
    expose_php = On
    max_execution_time = 30
    max_input_time = 60
    memory_limit = 512M
    error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
    display_errors = on
    display_startup_errors = Off
    log_errors = On
    log_errors_max_len = 1024
    ignore_repeated_errors = Off
    ignore_repeated_source = Off
    report_memleaks = On
    html_errors = On
    variables_order = "GPCS"
    request_order = "GP"
    register_argc_argv = Off
    auto_globals_jit = On
    post_max_size = 8M
    auto_prepend_file =
    auto_append_file =
    default_mimetype = "text/html"
    default_charset = "UTF-8"
    doc_root =
    user_dir =
    enable_dl = Off
    file_uploads = On
    upload_max_filesize = 20M
    max_file_uploads = 20
    allow_url_fopen = On
    allow_url_include = Off
    default_socket_timeout = 99999999
    date.timezone = PRC
    [CLI Server]
    cli_server.color = On
    [Date]
    [filter]
    [iconv]
    [intl]
    [sqlite3]
    [Pcre]
    [Pdo]
    [Pdo_mysql]
    pdo_mysql.cache_size = 2000
    pdo_mysql.default_socket=
    [Phar]
    [mail function]
    SMTP = localhost
    smtp_port = 25
    mail.add_x_header = Off
    [ODBC]
    odbc.allow_persistent = On
    odbc.check_persistent = On
    odbc.max_persistent = -1
    odbc.max_links = -1
    odbc.defaultlrl = 4096
    odbc.defaultbinmode = 1
    [Interbase]
    ibase.allow_persistent = 1
    ibase.max_persistent = -1
    ibase.max_links = -1
    ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
    ibase.dateformat = "%Y-%m-%d"
    ibase.timeformat = "%H:%M:%S"
    [MySQLi]
    mysqli.max_persistent = -1
    mysqli.allow_persistent = On
    mysqli.max_links = -1
    mysqli.cache_size = 2000
    mysqli.default_port = 3306
    mysqli.default_socket =
    mysqli.default_host =
    mysqli.default_user =
    mysqli.default_pw =
    mysqli.reconnect = Off
    [mysqlnd]
    mysqlnd.collect_statistics = On
    mysqlnd.collect_memory_statistics = Off
    [OCI8]
    [PostgreSQL]
    pgsql.allow_persistent = On
    pgsql.auto_reset_persistent = Off
    pgsql.max_persistent = -1
    pgsql.max_links = -1
    pgsql.ignore_notice = 0
    pgsql.log_notice = 0
    [bcmath]
    bcmath.scale = 0
    [browscap]
    [Session]
    session.save_handler = files
    session.use_strict_mode = 0
    session.use_cookies = 1
    session.use_only_cookies = 1
    session.name = PHPSESSID
    session.auto_start = 0
    session.cookie_lifetime = 0
    session.cookie_path = /
    session.cookie_domain =
    session.cookie_httponly =
    session.serialize_handler = php
    session.gc_probability = 1
    session.gc_divisor = 1000
    session.gc_maxlifetime = 1440
    session.referer_check =
    session.cache_limiter = nocache
    session.cache_expire = 180
    session.use_trans_sid = 0
    session.sid_length = 26
    session.trans_sid_tags = "a=href,area=href,frame=src,form="
    session.sid_bits_per_character = 5
    [Assertion]
    zend.assertions = -1
    [COM]
    [mbstring]
    [gd]
    [exif]
    [Tidy]
    tidy.clean_output = Off
    [soap]
    soap.wsdl_cache_enabled=1
    soap.wsdl_cache_dir="/tmp"
    soap.wsdl_cache_ttl=86400
    soap.wsdl_cache_limit = 5
    [sysvshm]
    [ldap]
    ldap.max_links = -1
    [dba]
    [opcache]
    [curl]
    [openssl]

    c. 添加php-fpm到系統(tǒng)啟動目錄:

    cp  sapi/fpm/init.d.php-fpm  /etc/init.d/php-fpm
    chmod  +x  /etc/init.d/php-fpm
    systemctl  daemon-reload

    d. 創(chuàng)建配置文件:
    touch /usr/local/php/etc/php-fpm.conf

    [global]
    pid = /usr/local/php/var/run/php-fpm.pid
    error_log = /usr/local/php/var/log/php-fpm.log
    log_level = notice
    [nginx]
    listen = 127.0.0.1:9000
    listen.backlog = -1
    listen.allowed_clients = 127.0.0.1
    listen.owner = nginx
    listen.group = nginx
    listen.mode = 0666
    user = nginx
    group = nginx
    pm = dynamic
    pm.max_children = 20
    pm.start_servers = 10
    pm.min_spare_servers = 10
    pm.max_spare_servers = 20
    request_terminate_timeout = 100
    request_slowlog_timeout = 0
    slowlog = var/log/slow.log
  12. 啟動和停止:
    a. 啟動:
    systemctl  start  php-fpm

    b. 停止:

    systemctl  stop  php-fpm

    c. 重啟:

    systemctl  restart  php-fpm

    d. 開機(jī)啟動:

    chkconfig  php-fpm  on

    e. 添加環(huán)境變量:

    echo  'export  PATH=$PATH:/usr/local/php/bin/'  >>  /etc/profile
    .  /etc/profile

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

分享名稱:centos7源碼安裝lnmp(新)-創(chuàng)新互聯(lián)
標(biāo)題來源:http://muchs.cn/article46/deigeg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、App設(shè)計網(wǎng)站維護(hù)、動態(tài)網(wǎng)站、網(wǎng)站改版、網(wǎng)站設(shè)計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)