zoukankan      html  css  js  c++  java
  • 编译安装centos7 php7.2 mysql5.7 nginx1.9.9

    2018年3月12日 14:09:39

    注意时效

    centos7
    
    网卡
    
    cd /etc/sysconfig/network-scripts/
    
    TYPE=Ethernet
    PROXY_METHOD=none
    BROWSER_ONLY=no
    BOOTPROTO=static
    DEFROUTE=yes
    IPV4_FAILURE_FATAL=no
    IPV6INIT=yes
    IPV6_AUTOCONF=yes
    IPV6_DEFROUTE=yes
    IPV6_FAILURE_FATAL=no
    IPV6_ADDR_GEN_MODE=stable-privacy
    NAME=ens160
    UUID=90a09195-c24e-401d-bf4e-8c846539b130
    DEVICE=ens160
    ONBOOT=yes
    IPADDR=172.17.1.253
    GATEWAY=172.17.1.1
    NETMASK=255.255.255.255
    DNS1=8.8.8.8
    DNS2-172.17.1.1
    
    关闭firewall
    systemctl stop firewalld.service #停止firewall
    systemctl disable firewalld.service #禁止firewall开机启动
    
    
    yum install -y apr* autoconf automake bison bzip2 bzip2* cloog-ppl compat* cpp curl curl-devel fontconfig fontconfig-devel freetype freetype* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 libxml2-devel libXpm* libxml* libtiff libtiff* make mpfr ncurses* ntp openssl openssl-devel patch pcre-devel perl php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* wget zlib-devel
    
    yum -y groupinstall "Development Tools"
    
    yum install -y gcc gcc-c++ make cmake automake autoconf gd file bison patch mlocate flex 
    diffutils zlib zlib-devel pcre pcre-devel 
    libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel 
    glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel 
    ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel 
    krb5 krb5-devel openssl openssl-devel 
    openldap openldap-devel nss_ldap openldap-clients openldap-servers 
    openldap-devellibxslt-devel kernel-devel libtool-libs 
    readline-devel gettext-devel libcap-devel php-mcrypt libmcrypt libmcrypt-devel recode-devel
    
    yum install -y libxml2 libxml2* openssl-dev libcurl3-openssl-dev openssl-devel.i686 
    openssl-perl.i686 libcurl-devel.i686 libjpeg-turbo-devel.i686 libpng.i686 libpng-devel.i686l freetype-devel php-gd
    
    
    yum -y install cmake ncurses ncurses-devel bison bison-devel boost boost-devel
    
    安装MySQL
    
    groupadd mysql #添加mysql组
    
    useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统
    
    mkdir -p /data/mysql #创建MySQL数据库存放目录
    
    chown -R mysql:mysql /data/mysql #设置MySQL数据库存放目录权限
    
    mkdir -p /usr/local/mysql #创建MySQL安装目录
    
    
    mkdir -p /usr/local/boost
    
    cd /usr/local/boost
    wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
    
    tar -xvzf boost_1_59_0.tar.gz
    
    编译
    
    cmake 
    -DCMAKE_INSTALL_PREFIX=/usr/local/mysql 
    -DMYSQL_DATADIR=/usr/local/mysql/data 
    -DSYSCONFDIR=/etc 
    -DWITH_MYISAM_STORAGE_ENGINE=1 
    -DWITH_INNOBASE_STORAGE_ENGINE=1 
    -DWITH_MEMORY_STORAGE_ENGINE=1 
    -DWITH_READLINE=1 
    -DMYSQL_UNIX_ADDR=/tmp/mysql.sock 
    -DMYSQL_TCP_PORT=3306 
    -DENABLED_LOCAL_INFILE=1 
    -DWITH_PARTITION_STORAGE_ENGINE=1 
    -DEXTRA_CHARSETS=all 
    -DDEFAULT_CHARSET=utf8 
    -DDEFAULT_COLLATION=utf8_general_ci 
    -DMYSQL_USER=mysql 
    -DWITH_DEBUG=0 
    -DWITH_SSL=system 
    -DWITH_BOOST=/usr/local/boost
    
    
    pid =/www/lanmps/php5.6.31/var/run/php-fpm.pid
    error_log = /www/lanmps/php5.6.31/var/log/php-fpm.log
    log_level = notice
    
    [www]
    listen = /tmp/php-cgi.sock
    listen.backlog = -1
    listen.allowed_clients = 127.0.0.1
    listen.owner = www
    listen.group = www
    listen.mode = 0666
    user = www
    group = www
    pm = dynamic
    pm.max_children = 80
    pm.start_servers = 40
    pm.min_spare_servers = 40
    pm.max_spare_servers = 80
    request_terminate_timeout = 100
    request_slowlog_timeout = 0
    slowlog = var/log/slow.log
    
    
    #修改/usr/local/mysql权限
    chmod +w /usr/local/mysql  
    chown -R mysql:mysql /usr/local/mysql
    
    mv /etc/my.cnf /etc/my.cnf.bak  
    cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
    
    #拷贝mysql安装目录下support-files服务脚本到init.d目录
    cp support-files/mysql.server /etc/rc.d/init.d/mysqld
    #赋予权限
    chmod +x /etc/rc.d/init.d/mysqld
    #设置开机启动
    chkconfig mysqld on
    
    #执行初始化配置脚本,创建系统自带的数据库和表,注意配置文件的路径
    
    ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
    
    确保/usr/local/mysql/data为空
    ./bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
    
    vi /etc/my.cnf
    
    [mysqld]
    basedir=/usr/local/mysql
    datadir=/usr/local/mysql/data
    socket=/tmp/mysql.sock
    
    symbolic-links=0
    
    [mysqld_safe]
    ;log-error=/var/log/mariadb/mariadb.log
    pid-file=/usr/local/mysql/data/localhost.localdomain.pid
    
    #修改/etc/profile文件
    vi /etc/profile
    #在文件末尾添加
    PATH=/usr/local/mysql/bin:$PATH
    export PATH
    #让配置立即生效
     
    source /etc/profile
    
    /usr/local/mysql/bin/mysqladmin -uroot -p password 'root';
    
    /usr/local/mysql/bin/mysqladmin -uroot -p password 'root';
    
    flush privileges;
    
    重新授权用户
    
    mysqld --skip-grant-tables 回车
    
    --skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证
    
    GRANT ALL PRIVILEGES ON *.* TO 'zx'@'%'IDENTIFIED BY 'zx' WITH GRANT OPTION;
    
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;
    
    nginx安装
    yum -y install yasm libmcrypt libvpx tiff libpng freetype jpeg libgd t1lib
    
    
    ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module
    
    
    vi /etc/init.d/nginx
    
    chmod +x /etc/init.d/nginx
    
    chkconfig nginx on
    
    ./configure 
    --prefix=/usr/local/nginx 
    --sbin-path=/usr/sbin/nginx 
    --conf-path=/etc/nginx/nginx.conf 
    --error-log-path=/var/log/nginx/error.log 
    --http-log-path=/var/log/nginx/access.log 
    --pid-path=/var/run/nginx.pid 
    --lock-path=/var/run/nginx.lock 
    --http-client-body-temp-path=/var/cache/nginx/client_temp 
    --http-proxy-temp-path=/var/cache/nginx/proxy_temp 
    --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp 
    --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp 
    --http-scgi-temp-path=/var/cache/nginx/scgi_temp 
    --user=www 
    --group=www 
    --with-pcre 
    --with-http_v2_module 
    --with-http_ssl_module 
    --with-http_realip_module 
    --with-http_addition_module 
    --with-http_sub_module 
    --with-http_dav_module 
    --with-http_flv_module 
    --with-http_mp4_module 
    --with-http_gunzip_module 
    --with-http_gzip_static_module 
    --with-http_random_index_module 
    --with-http_secure_link_module 
    --with-http_stub_status_module 
    --with-http_auth_request_module 
    --with-mail 
    --with-mail_ssl_module 
    --with-file-aio 
    --with-ipv6 
    --with-http_v2_module 
    --with-threads 
    --with-stream 
    --with-stream_ssl_module
    
    
    yum -y install libicu-devel
    
    
    make[2]: *** [progname.o] 错误 1
    make[2]:正在离开目录 `/home/lmos/libiconv-1.14/srclib'
    make[1]: *** [all] 错误 2
    make[1]:正在离开目录 `/home/lmos/libiconv-1.14/srclib'
    make: *** [all] 错误 2
    
    进入srclib目录 执行 sed -i -e '/gets is a security/d' ./stdio.in.h
    
    
    Cannot find ldap.h
    复制代码 代码如下:
    yum -y install openldap
    yum -y install openldap-devel
    
    configure: error: Cannot find ldap libraries in /usr/lib
    复制代码 代码如下:
    cp -frp /usr/lib64/libldap* /usr/lib/
    
    http://www.bkjia.com/PHPjc/1008013.html 参考bug解决办法
    
    
    yum install -y epel-release
    yum install -y libmcrypt-devel
    
    export LD_LIBRARY_PATH=/usr/local/lib: LD_LIBRARY_PATH
    
    
    
    ./configure --prefix=/usr/local/php 
    --with-config-file-path=/usr/local/php/etc 
    --with-mysql-sock=/tmp/mysql.sock 
    --enable-fpm 
    --with-fpm-user=www 
    --with-fpm-group=www 
    --enable-mysqlnd 
    --with-mysqli=mysqlnd 
    --with-pdo-mysql=mysqlnd 
    --enable-mysqlnd-compression-support 
    --with-iconv-dir 
    --with-freetype-dir 
    --with-jpeg-dir 
    --with-png-dir 
    --with-zlib 
    --with-libxml-dir 
    --enable-xml 
    --disable-rpath 
    --enable-bcmath 
    --enable-shmop 
    --enable-sysvsem 
    --enable-inline-optimization 
    --with-curl 
    --enable-mbregex 
    --enable-mbstring 
    --enable-intl 
    --with-mcrypt 
    --with-libmbfl 
    --enable-ftp 
    --with-gd 
    --enable-gd-jis-conv 
    --enable-gd-native-ttf 
    --with-openssl 
    --with-mhash 
    --enable-pcntl 
    --enable-sockets 
    --with-xmlrpc 
    --enable-zip 
    --enable-soap 
    --with-gettext 
    --enable-fileinfo 
    --enable-opcache 
    --with-pear 
    --enable-maintainer-zts 
    --with-ldap=shared 
    --without-gdbm
    
    
    nodejs
    curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -       8是版本系列
    yum install -y nodejs
    
    npm install -g cnpm --registry=https://registry.npm.taobao.org
    注意fpm版本也就是php版本
    nginx使用sock形式调用php-fpm


    vi /etc/php-fpm.d/www.conf
    listen = /tmp/php-fpm.sock 建议放在这个目录,不容易有权限问题,也要主要有没有定期清理tmp的脚本或者代码
    vi /etc/nginx/conf.d/default.conf

    fastcgi_pass   unix:/tmp/php-fpm.sock;

    注意可不是就这么就完了
    还有需要配置的

    listen.owner = www
    listen.group = www
    listen.mode = 0660

    listen.allowed_clients = 127.0.0.1

    listen = /tmp/php-fpm.sock


    listen.backlog = -1

     nginx 做服务的脚本是有问题的请参看

    http://bbs.qcloud.com/thread-10429-1-1.html



    vim /usr/lib/systemd/system/nginx.service

    [Unit]
    Description=nginx - high performance web server
    Documentation=http://nginx.org/en/docs/
    After=network.target remote-fs.target nss-lookup.target

    [Service]
    Type=forking
    PIDFile=/var/run/nginx.pid
    ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf
    ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s QUIT $MAINPID
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target

     

    其实版本差距不大,就是centos的系统操作有写区别,其他没什么

  • 相关阅读:
    JavaScript模态对话框类
    事件模块的演变(1)
    html5中可通过document.head获取head元素
    How to search for just a specific file type in Visual Studio code?
    What do 'lazy' and 'greedy' mean in the context of regular expressions?
    正则非获取匹配 Lookahead and Lookbehind ZeroLength Assertions
    regex length 正则长度问题
    Inversion of Control vs Dependency Injection
    How to return View with QueryString in ASP.NET MVC 2?
    今天才发现Google Reader
  • 原文地址:https://www.cnblogs.com/zx-admin/p/8572743.html
Copyright © 2011-2022 走看看