阿里雲快速搭建php+nginx+mysql

安裝php

yum安裝的版本只有5.1,因此手動安裝php

  1. 百度雲下載 php-5.6.16.tar.gz: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. 執行下面的配置
    ./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
    cp /opt/lib/php-5.6.28/sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf
    複製代碼
  11. php-fpm 全局啓動
    cp /usr/local/php/sbin/php-fpm /usr/local/bin/php-fpm
    複製代碼

12.啓動php-fpmcss

13.新建index.phphtml

<?php
   phpinfo();
複製代碼

14.成功mysql

安裝nginx

  1. yum 安裝 yum -y install nginxnginx

  2. 刪除 /etc/nginx/conf.d下全部文件git

  3. 配置本身的服務 vim mysite.confsql

    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 startshell

安裝mysql

  1. yum安裝
    yum -y install mysql-server mysql mysql-devel
     service mysqld start
    複製代碼
  2. 開機啓動
    chkconfig mysqld on
    chkconfig --list | grep mysql
    複製代碼
  3. 密碼設置
    mysqladmin -u root password '密碼'
    複製代碼
  4. 設置全網訪問mysql -uroot -p
    • 輸入:use mysql;
    • 查詢host輸入: select user,host from user;
    • 建立host(若是有"%"這個host值,則跳過這一步)
    • 若是沒有"%"這個host值,就執行下面這兩句:
      mysql> update user set host='%' where user='root';
      mysql> flush privileges;
      複製代碼
    • 受權用戶
      • 任意主機以用戶root和密碼pwd鏈接到mysql服務器
      • 指定IP爲(如192.168.1.100)的主機以用戶tuser和密碼tpwd鏈接到mysql服務器
      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;
      複製代碼
相關文章
相關標籤/搜索