Centos7.0以上安裝nginx+php7.0+mysql5.7+redis3作為開發php環境

來源:互聯網
上載者:User

標籤:centos7安裝lnmp


CentOS 7 biuld 1611迷你安裝@VMware

Redis 3.2.8


安裝步驟:


#安裝gcc

yum -y install gcc

#下載redis

curl -O  http://download.redis.io/releases/redis-3.2.8.tar.gz

#解壓

tar -zxvf redis-3.2.8.tar.gz

#轉換目錄

cd redis-3.2.8/deps/

#編譯依賴

make geohash-int hiredis jemalloc linenoise lua

#轉換目錄

cd ..

#編譯Redis

make && make install

#轉換目錄

cd utils/

#使用指令碼安裝服務

./install_server.sh

#啟動服務

systemctl start redis_6379

systemctl status redis_6379

#好了,就這些,嘗試一下吧。


簡單提示:


    目前的版本中需要編譯的依賴有五項,更早或未來的版本可能會有不同。如果您沒有編譯這些項目,編譯Redis會遇到錯誤。


    fatal error: jemalloc/jemalloc.h: No such file or directory

    cc: error: ../deps/hiredis/libhiredis.a: No such file or directory

    cc: error: ../deps/lua/src/liblua.a: No such file or directory

    cc: error: ../deps/geohash-int/geohash.o: No such file or directory

    cc: error: ../deps/linenoise/linenoise.o: No such file or directory


    在使用指令碼安裝服務的過程中,您可以一路【Enter】完成安裝。之後您可以再次運行指令檔,並通過輸入不同的連接埠號碼建立多個Redis服務。




1.先修改yum源  https://webtatic.com


  rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

  rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

  rpm -Uvh  http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm


2.安裝nginx


  yum install nginx


3.安裝mysql5.7


  yum -y install mysql-community-server


4.安裝php


 yum install php70w-devel php70w.x86_64 php70w-pecl-redis  php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64  php70w-pdo.x86_64   php70w-mysqlnd  php70w-fpm php70w-opcache


5.開始簡單的配置


  mysql 配置


  vim /etc/my.cnf


在[client] 下面添加

  default-character-set=utf8


在 [mysqld] 下面添加


  character_set_server=utf8

  init_connect=‘SET NAMES utf8‘


  collation-server=utf8_general_ci


儲存退出


擷取初始密碼


 grep ‘temporary password‘ /var/log/mysqld.log




注意 裡麵包括開頭的 ;號


然後登陸mysql 修改密碼


  alter user [email protected] identified by ‘zhonghui!8‘


如果密碼太過於簡單可能不然修改因為mysql預設設定了密碼複雜度 至少8位 必須包含 大小寫字母數字及符號


查看密碼原則:


  show variables like ‘%password%‘;


說明:


validate_password_dictionary_file:密碼原則檔案,策略為STRONG才需要 


validate_password_length:密碼最少長度 


validate_password_mixed_case_count:大小寫字元長度,至少1個 


validate_password_number_count :數字至少1個 


validate_password_special_char_count:特殊字元至少1個 上述參數是預設策略MEDIUM的密碼檢查規則。


validate_password_policy:密碼原則,預設為MEDIUM策略 ,共有如下三種密碼原則:


0 or LOW                 Length


1 or MEDIUM           Length; numeric, lowercase/uppercase, and special characters


2 or STRONG          Length; numeric, lowercase/uppercase, and special characters; dictionary file


可以通過 set  GLOBAL validate_password_policy=0 來修改


或者修改/etc/my.cnf檔案


validate_password_policy=0 #0(LOW),1(MEDIUM),2(STRONG)其中一種,注意2需要提供密碼字典檔案


 如果不要求輸入密碼策略,添加my.cnf檔案中添加如下配置禁用即可:


  validate_password = off  


添加一個可以在外部登陸的mysql使用者


  grant all privileges on *.* to 建立的使用者名稱 @"%" identified by "密碼";

  flush privileges;  


 


注意修改設定檔後需要重啟mysql


配置nginx:


nginx可以的預設設定檔一般在:


  /etc/nginx/nginx.conf


使用 cat 查看一下設定檔 

這行表示nginx會引用  conf.d 這個檔案夾下面所有.conf尾碼的檔案


那麼在conf.d下面我們來建立我們自己的設定檔


  vim /etc/nginx/conf.d/user.conf


然後寫入

    server {

    listen      80;

    server_name 192.168.88.3或者www.abc.com;

    root        /source/hld/bp.hldcanyin.com/public(項目目錄絕對路徑);

    index       index.php index.html index.htm;

    charset     utf-8;


    access_log /var/log/nginx/bp.hldcanyin.com.access.log main;

    error_log  /var/log/nginx/bp.hldcanyin.com.error.log debug;


    location / {

        #try_files $uri $uri/ /index.php?_url=$uri&$args;

        try_files $uri $uri/ /index.php?$query_string;

    }


    location ~ \.php {

        # try_files   $uri =404;


        fastcgi_pass  127.0.0.1:9000;

        fastcgi_index /index.php;


        include fastcgi_params;

        fastcgi_split_path_info       ^(.+\.php)(/.+)$;

        fastcgi_param PATH_INFO       $fastcgi_path_info;

        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }


    location ~ /\.ht {

        deny all;

    }

}


這樣 簡單的lnmp就安裝好了 


systemctl restart php-fpm   #啟動php

systemctl restart nginx #啟動nginx

systemctl restart  mysqld #啟動mysql


nginx常見問題:使用nginx -s reload時

nginx報錯 [error] open() “/usr/local/var/run/openresty.pid” failed (2: No such file or directory)


    解決: 服務沒有啟動 使用start啟動服務,因為沒有start而直接使用stop或者reload報錯這個問題;

    如果方法一沒有解決,使用方法二:-C 指定設定檔nginx.conf或者weblua.conf




本文出自 “11822904” 部落格,請務必保留此出處http://11832904.blog.51cto.com/11822904/1947557

Centos7.0以上安裝nginx+php7.0+mysql5.7+redis3作為開發php環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.