LNMP環境配置
Linux,NGINX,PHP,MYSQLphp
PHP 依賴庫安裝html
安裝GD庫 -讓php支持gif,png,jpeg格式python
GD庫須要如下模塊的支持
jpeg,libpng,freetype,libXpm-develmysql
wget http://www.ijg.org/files/jpegsrc.v9.tar.gzlinux
tar -zxvf jpegsrc.v9.tar.gz
cd jpeg-9
./configure --prefix=/usr/local/jpeg9/ --enable-shared --enable-static
make & make install
libpngnginx
wget http://jaist.dl.sourceforge.net/project/libpng/libpng16/1.6.13/libpng-1.6.13.tar.gzsql
tar -zxvf libpng-1.6.13.tar.gz
cd libpng-1.6.13
./configure --prefix=/usr/local/libpng
make & make install
freetypevim
wget http://jaist.dl.sourceforge.net/project/freetype/freetype2/2.5.3/freetype-2.5.3.tar.gzdom
tar -zxvf freetype-2.5.3.tar.gz
cd freetype-2.5.3 ./configure --prefix=/usr/local/freetype make & make install
libXpm-develpython2.7
apt-get install libxpm-dev
#若是編譯報錯,創建軟鏈接
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so.4.11.0 /usr/lib/
ln -s /usr/lib/x86_64-linux-gnu/libXpm.so.4 /usr/lib/
如今須要的模塊都已經編譯好了
正式開始安裝GD庫
https://bitbucket.org/libgd/gd-libgd/downloads
wget https://bbuseruploads.s3.amazonaws.com/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
tar -zxvf libgd-2.1.0.tar.gz
cd libgd-2.1.0
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg9/ --with-png=/usr/local/libpng/ --with-zlib=/usr/local/zlib-1.2.8/ --with-freetype=/usr/local/freetype/
make & make install
安裝curl庫
wget http://curl.haxx.se/download/curl-7.37.1.tar.gz
tar -zxvf curl-7.37.1.tar.gz
cd curl-7.37.1
./configure --prefix=/usr/local/curl
make & make install
PHP 安裝
安裝php前咱們還得解決libxml2 和 libxslt
http://www.xmlsoft.org/downloads.html
wget ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz
tar -zxvf libxml2-2.9.1.tar.gz
cd libxml2-2.9.1
須要指定python
./configure --prefix=/usr/local/libxml2 --with-python=/usr/lib/python2.7
make & make install
http://xmlsoft.org/XSLT/downloads.html
wget ftp://xmlsoft.org/libxslt/libxslt-1.1.28.tar.gz
tar -zxvf libxslt-1.1.28.tar.gz cd libxslt-1.1.28
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
make & make install
安裝 Libiconv
http://directory.fsf.org/wiki/Libiconv
wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
tar -zxvf libiconv-1.14.tar.gz cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
#出現錯誤
make[2]: *** [progname.o] Error 1
make[2]: Leaving directory `/opt/libiconv-1.14/srclib'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/opt/libiconv-1.14/srclib'
make: *** [all] Error 2
#執行
cd srclib
sed -i -e '/gets is a security/d' ./stdio.in.h
make
make install
安裝 BZip2
http://www.bzip.org/downloads.html
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar -zxvf bzip2-1.0.6.tar.gz -C /usr/src cd /usr/src/bzip2-1.0.6/ make make install
好了,通過漫長的編譯,終於要裝php了
http://php.net/downloads.php
wget http://cn2.php.net/distributions/php-5.6.0.tar.gz
tar -zxvf php-5.6.0.tar.gz
cd php-5.6.0/
./configure --prefix=/usr/local/php-5.6.0 --with-config-file-path=/usr/local/php-5.6.0/etc --with-curl=/usr/local/curl/ --with-freetype-dir=/usr/local/freetype -with-png-dir=/usr/local/libpng/ --with-libxml-dir=/usr/local/libxml2/ --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-zlib-dir=/usr/local/zlib-1.2.8/ --with-xsl=/usr/local/libxslt/ --with-jpeg-dir=/usr/local/jpeg9/ --with-iconv-dir=/usr/local/libiconv/ --with-bz2=/usr/local/bzip2/ --with-openssl-dir=/usr/local/ssl --with-gd=/usr/local/gd2/ --with-xpm-dir=/usr/lib/x86_64-linux-gnu --enable-ftp --enable-sockets --enable-soap --enable-bcmath --enable-xslt --enable-mbstring --enable-calendar --with-gettext --enable-dom --enable-xml --enable-fpm --with-png
make & make install
配置PHP
cp /usr/local/php-5.6.0/php.ini-production /usr/local/php-5.6.0/etc/php.ini cp /usr/local/php-5.6.0/etc/php-fpm.conf.default /usr/local/php-5.6.0/etc/php-fpm.conf #添加 nobody 用戶 啓動PHP groupadd nobody
啓動
/usr/local/php-5.6.0/sbin/php-fpm
執行以上命令,若是沒報錯通常狀況下表示啓動正常,若是不放心,也能夠經過端口判斷是PHP否啓動
# netstat -lnt | grep 9000 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
配置Nginx
mkdir /usr/local/php-portal/logs/ # 用於存放nginx日誌.請看2.3的配置文件 mkdir -p /usr/local/php-portal/site # 站點根目錄 vim /usr/local/php-portal/site/info.php
<?php
phpinfo();
?>
# 退出保存
編輯nginx.conf
vim /usr/local/nginx/conf/nginx.conf # 增長 PHP Server server { listen 8081; server_name localhost; access_log /usr/local/php-portal/logs/access.log; index index.php index.html index.html; root /usr/local/php-portal/site; location / { try_files $uri $uri/ /index.php?$args; } location ~ .*\.(php)?$ { expires -1s; try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass 127.0.0.1:9000; } }
啓動Nginx
/usr/local/nginx/sbin/nginx
訪問測試頁
http://192.168.124.132:8081/info.php