LNMP安装
LNMP-----à Linux + Nginx+Mysql+Php
环境安装包:http://pan.baidu.com/s/1c1H8d8G
初始环境:
为了省事把所需要的库文件全都安装上,可以使用rpm包安装,也可以用yum命令安装,
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
#nginx所需要的库文件件
yum -y install pcre-devel zlib-devel
#PHP依赖的库文件
yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel
cp -frp /usr/lib64/libldap* /usr/lib/
安装库文件
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local
make && make install
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分为两种情况:
1、若本机已经安装了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
2、若本机没有安装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
修改配置:
一、增加用户并授权
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
二、配置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
三、关闭
查询nginx主进程号
ps -ef | grep nginx
从容停止 kill -QUIT 主进程号
快速停止 kill -TERM 主进程号
强制停止 kill -9 nginx
若nginx.conf配置了pid文件路径,如果没有,则在logs目录下
kill -信号类型 '/usr/local/nginx/logs/nginx.pid'
如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】按钮。
如果,您希望更容易地发现我的新博客,不妨点击一下右下角的【关注 LeLe.Xu】。
因为,我的写作热情也离不开您的肯定支持。
感谢您的阅读,如果您对我的博客所讲述的内容有兴趣,请继续关注我的后续博客,我是LeLe.Xu 。