分类目录归档:lnmp

设置lnmp切换php版本

1.       说明:linux下安装lnmp的默认php版本只能使用一个版本,如果有些网站需要低版本5.2或者高版本,那么如何做呢,

2.       Lnmp安装时候默认选择了php5.3,但是其中某个网站需要php5.5

3.       编译安装php5.5

(a)安装必要软件

rpm -ivh
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum
groupinstall ‘Development Tools’

yum
install libmhash-devel

yum
install libmhash

yum
install libicu-devel

yum -y
install krb5*

yum
install -y gcc gcc-c++ make gmp-devel libc-client-devel zlib zlib-devel pcre
pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel
libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel
openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients
openldap-servers

(b)安装libiconv

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

./configure
–prefix=/usr/local/libiconv

make
&& make install

(c)安装libmcrypt

wget
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt

tar zxvf
libmcrypt-2.5.7.tar.gz

cd
libmcrypt-2.5.7

./configure

make
&& make install
(d)
如果是64为操作系统执行以下操作

ln -s
/usr/lib64/libc-client.so 
/usr/lib/libc-client.so   

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

ln -s
/usr/lib64/libpng.so /usr/lib/libpng.so               

ln -s
/usr/lib64/libjpeg.so /usr/lib/libjpeg.so 

ln -s
/usr/lib64 /usr/kerberos/lib

cp -r
/usr/lib64/mysql/* /usr/lib/mysql/

(e)下载php5.5编译安装

wget http://cn2.php.net/distributions/php-5.5.38.tar.gz

tar –zxvf
php-5.5.38.tar.gz

cd php-5.5.38

先生成Makefile:

./configure
–prefix=/usr/local/php5.5 –with-config-file-path=/usr/local/php5.5/etc
–with-config-file-scan-dir=/usr/local/php5.5/php.d –with-mysql –with-mysqli
–with-iconv-dir=/usr/local/libiconv –with-mhash=/usr –with-icu-dir=/usr
–with-bz2 –with-curl –with-freetype-dir –with-gd –with-gettext –with-gmp
–with-imap –with-imap-ssl –with-jpeg-dir –with-kerberos –with-ldap
–with-mcrypt –with-openssl –without-pear –with-pdo-mysql –with-png-dir –with-xmlrpc
–with-zlib –enable-bcmath –enable-calendar –enable-ctype –enable-dom
–enable-exif –enable-ftp –enable-gd-native-ttf –enable-intl –enable-json
–enable-mbstring –enable-pcntl –enable-session –enable-shmop
–enable-simplexml –enable-soap –enable-sockets –enable-tokenizer
–enable-wddx –enable-xml –enable-zip –disable-fileinfo –enable-fpm

开始编译和安装

make
&& make install

cp
php.ini-production /usr/local/php5.5/etc/php.ini

(f)添加php5.5到服务项并设置自动启动:

cp
./sapi/fpm/init.d.php-fpm /etc/init.d/php5.5

chmod +x
/etc/init.d/php5.5

cd
/usr/local/php5.5/etc/

cp
php-fpm.conf.default php-fpm.conf

vi
php-fpm.conf
修改监听端口listen 127.0.0.1:9000listen 127.0.0.1:9001

chkconfig
php5.5 on

service
php5.5 start

(g)建立新文件/usr/local/nginx/conf/enable-php5.5.conf,内容如下:

   

(h)最后修改需要php5.5版本的网站配置文件如,www.ceshi2.com.conf
修改include enable-php.conf;include
enable-php5.5.conf;
    

(i)重启nginx ,php-fpm

   

lnmp一键安装包建立站点

 安装后的目录都在:/usr/local中

1.下载安装https://lnmp.org/(这里是ubuntu系统但是大同小异)

tar -zxvf xxxxx.tar.gz
./install.sh
  在安装的时候会进行提示选择安装mysql|php|nginx版本以及输入mysql密码.
sudo lnmp start启动(默认)
sudo lnmp restart  重启lnmp
/etc/init.d/nginx {start|stop|reload|restart}    Nginx状态管理
/etc/init.d/mysql {start|stop|restart|reload|force-reload|status}  MySQL状态管理
/etc/init.d/php-fpm {start|stop|quit|restart|reload|logrotate}    PHP-FPM状态管理

2.安装ftp,下载的包中解压后有pureftpd.sh   
sudo ./pureftpd.sh                    进行安装
sudo lnmp ftp add|list|del FtpUsers   进行增加|列出|删除 ftp
 

3.其他可执行安装
sudo ./addons.sh [install|uninstall]  缓冲加速[eAccelerator|memcached|xcache|redis|opcache]
sudo ./upgrade.sh [nginx|mysql|mariadb|m2m|php|phpa] 升级

4.建立虚拟站点,执行:
sudo lnmp vhost add
执行后系统会提示输入需绑定域名(可以输入更多域名)

接着是站点跟目录(这里选择默认目录即可,直接按回车键)

如果您的站点需要开启伪静态那么写入y

在询问是否创建日志文件后接下来就是是否创建数据库:

创建好后那么已经完成一半了,另一半上传源码进行配置站点。

具体教程请参考论坛:https://lnmp.org/faq/lnmp-software-list.html

5.新建的站点目录在/home/wwwroot
  而数据库目录在/usr/local/下,可以把data目录移动到/home下
   1).停止数据库

   2).cp –rf /var/lib/mysql/data /data/mysql/data

   3).修改权限:chown –R mysql:mysq /data/mysql/data

   4).mv /var/lib/mysql/data /var/lib/mysql/data.backup

   5).创建软连接:ln -s /data/mysql/data /var/lib/mysql/data

      最后启动