首頁  >  文章  >  php教程  >  CentOS 7.2mini版本下編譯安裝php7.0.10+MySQL5.7.14+Nginx1.10.1

CentOS 7.2mini版本下編譯安裝php7.0.10+MySQL5.7.14+Nginx1.10.1

WBOY
WBOY原創
2016-09-02 08:42:561920瀏覽

一、安裝前的準備工作

1、yum update    #更新系統

2、yum install gcc gcc-c++ autoconf automake cmake bison m4 libxml2 libxml2-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel phpo集 3、下載以下套件   #我把所有來源檔案下載在root目錄,讀者可自行修改原始檔案存放目錄

     3.1 libmcrypt-2.5.8.tar.gz

     3.2 mcrypt-2.6.8.tar.gz

     3.3 mhash-0.9.9.9.tar.gz

     3.4 zlib-1.2.8.tar.gz

 解壓並安裝如:

#tar -zvxf  libmcrypt-2.5.8.tar.gz

#cd libmcrypt-2.5.8

#./configure

#make && make insatll

4、在安裝軟體時如果提示有什麼依賴套件沒有安裝的可以再執行yum install * -y (*表示相關套件)

 

 

二、編譯安裝Nginx

1、去官網http://nginx.org/en/download.html下載最nginx-1.10.1.tar.gz的穩定版

2、編譯步驟如下

    

  1、透過winSCP上傳nginx-1.10.1.tar.gz到/root目錄下

    1.1 groupadd -r nginx         新建  .1 groupadd -r nginx         新建   

    1.2 useradd -r -g nginx -s /bin/false nginx    #新無登入權限的nginx用戶
    1.3 id nginx                            
  2、tar -zvxf nginx-1.10.1.tar.gz

  3、cd nginx-1.10.1

  4、可透過./configure --help查看編譯組態參數,也可參考http://nginx.org/en/docs/configure.html,下列參數要寫在一行

    ./configure

 㟎    =/usr/local/nginx

    --modules-path=/usr/local/nginx/modules
    --with-http_ssl_Lule
    --with-http_ssl_Lmule🀎   --user= nginx
    --group=nginx

  5、make && make install   #編譯並安裝

  6、啟動nginx

    6.1 cd /usr/local/nginx

    6.2 sbin/nginx       6.2 sbin/nginx        

  7、在/usr/lib/systemd/system目錄下新建nginx.service文件,這樣就可以透過systemctl stop|start|reload nginx.service來操作nginx,也可參考https://www.nginx.com/ resources/wiki/start/topics/examples/systemd/,內容如下:

    [Unit]
     Description=The NGINX HTTP and reverse proxy server🎎

    [Service]

    Type=forking
    PIDFile=/usr/local/nginx/nginx.pid🀎    ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s stop

     Hmp=truetrue

    [Install]
    WantedBy=multi-user.target

 


 

三、編譯安裝MySQL


1、去官網http://dev.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.14.tar.gz下載帶boost的5.7.14版本

2、編譯步驟如下


  

  1、用winSCP上傳mysql-boost-5.7.14.tar.gz到/root目錄下

  2、groupadd mysql

  3、useradd -r -g mysql -s /bin/false mysql

  4、用cmake編譯mysql, 相關參數可以參考https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html,下列參數要寫在一行

    cmake

    -DCMAKE_INSTALL_PREFIX= /usr/local/mysql

    -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock

    -DSYSCONFDIR=/usr/local/mysql/etc

    -DSYSTEMD_PID_DIR=/usr/local/mysql

    -DDEFAULT_CHARSET=utf8

    -DDEFAULT_COLLATION =utf8_general_ci

    -DWITH_INNOBASE_STORAGE_ENGINE=1

    -DWITH_ARCHIVE_STORAGE_ENGINE=1    四  -DWITH_PERFSCHEMA_STORAGE_ENGINE=1
    -DMYSQL_DATADIR=/usr/local/mysql/data
    -D
  5、make && make install

  6、配置mysql並初始化資料庫
    6.1 cd /usr/local/mysql     #進入編譯目錄
    6.2 chown -R my 修改所有者修改 3. chgrp -R mysql .        #修改目錄組
    6.4 cp /usr/ local/mysql/support-files/mysql.server /etc/init.d/mysqld               #設定mysqld服務
    6.5 cp /usr/local/my/Lm/loft5/idefus .cnf     #配置my.cnf
      6.5.1 複製下列內容到my.cnf文件中的[mysqld]下
   公     basedir = /usr/local/mysql
           datadir = /usr/local/mysql/data
port = 3306
           server_id = /usr/local/mysql/mysqld.pid
    my  『   6.5 chkconfig mysqld on     #設定mysqld開機自動啟動
    6.6 bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data      #初始化資料庫
    6.7 bin/mysqld --user=mygread Security" section of the manual to find out how to run mysqld as root!,就在my.cnf中加入user=root, 表示以root用戶啟動

  7、修改root使用者登入密碼並允許root使用者遠端登入
    7.1 mysql -u root --skip-password

    7.2 ALTERhost 'word

    7.2 ALTERhost 'word
    7.2 ALTERhost 'word
    7.2 ALTERhost 'word 7.3 允許root使用者遠端登入
7.3.1 use mysql;
    7.3.2 update user set host='%' where user='root' and host='localhost';      #up ='root'; #禁用)
    7.3.3 flush privileges;
    7.3.4 service mysqld restart

  8、解決service mysqld start|stop報MySQL server PID file could not be found!或Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe), 其實可透過閱讀此文件解決相關錯誤

