Linux 搭建LNMP(PHP5.6和PHP7)內容主要來自網上他人

該內容主要來自魯玉成雲的隨筆,出自http://www.cnblogs.com/luyucheng/p/6084735.htmlphp

 

./configure --prefix=/usr/local/servers/php7 \(因爲要用時使用PHP7和PHP5.6,故而給PHP7指定了目錄)
--with-config-file-path=/usr/local/servers/php7/etc \
--with-mysqli \
--enable-fpm \
--enable-ftp \
--enable-xml \
--enable-zip \
--enable-soap \
--enable-pcntl \
--enable-shmop \
--enable-bcmath \
--enable-shared \
--enable-mysqlnd \
--enable-opcache \
--enable-session \
--enable-sockets \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-inline-optimization \
--with-gd \
--with-curl \
--with-zlib \
--with-mcrypt \
--with-mhash \
--with-iconv \
--with-xmlrpc \
--with-gettext \
--with-jpeg-dir \
--with-freetype-dir \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--without-gdbm \
--without-pear \
--disable-debug \
--disable-rpath \html

//--with-iconv=/usr/local/libiconv \  (按照博主的configure一直不成功,報undefined reference to `libiconv_open'這樣的錯,故而先按照https://www.cnblogs.com/52php/p/6197428.html 這個先編譯了 libiconv
--disable-fileinfomysql

事實上libconv編譯成功以後仍然報錯,又找到一個解決辦法,https://blog.csdn.net/ikscher/article/details/51009584#replynginx

回到 cd /usr/local/src/php7- sql

在執行完 ./configure ... 以後,修改下 Makefile,(找不到Makefile 能夠用ls看下 而後vim Makefile)找到其中的EXTRA_LIBS 在後面添加 -liconvvim

EXTRA_LIBS -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmcrypt -lldap -llber -lfreetype -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto api

-lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2-lz -lm -lcrypt  -liconv
session

 

----PHP5.6-----php7

./configure --prefix=/usr/local/servers/php \
--with-config-file-path=local/servers/php/etc
--with-mysql \
--with-mysqli \
--with-iconv-dir \
--with-zlib \
--with-zlib-dir \
--with-libxml-dir \
--enable-xml \
--with-curl \
--enable-dba \
--enable-fpm \
--enable-mbstring \
--with-gd \
--with-openssl \
--with-pdo-mysql \
--without-pdo-sqlite \
--with-mcrypt \
--with-mhash \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-libdir=/usr/lib64 \
--with-jpeg-dir=/usr/lib64 \
--with-freetype-dir=/usr/lib64 \
--with-png-dir=/usr/lib64 \
--with-iconv-dir=/usr/local/libiconv \
--enable-gd-native-ttf \
--with-gettext \
--enable-pcntl \
--enable-sysvmsg \
--enable-sysvsem \

 

make && make install框架

vim /etc/profile
PATH=/usr/local/mysql/bin:/usr/local/servers/php7/bin:$PATH(/usr/local/servers/php7/bin:加入環境變量)

PHP5.6的編譯使用了同上的configure (注意修改--prefix=/usr/local/servers/php \ --exec-prefix=/usr/local/servers/php \ 目錄以做區別)

 

mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf 
PHP7時這些命令均修改爲(注意其餘條命令目錄)
mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.confcp /usr/local/src/php-7.1.3/sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm(只需將/etc/init.d/目錄下的改爲php7-fpm以做區分)chmod +x /etc/init.d/php7-fpmchkconfig --add php7-fpmchkconfig php7-fpm on./sbin/nginx -s reload(重啓)vim /usr/local/nginx/conf/nginx.conf (i 插入)server{    listen 80;    server_name localhost;    index index.php index.html index.htm;    root  /home/wwwroot/zpdydhl;    charset utf-8;        location ~* \.php$ {                fastcgi_pass 127.0.0.1:9000;                fastcgi_index index.php;                include fastcgi_params;                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                fastcgi_intercept_errors on;        }  #  access_log  /home/wwwlogs/access.log  access;}server{    listen 8098;    server_name localhost;    index index.php index.html index.htm;    root  /home/wwwroot/zpdydhl_api;    location / {        if (!-e $request_filename) {            rewrite ^(.*)$ /index.php?s=$1 last;            break;           }        }    location ~ .*\.php$ {    fastcgi_pass 127.0.0.1:9001;(vim /usr/local/php7/etc/php-fpm.d/www.conf 將listen改成9001,重啓./sbin/php-fpm)        fastcgi_index index.php;        include fastcgi_params;        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;        fastcgi_intercept_errors on;    }        access_log  /home/wwwlogs/access.log  access;}esc鍵 :wq(保存並退出)/etc/init.d/php-fpm start/etc/init.d/php-fpm stop/etc/init.d/php-fpm restart/etc/init.d/php-fpm reloadlsof -i:9000PHP7若是是yaf框架還要安裝yaf擴展以及yaconf擴展http://pecl.php.net/package/yaconf http://pecl.php.net/package/yaf
相關文章
相關標籤/搜索