Linux整合LNMP(Centos7.4+Nginx+PHP+MariaDB)

分享知識 傳遞快樂

 

由於之前寫過Windows整合方式,有很多相同的地方,在此就不過多重複寫了,參考下面幾篇文章就夠用了。

Win7整合WNMP(Linux整合LNMP(Centos7.4+Nginx+PHP+MariaDB))

Nginx安裝注意事項

Linux安裝MariaDB(超詳細的yum安裝、二進制安裝)

 

Nginx和MariaDB配置還是很順利,但在配置PHP時出了不少幺蛾子;下面記錄一下本人遇到的問題。

 

1、官網下載PHP二進制包

PHP 5.2.25:https://www.php.net/releases/

文件名:php-5.2.15.tar.gz

 

2、解壓tar.gz文件到指定目錄下

[root@localhost ~]# mkdir /opt/mariadb
[root@localhost ~]# tar -zxvf php-5.2.15.tar.gz -C /opt/lnmp/bin/php/5.5.12

 

3、配置

1)配置

[root@localhost 5.5.12]# ./configure --prefix=/opt/lnmp/bin/php/5.5.12 --with-config-file-path=/opt/lnmp/bin/php/5.5.12/etc --enable-inline-optimization --disable-debug --enable-fpm --with-fpm-user=www --with-fpm-group=www --disable-rpath --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl  --with-mhash --with-pcre-regex --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-mbstring --with-onig --enable-shared --enable-opcache --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-readline --with-iconv --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets  --enable-zip --enable-wddx --with-pear 

2)編譯安裝

[root@localhost 5.5.12]# make
[root@localhost 5.5.12]# make install

或者

[root@localhost 5.5.12]# make && make install

附:

還可以使用一條命令操作全部:配置編譯安裝

[root@localhost 5.5.12]# ./configure --prefix=/opt/lnmp/bin/php/5.5.12 --with-config-file-path=/opt/lnmp/bin/php/5.5.12/etc --enable-inline-optimization --disable-debug --enable-fpm --with-fpm-user=www --with-fpm-group=www --disable-rpath --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl  --with-mhash --with-pcre-regex --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-mbstring --with-onig --enable-shared --enable-opcache --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-readline --with-iconv --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets  --enable-zip --enable-wddx --with-pear && make && make install

如果在編譯安裝時出現異常請參考命令結束的最後一行,根據反饋的信息來判斷系統缺少哪些依賴文件。在文章最下面提供一些常見的PHP編譯時返回error解決方法。

 

4、啓動

編譯安裝成功後會在php的安裝目錄下生成一個sbin的文件夾,通過php-fpm來啓動PHP:

[root@localhost 5.5.12]# cd sbin/
[root@localhost sbin]# ./php-fpm
[06-Jan-2020 20:57:05] ERROR: failed to open configuration file '/opt/lnmp/bin/php/5.5.12/etc/php-fpm.conf': No such file or directory (2)
[06-Jan-2020 20:57:05] ERROR: failed to load configuration file '/opt/lnmp/bin/php/5.5.12/etc/php-fpm.conf'
[06-Jan-2020 20:57:05] ERROR: FPM initialization failed

在啓動出現了異常,提示找不到php-fpm.conf文件。

解決方法:

進入php的配置目錄

[root@localhost etc]# cd etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# vim php-fpm.conf

打開 php-fpm.conf 文件中以下配置:

pid = run/php-fpm.pid

打開後,保存即可。

 

5、查看狀態

[root@localhost 5.5.12]# ps -ef | grep php-fpm

 

6、停止

[root@localhost 5.5.12]# killall -9 php-fpm

 

 

 

 

PHP編譯時返回error解決方法:

1)Configure: error: xml2-config not found. Please check your libxml2 installation.

[root@localhost 5.5.12]# yum install libxml2 libxml2-devel

2)Configure: error: Please reinstall the BZip2 distribution

[root@localhost 5.5.12]# yum install bzip2 bzip2-devel

3)Configure: error: Please reinstall the libcurl distribution-easy.h should be in <curl-dir>/include/curl/.

[root@localhost 5.5.12]# yum install curl curl-devel

4)Configure: error: libjpeg.(also) not found.

[root@localhost 5.5.12]# yum install libjpeg libjpeg-devel

5)Configure: error: libpng.(also) not found.

[root@localhost 5.5.12]# yum install libpng libpng-devel

6)Configure: error: mcrypt.h not found. Please reinstall libmcrypt.

[root@localhost 5.5.12]# yum install libmcrypt libmcrypt-devel
[root@localhost 5.5.12]# yum install -y epel-release
[root@localhost 5.5.12]# yum install -y libmcrypt-devel

7)Configure: error: Please reinstall libmhash – I cannot find mhash.h.

[root@localhost 5.5.12]# yum install mhash-devel

8)Configure: error: jpeglib.h not found.

[root@localhost 5.5.12]# yum -y install libjpeg-devel


 

 

 

 

 

 

 

——————————
如有不足請留言指正
相互學習,共同進步

發佈了114 篇原創文章 · 獲贊 107 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章