• linux(centos7) nginx php mysql安装


    环境:

    linux:centos7

    php:7.0

    基础命令

    // yum install -y lrzsz // centos7 默认已安装
    yum install epel-release

    nginx安装

     1.依赖包

    yum install gcc
    yum install pcre-devel
    yum install zlib zlib-devel
    yum install openssl openssl-devel
    
    //或者一键安装上面四个依赖
    yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

    2.下载http://nginx.org/

    3.配置、编译与安装

    ./configure 
    --prefix=/usr/local/nginx 
    --sbin-path=/usr/local/nginx/sbin/nginx 
    --conf-path=/usr/local/nginx/conf/nginx.conf 
    --with-http_stub_status_module 
    --with-http_ssl_module 
    --with-pcre 
    --lock-path=/var/run/nginx.lock 
    --pid-path=/var/run/nginx.pid
    
    make && make install

    4.关闭防火墙

      // 命令都可以

      service firewalld stop;
      systemctl stop firewalld.service;

    // centos从7开始默认用的是firewalld,这个是基于iptables的,虽然有iptables的核心,但是iptables的服务是没安装的。所以你只要停止firewalld服务即可:
    sudo systemctl stop firewalld.service && sudo systemctl disable firewalld.service

    如果你要改用iptables的话,需要安装iptables服务:
    sudo yum install iptables-services
    sudo systemctl enable iptables && sudo systemctl enable ip6tables
    sudo systemctl start iptables && sudo systemctl start ip6tables

    php安装

    1.下载http://www.php.net/downloads.php, 

    2.安装依赖

    yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel curl

    注意:安装php7beta3的时候有几处配置只是去,须要yum一下。如今php-7.0.2已经不用这样了。
    # yum -y install curl-devel
    # yum -y install libxslt-devel

    3.配置、编译与安装

    ./configure --prefix=/usr/local/php 
     --with-curl 
     --with-freetype-dir 
     --with-gd 
     --with-gettext 
     --with-iconv-dir 
     --with-kerberos 
     --with-libdir=lib64 
     --with-libxml-dir 
     --with-mysqli 
     --with-openssl 
     --with-pcre-regex 
     --with-pdo-mysql 
     --with-pdo-sqlite 
     --with-pear 
     --with-png-dir 
     --with-xmlrpc 
     --with-xsl 
     --with-zlib 
     --enable-fpm 
     --enable-bcmath 
     --enable-libxml 
     --enable-inline-optimization 
     --enable-gd-native-ttf 
     --enable-mbregex 
     --enable-mbstring 
     --enable-opcache 
     --enable-pcntl 
     --enable-shmop 
     --enable-soap 
     --enable-sockets 
     --enable-sysvsem 
     --enable-xml 
     --enable-zip

    make && make install
    ./configure --prefix=/usr/local/php 
     --with-curl 
     --with-freetype-dir 
     --with-gd 
     --with-gettext 
     --with-iconv-dir 
     --with-kerberos 
     --with-libdir=lib64 
     --with-libxml-dir 
     --with-mysqli 
     --with-openssl 
     --with-pcre-regex 
     --with-pdo-mysql 
     --with-pdo-sqlite 
     --without-pear  --disable-phar 
     --with-png-dir 
     --with-xmlrpc 
     --with-xsl 
     --with-zlib 
     --enable-fpm 
     --enable-bcmath 
     --enable-libxml 
     --enable-inline-optimization 
     --enable-gd-native-ttf 
     --enable-mbregex 
     --enable-mbstring 
     --enable-opcache 
     --enable-pcntl 
     --enable-shmop 
     --enable-soap 
     --enable-sockets 
     --enable-sysvsem 
     --enable-xml 
     --enable-zip
    
    make && make install

    如果报错curl,则需要安装

    cd /down
    wget  http://curl.haxx.se/download/curl-7.38.0.tar.gz
    tar -xzvf curl-7.38.0.tar.gz
    cd tar -xzvf curl-7.38.0.tar.gz
    ./configure --prefix=/usr/local/curl
    make && make install

    // yum安装
    yum install curl

    配置文件

    # cp php.ini-development /usr/local/php/lib/php.ini
    # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    # cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
    # cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm
     
    须要注意的是php7中www.conf这个配置文件配置phpfpm的端口号等信息,假设你改动默认的9000端口号需在这里改,再改nginx的配置
    启动
    #  /etc/init.d/php-fpm
     
    配置nginx.conf
    #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_params;
      #}
    location ~ .php$ {        改为
       root   html;
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include  fastcgi_params;
      }

    建立index.php 内容为

    <?php
    phpinfo()
    ?>

    最后重启

    service nginx restart    或者./nginx -s reload  重启nginx      

    service php-fpm restart 或者 /etc/init.d/php-fpm  重启 php-fpm

    mysql安装

    其它知识

    firewalld使用

    启动: systemctl start firewalld
    关闭: systemctl stop firewalld
    查看状态: systemctl status firewalld 
    开机禁用  : systemctl disable firewalld
    开机启用  : systemctl enable firewalld
  • 相关阅读:
    虚拟机安装Mac OS X ----- VM12安装Mac OS X
    windows7 64位安装mysql 5.7.11 zip压缩版
    sublime text 3 + python配置,完整搭建及常用插件安装
    Windows下虚拟机安装Mac OS X ----- VM12安装Mac OS X 10.11
    myeclipse 2014新建maven web 项目步骤
    解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.
    static{}语句块详解
    http状态码代表含义
    Android权限列表permission说明
    【MySQL】10条SQL优化语句,让你的MySQL数据库跑得更快!
  • 原文地址:https://www.cnblogs.com/wesky/p/9436447.html
Copyright © 2020-2023  润新知