安装php

yum安装的版本只有5.1,所以手动安装

  1. 百度云下载 php-5.6.16.tar.gz:https://pan.baidu.com/s/1eSxfhXg
  2. tar -xzvf php-5.6.16.tar.gz
  3. 安装 libxml2 : yum install libxml2-devel
  4. 安装 bzip2: yum install bzip2 bzip2-devel
  5. 安装 curl: yum -y install curl-devel
  6. 安装 libpng :yum install libpng libpng-devel
  7. 安装 libmcrypt:yum install libmcrypt libmcrypt-devel
  8. 安装 readline: yum -y install readline readline-devel
  9. 执行下面的配置

    1
    ./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear --with-gd
  10. 复制php-fpm.conf

    1
    cp /opt/lib/php-5.6.28/sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf
  11. php-fpm 全局启动

    1
    cp /usr/local/php/sbin/php-fpm /usr/local/bin/php-fpm

12.启动 php-fpm
13.新建index.php

1
2
<?php
phpinfo();

14.成功

安装nginx

  1. yum 安装 yum -y install nginx
  2. 删除 /etc/nginx/conf.d下所有文件
  3. 配置自己的服务 vim mysite.conf

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    server {
    charset utf-8;
    client_max_body_size 128M;
    listen 80;
    server_name www.wexue.top;
    root /opt/server/gmfitness-wx;
    index index.php index.html;

    access_log /opt/log/access.log;
    error_log /opt/log/error.log;

    location / {
    # Redirect everything that isn't a real file to index.php
    try_files $uri $uri/ /index.php$is_args$args;
    }
    #转发
    location /wxnotify {
    proxy_pass http://XXXXX/index.php?g=Restful&m=Vip&a=wxnotify;
    }

    # uncomment to avoid processing of calls to non-existing static files by Yii
    #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    # try_files $uri =404;
    #}
    #error_page 404 /404.html;

    location ~ \.php$ {
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass 127.0.0.1:9000;
    #fastcgi_pass unix:/var/run/php5-fpm.sock;
    try_files $uri =404;
    }

    location ~ /\.(ht|svn|git) {
    deny all;
    }
    }
  4. 启动:yum自动安装了nginx的服务,service nginx start

安装mysql

  1. yum安装
    1
    2
    yum -y install mysql-server mysql mysql-devel
    service mysqld start
  1. 开机启动

    1
    2
    chkconfig mysqld on
    chkconfig --list | grep mysql
  2. 密码设置

    1
    mysqladmin -u root password '密码'
  3. 设置全网访问mysql -uroot -p

  • 输入:use mysql;
  • 查询host输入: select user,host from user;
  • 创建host(如果有”%”这个host值,则跳过这一步)
  • 如果没有”%”这个host值,就执行下面这两句:

    1
    2
    mysql> update user set host='%' where user='root';
    mysql> flush privileges;
  • 授权用户

    • 任意主机以用户root和密码pwd连接到mysql服务器
    • 指定IP为(如192.168.1.100)的主机以用户tuser和密码tpwd连接到mysql服务器
      1
      2
      3
      4
      5
      mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
      mysql> flush privileges;

      mysql> GRANT ALL PRIVILEGES ON *.* TO 'tuser'@'192.168.1.100' IDENTIFIED BY '密码' WITH GRANT OPTION;
      mysql> flush privileges;