LNMP安裝

LNMP-----à Linux + Nginx+Mysql+Phpphp

環境安裝包:http://pan.baidu.com/s/1c1H8d8Ghtml

初始環境: mysql

爲了省事把所須要的庫文件全都安裝上,可使用rpm包安裝,也能夠用yum命令安裝, nginx

 

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers c++

 

#nginx所須要的庫文件件 sql

 

yum -y install pcre-devel zlib-devel vim

 

#PHP依賴的庫文件 api

yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel app

 

cp -frp /usr/lib64/libldap* /usr/lib/ curl

安裝庫文件

tar zxvf libiconv-1.14.tar.gz

cd libiconv-1.14

./configure --prefix=/usr/local

make && make install

libiconv 安裝問題處理

 

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure

make && make install

/sbin/ldconfig

cd libltdl

./configure --enable-ltdl-install

make && make install

 

tar zxvf mhash-0.9.9.9.tar.gz

cd mhash-0.9.9.9/

./configure

make && make install

 

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8

ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a

ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la

ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so

ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config

 

configure error libmcrypt was not found解決方法

tar -zxvf mcrypt-2.6.8.tar.gz

cd mcrypt-2.6.8/

/sbin/ldconfig

./configure

make && make install

 

mkdir -p /usr/local/php5.6

 

 

export LIBS="-lm -ltermcap –lresolv "
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"
export LD_LIBRARY_PATH="/usr/local/mysql/lib/:/lib/:/usr/lib/:/usr/local/lib:/lib64/:/usr/lib64/:/usr/local/lib64"

 

 

Zlib安裝

tar -zxvf zlib-1.2.8.tar.gz  

 cd zlib-1.2.8

./configure --prefix=/usr/local/zlib

Make && make install

Cd ..

安裝freetype

tar jxvf freetype-2.3.10.tar.bz2

cd freetype-2.3.10

 

export LIBS=

export CFLAGS=

 

 ./configure --prefix=/usr/local/freetype

 

make

make install

cd ..

 

 安裝jpeg

tar zxvf jpegsrc.v9b.tar.gz

cd jpeg-9b

./configure --prefix=/usr/local/jpeg

Make(先make 在make install)

make install

cd ..

安裝libpng

tar jxvf libpng-1.2.41.tar.bz2

cd libpng-1.2.41

./configure --prefix=/usr/local/libpng

若報錯zlib not installed ,則參考http://www.cnblogs.com/xulele/p/5247352.html

make

make install

 

(4) 安裝GD

 連接頭文件

Cd ..

ln  -s  /usr/local/libpng/include/pngconf.h /usr/include

ln  -s /usr/local/libpng/include/png.h /usr/include

 

安裝GD

tar -zxvf gd-2.1.0.tar.gz

cd libgd-2.1.0

./configure --prefix=/usr/local/gd2\

 --with-freetype=/usr/local/freetype --with-png=/usr/local/libpng\

 --with-jpeg=/usr/local/jpeg

make

make install

cd ..

 

安裝php

 

tar jxvf php-5.6.19.tar.bz2

 

 cd php-5.6.19

 configure分爲兩種狀況:

一、若本機已經安裝了mysql,則採用下面這種方式,指定mysql的安裝目錄

./configure --prefix=/usr/local/php5.6\

 --with-config-file-path=/etc\

 -enable-fpm\

--with-iconv-dir=/usr/local\

--with-freetype-dir\

--with-mysql=/usr/local/mysql\

--with-mysqli=/usr/local/mysql/bin/mysql_config\

--with-jpeg-dir --with-png-dir --with-zlib --with-mhash\

 -enable-sockets -enable-ftp --with-libxml-dir -enable-xml\

 -disable-rpath -enable-bcmath -enable-shmop -enable-sysvsem\

 -enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex\

 -enable-mbstring --with-mcrypt --with-gd -enable-gd-native-ttf\

 --with-openssl --with-mhash -enable-pcntl -enable-sockets\

 --with-ldap --with-ldap-sasl\

 --with-xmlrpc -enable-zip -enable-soap --without-pear

 

 二、若本機沒有安裝mysql,只是開啓對msyql的支持,則以下方式:

./configure --prefix=/usr/local/php5.6\

 --with-config-file-path=/etc\

 --enable-fpm\

 --with-iconv-dir=/usr/local\

 --with-freetype-dir\

 --with-jpeg-dir --with-png-dir --with-zlib --with-mhash\

 --enable-sockets --enable-ftp --with-libxml-dir -enable-xml\

 --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem\

 --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex\

 --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf\

 --with-openssl --with-mhash --enable-pcntl\

 --with-ldap --with-ldap-sasl\

 --with-xmlrpc --enable-zip --enable-soap --without-pear\

 --with-mysql --with-mysqli --enable-pdo  --with-pdo-mysql   

 

 vi Makefile

 

在PHP源碼目錄下 vi Makefile 找到 EXTRA_LIBS 行,在行末添加 ‘ -llber ‘ 保存退出再次make便可。

 

 

make ZEND_EXTRA_LIBS='-liconv'

make install

 

cp php.ini-production /etc/php.ini

 

vim /etc/profile  

在文件末尾加上兩行

PATH=$PATH:/usr/local/php5.6/bin  

export PATH 

保存,而後執行:

source /etc/profile

 

將php-fpm 做爲服務運行

 

cp ./sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm

cd /usr/local/php5.6/etc    

mv php-fpm.conf.default php-fpm.conf

chmod 755 /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig --level 345 php-fpm on

服務方式啓動php-fpm

service php-fpm start

 

【2】編譯Nginx

useradd www

安裝pcre

tar zxvf pcre-8.32.tar.gz

cd pcre-8.32/

./configure --prefix=/usr/local/pcre

make && make install

安裝nginx

tar zxvf nginx-1.8.1.tar.gz

cd nginx-1.8.1/

./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6

make && make install

 

 

修改配置:

1、增長用戶並受權

cd /usr/local/php5.6/etc

vim php-fpm.conf

確認Listen爲9000 ,並開啓

Useradd php

chmod -R 775 php

 

cd home

cd php/www (注:若沒有www文件夾 則 mkdir www)

vim index.php

2、配置nginx

配置nginx

Cd /usr/local/nginx/conf

 

location ~ \.php$ {

root /home/php/www;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /home/php/www$fastcgi_script_name;

include fastcgi_params;

}

kill -HUP 主進程號或進程號文件路徑

或者使用

啓動:

 

/usr/local/nginx/sbin/nginx

   

3、關閉

  查詢nginx主進程號

  ps -ef | grep nginx

  從容中止   kill -QUIT 主進程號

  快速中止   kill -TERM 主進程號

  強制中止   kill -9 nginx

  若nginx.conf配置了pid文件路徑,若是沒有,則在logs目錄下

  kill -信號類型 '/usr/local/nginx/logs/nginx.pid'

相關文章
相關標籤/搜索