• Linux下安装PHP+Nginx+Msql


    安装Nginx:

    1.先指定个文件存放位置  usr/local/src

    2. 下载nginx,  wget http://nginx.org/download/nginx-1.12.0.tar.gz

    3.解压:tar zxf nginx......

    4.进入到nginx目录下,不清楚如何操作可以查看帮助(./configure --help)

      此时如果安装nginx会报未安装pcre,zlib类库,YUM找一下安装起来,

      yum search pcre

      yum install pcre pcre-devel 确认Y下载并安装

      yum install zlib zlib-devel

          指定安装目录:./configure --prefix=/usr/local/nginx

      编译:make && make install

    此时安装成功,接下来要启动nginx,先去nginx安装目录下

    (查看端口占用:netstar -tupln | grep 80)

    关掉防火强 service iptables stop

    cd /usr/local/nginx/sbin

    ./nginx

    最后去阿里云增加安全组规则8080 0.0.0.0/0 80 443选中

    不然打死也访问不了!

     ====================================================

    安装PHP:

    1.先安装PHP所需要的必备库
    yum install gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel

    或者:

    yum -y install libmcrypt-devel mhash-devel libxslt-devel

    libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel
    zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel
    ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel
    krb5 krb5-devel libidn libidn-devel openssl openssl-devel
    //此处为备用选项
    yum install -y gcc gdb strace gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs patch e2fsprogs-devel krb5-devel libidn libidn-devel openldap-devel nss_ldap openldap-clients openldap-servers libevent-devel libevent uuid-devel uuid mysql-devel pcre pcre-devel libxslt libxslt-devel openssl openssl-devel
    //此处为备用配置
    ./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-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --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-sysvshm --enable-xml --enable-zip --enable-ftp


    2.下载PHP:wget http://hk2.php.net/get/php-5.6.30.tar.gz/from/this/mirror
    3.解包:tar -zxf mirror
    4.进入/usr/local下新建立一个PHP文件夹(mkdir php),(提示:with-config-file-path是php.ini所在的目录位置)
    进入 cd /usr/local/src/php-5.6.30执行以下
    ./configure --prefix=/usr/local/php
    --with-config-file-path=/etc/php
    --with-gd
    --enable-gd-native-ttf
    --enable-gd-jis-conv
    --enable-mysqlnd
    --with-mysql=mysqlnd
    --with-pdo-mysql=mysqlnd
    --with-openssl
    --enable-mbstring
    --enable-fpm

    //这是一些常用的库
    yum -y install openssl
    yum -y install openssl-devel
    yum -y install curl
    yum -y install curl-devel
    yum -y install libjpeg
    yum -y install libjpeg-devel
    yum -y install libpng
    yum -y install libpng-devel
    yum -y install freetype
    yum -y install freetype-devel
    yum -y install pcre
    yum -y install pcre-devel
    yum -y install libxslt
    yum -y install libxslt-devel
    yum -y install bzip2
    yum -y install bzip2-devel
    
    //执行配置:
    ./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-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --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-sysvshm --enable-xml --enable-zip
    //如果有以下错误PHP 编译问题PEAR package PHP_Archive not installed的解决

    ./configure --without-pear --disable-phar
    make
    make install
    //编译完pear再安装
    wget  http://pear.php.net/go-pear.phar 
    /usr/local/bin/php go-pear.phar


    5.编译:make && make install
    6.进入 /usr/local/php/etc下复制ini文件作为FPM的进程配置,注意这和php.ini文件是不一样的.
    cp php-fpm.conf.defalut php-fpm.conf

     此时会多出php-fpm.conf这么个文件.


    7. 复制一份php.ini过来,所以去/usr/local/src/php-5.6-30下
    cp php.ini-development /usr/local/php/lib/php.ini
    这就是以后用到的php.ini文件
    8.启动PHP:进入/usr/local/php/sbin
    执行 ./php-fpm

     (ps aux | grep php查看进程)

    以下为卸载php:

    首先查看机器上安装的所有php相关的rpm包

    rpm -qa | grep php
    //这里会列出所有包的列表,要一个个的删除,删除顺序要自己找
    //接下来
    rpm -e php-cli-5.3.3-49.el6.x86_64
    //这是删除CLI的包,如此下去,直到删除完.

    =========================================

    整合php&nginx

    进入nginx 下的conf文件 修改成如下状态

    保存再重启动nginx

    ./sbin/nginx -s reload

      

    mysql下载地址:https://dev.mysql.com/downloads/mysql/5.6.html#downloads

    选择 5.6.38   选择linux-Generic   选择all

    下载这个:Linux - Generic (glibc 2.12) (x86, 64-bit), Compressed TAR Archive

    地址是:wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz

    1.# 安装依赖     yum -y install perl perl-devel autoconf libaio

            yum install numactl numactl-devel

    2.解压:tar zxvf mysql-5.6.38-linux-glibc2.12-x86_64.tar.gz

    3.复制 :cp mysql-5.6.38-linux-glibc2.12-x86_64 /usr/local/mysql -r

    4.增加用户组:groupadd mysql        useradd -r -g mysql -s /bin/false mysql

    5.安装 :./scripts/mysql_install_db --user=mysql

    6.修改当前目录拥有者为root用户  chown -R root:root ./

    7.修改当前data目录拥有者为mysql用户 chown -R mysql:mysql data

    8.、修改当前目录(usr/local/mysql)拥有者为root用户  chown -R root:root ./

    9、修改当前data目录拥有者为mysql用户  chown -R mysql:mysql data

    linux下,在mysql正常运行的情况下,输入mysql提示:
    mysql command not found

    遇上-bash: mysql: command not found的情况别着急,这个是因为/usr/local/bin目录下缺失mysql导致,只需要一下方法建立软链接,即可以解决:

    把mysql安装目录,比如MYSQLPATH/bin/mysql,映射到/usr/local/bin目录下: 
    # cd /usr/local/bin
    # ln -fs /MYSQLPATH/bin/mysql mysql

     ==========================

    修改密码

    mysql> use mysql;
    mysql> UPDATE user SET password=password("test123") WHERE user='root';   
    mysql> flush privileges;
    mysql> exit;            

    ========================

    提示登陆权限

     mysql>grant all on *.* to root@'%' identified by 'root'; 

    //php -m 无效时设置 /etc/profile环境变量

    另外当打印php_info时的扩展与php -m 查到的扩展不一致时,用下which php,会发现路径不一样,所以要去环境变量里增加

    方法三:修改/etc/profile文件使其永久性生效,并对所有系统用户生效,在文件末尾加上如下两行代码

    PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin
    export PATH

    最后:执行 命令source /etc/profile或 执行点命令 ./profile使其修改生效,执行完可通过echo $PATH命令查看是否添加成功。

  • 相关阅读:
    我的DBA之路:MYSQL数据类型
    我的DBA之路:MYSQL架构
    我的DBA之路:安装MySQL
    Java多线程系列之:显示锁
    Java多线程系列之:原子操作CAS
    Java多线程系列之:线程的并发工具类
    Java并发AQS原理分析(二)
    Java并发AQS原理分析(一)
    MySQL聚集索引和非聚集索引
    快速失败机制--fail-fast
  • 原文地址:https://www.cnblogs.com/bing2017/p/7101291.html
Copyright © 2020-2023  润新知