8.1 chmod 777 /usr/local/mysql         #因我設定mysqld.pid檔案保存在/usr/local/mysql目錄,所以保證其有可寫入權限
    my8.2 透過修改檔案〔5〦/sql. .1 basedir=/usr/local/mysql       #手動指定
    8.2.2 datadir=/usr/local/mysql/data     #手動指定
  /大 .pid     #手動指定
8.2.4 把此文件中所有未註解的含有mysqld_safe的字元替換成mysqld

 

 


四、編譯安裝php

1、去官網http://php.net/downloads.php下載php7.0.10版

2、編譯步驟如下

  1、用winSCP上傳php-7.0.10.tar.gz到/root目錄下

  2、tar -zvxf php-7.0.10.tar.gz    #解壓縮

  3、設定編譯php參數, 可使用./configure --help指令查看所有編譯設定項目, 下列參數要寫在一行中

    ./configure

    --prefix= prefix=/usr/local/php

    --datadir=/usr/local/php
    --with-config-file-path=/usr/local/php/etcmy --with-config-path=/usr/local/php/etcmy〜   〦 my〜 my〜〜 、〜 5〜 5〜 5〜 〦〦〦〦〦 ) -pdo-mysql=mysqlnd
    --with-fpm-user=nginx
    --with-fpm-group=nginx
    --with-gd
    --with-iconv
    --enable-mbstring
    --enable-fpm
    --enable-mysqlnd

  4、make && make install    #編譯並安裝

  5、cd /usr/local/php    #進入編譯目錄

  6、修改相關設定檔

    6.1 cp /usr/local/php/etc/php.ini.default /usr/local/php/etc/php.ini      #php. nginx支援php參考http://php.net/manual/zh/install.unix.nginx.php

    6.2 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc /php-fpm.conf     #去掉[global]項目下pid前的;

    6.3 cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/et/php -fpm.d/www.conf     #大致在23、24行修改user和group如:user = nginx,group = nginx

  7、chmod 777 /usr/local/php/var/run     #預設PID檔案是寫在/usr/local/php/var/run這個目錄中,所以修改目錄權限

  8、sbin/php-fpm     #啟動php, 可透過sbin/php-fpm -h 查看相關操作指令清單

  9、在/usr/lib/systemd/system目錄下新建php-fpm.service文件,這樣就可以透過systemctl stop|start|reload php-fpm.service來操作php-fpm,內容如下:
    [Unit]
    Description=The PHP FastCGI Process Manager
    After=syslog.target network.target
    Before=nginx.servicetarget

    Before=nginx.servicetarget

    Before=nginx.servicetarget
    Before=nginx.servicetarget
    Before=nginx.servicetarget
    Before=nginx.servicetarget
    Before=nginx.servicetarget
 〜
    [Service]

    Type=forking

    PIDFile=/usr/local/php/var/run/php-fpm.pdid〔》》》〜/php。/長   ExecStop=/bin/kill - QUIT `cat /usr/local/php/var/run/php-fpm.pid`
    ExecReload=/bin/kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`

Privid`. =true

    [Install]
    WantedBy=multi-user.target

 

 

五、安裝redis及phpredis擴充

1、用winSCP上傳redis-3.0.0.tar.gz到/root目錄下

2、tar -zvxf redis-3.0.0.tar.gz -C /usr/local     #解壓縮到/usr/local目錄下

3、yum install tcl -y     #redis-test依賴此套件

4、cd /usr/local/redis-3.0.0

5、chmod 777 .    #目前目錄可寫,我把redis.pid檔指定到了/usr/local/redis-3.0.0下

6、make && make install

7、vi /usr/local/redis-3.0.0/redis.conf     #修改redis設定檔
  7.1 daemonize yes
  7.2 pidfile /usr/local/red/red   7.2 pidfile /usr/local/redis/redo/wred 是) #啟動redis

   src/redis-cli shutdown #關閉redis

   src/redis-server --help #查看相關幫助指令

9、在/usr/lib/systemd/system目錄下新建redis.service文件,這樣就可以透過systemctl stop|start redis.service來操作redis,內容如下:
  [Unit]

  Description=The Redis 3.0.0t]

  Description=The Redis 3.0.0t]
  Description=The Redis 3.0.0t] Service
  After=syslog.target

  [Service]
  Type=forking
  PIDFile=/usr/local/redis/redis.pid

  ExecStartPre=usr/local/redisservers/redcal/reddis/wecStartPre=usr/local/redisservers/redcalc/wredw/Fyred/wredun/local/redisserver/local/redc/Fyred. =/ usr/local/redis/src/redis-server /usr/local/redis/redis.conf

  ExecStop=/usr/local/redis/src/redis-cli shutdown
  PrivateTmp=true

  [Install]
  WantedBy=multi-user.target

10、安裝phpredis擴充
  10.1 用winSCP上傳phpredis-3.0.0.tar.gz到/root目錄下
  10.2 tar -zvxf phpredis-3.0.0.targz -CvCxf phpredis-3.0.0。 /local目錄下
  10.3 cd /usr/local/phpredis-3.0.0
  10.4 /usr/local/php/bin/phpize
  10.5 php /php-config
  10.6 make && make install

  10.7 在php.ini檔案中加入extension=redis.so

  10.8 啟動新啟動

 

 

 

六、至此在我的VirturBox中CentOS7.2下成功搭建了LNMP環境

 
🎜
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn