nginx+php7+mysql 在centos7.3下安裝

來源:互聯網
上載者:User

標籤:lease   product   unit   centos7   line   conf   top   error   sap   

1、Nginx   yum安裝

  1)添加Nginx到YUM源

    添加CentOS 7 Nginx yum資產庫,開啟終端,使用以下命令:

    sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

  2)安裝Nginx

    在你的CentOS 7 伺服器中使用yum命令從Nginx原始伺服器中擷取來安裝Nginx:

    sudo yum install -y nginx

  3)啟動Nginx

    nginx -c /etc/nginx/nginx.conf   開啟Nginx

    nginx -s reload   修改配置後重新載入生效

    nginx -s reopen  :重新開啟記錄檔

    nginx -t -c /path/to/nginx.conf 測試nginx設定檔是否正確

    nginx -s stop  :快速停止nginx

  4)Nginx設定開機自啟

    sudo systemctl enable nginx.service

  5)Nginx 設定檔所在目錄

    /etc/nginx/conf.d/

2、php7編譯安裝

  1)cd /usr/local/src/

  2)wget http://cn2.php.net/distributions/php-7.0.2.tar.gz

  3)tar -xzxvf php-7.0.2.tar.gz

  4)cd php-7.0.2

  5)解壓完後先不要編譯,請檢查是否安裝了gcc ,沒有的話執行yum install gcc

  6)檢查是否安裝了libxml2 ,沒有的話執行yum install libxml2  7)檢查是否安裝了libxml2-devel,沒有的話執行yum install libxml2-devel    註:因為改為用nginx了,所以編譯參數中的--with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安裝PHP前,請先安裝apache。   8)編譯參數配置      ‘./configure‘ ‘--prefix=/usr/local/php‘ ‘--with-pdo-pgsql‘ ‘--with-zlib-dir‘ ‘--with-freetype-dir‘ ‘--enable-mbstring‘ ‘--with-libxml-dir=/usr‘ ‘--enable-soap‘ ‘--enable-calendar‘ ‘--with-curl‘ ‘--with-mcrypt‘ ‘--with-gd‘ ‘--with-pgsql‘ ‘--disable-rpath‘ ‘--enable-inline-optimization‘ ‘--with-bz2‘ ‘--with-zlib‘ ‘--enable-sockets‘ ‘--enable-sysvsem‘ ‘--enable-sysvshm‘ ‘--enable-pcntl‘ ‘--enable-mbregex‘ ‘--enable-exif‘ ‘--enable-bcmath‘ ‘--with-mhash‘ ‘--enable-zip‘ ‘--with-pcre-regex‘ ‘--with-pdo-mysql‘ ‘--with-mysqli‘ ‘--with-jpeg-dir=/usr‘ ‘--with-png-dir=/usr‘ ‘--enable-gd-native-ttf‘ ‘--with-openssl‘ ‘--with-fpm-user=www-data‘ ‘--with-fpm-group=www-data‘ ‘--with-libdir=/lib/x86_64-linux-gnu/‘ ‘--enable-ftp‘ ‘--with-gettext‘ ‘--with-xmlrpc‘ ‘--with-xsl‘ ‘--enable-opcache‘ ‘--enable-fpm‘ ‘--with-iconv‘ ‘--with-xpm-dir=/usr‘   9)出現報錯 Cannot find OpenSSL‘s <evp.h>      則執行 yum install openssl openssl-devel   10)出現報錯 Please reinstall the libcurl distribution     則執行 yum -y install curl-devel   11)出現報錯 jpeglib.h not found    則執行 yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y  和執行yum install libjpeg-devel    12)checking for BZip2 in default path... not found          configure: error: Please reinstall the BZip2 distribution  這是bzip2軟體包沒有安裝解決辦法    yum install bzip2-devel.x86_64 -y   13)configure: error: xpm.h not found.       yum install libXpm-devel   14)error: Unable to locate gmp.h      Fix: yum install gmp-devel   15)現象:Unable to detect ICU prefix or /usr//bin/icu-config failed. Please verify ICU install       prefix and make sure icu-config works   解決辦法:yum install -y icu libicu libicu-devel   16)錯誤:mcrypt.h not found. Please reinstall libmcrypt.      解決辦法:yum  install  php-mcrypt  libmcrypt  libmcrypt-devel   17)錯誤: configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path    解決辦法:yum install  postgresql-devel   18)錯誤 : configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution    解決: yum install libxslt-devel   19)配置的checking 結束後,執行:    make clean && make && make install(如果出現錯誤:--ENABLE-OPCACHE=NO時執行export LD_LIBRARY_PATH=/usr/local/mysql/lib或export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib)   20)裝完成後,我們要把源碼包中的設定檔複製到PHP安裝目錄下,源碼包中有兩個配置  php.ini-development  php.ini-production  ,看名字就知道,一個是開發環境,一個是生產環境,我們這裡就複製開發環境的     cp php.ini-development /usr/local/php/lib/php.ini   21)另外還需要設定環境變數 :修改vim /etc/profile檔案使其永久性生效,並對所有系統使用者生效,在檔案末尾加上如下兩行代碼    PATH=$PATH:/usr/local/php/bin    export PATH    然後執行 命令 source /etc/profile   22)php -v 就可以看到PHP版本資訊了。    23)此時還需要配置PHP-fpm:    cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf     cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf     cp /usr/local/src/php-7.0.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm     chmod +x /etc/init.d/php-fpm  24)啟動php-fpm:   /usr/local/php/sbin/php-fpm3、MySQL   yum安裝  1)下載MySQL源    wget http://dev.MySQL.com/get/mysql57-community-release-el7-7.noarch.rpm

  2)安裝MySQL源   sudo rpm -ivh mysql57-community-release-el7-7.noarch.rpm

  3)安裝mysql-community-server    sudo yum install mysql-community-server -y

  4)重啟MySQL    systemctl restart mysqld   註:自動啟動服務用 systemctl enable mysql

 

 

nginx+php7+mysql 在centos7.3下安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.