LNMP 的安安装,Linux nginx mysql php ,这四个软件安装起来。

lLinux+ Nginx + MySQL + PHPlPHP是一种脚本语言,当前中国乃至世界上使用php语言开发网站非常普遍lNginx是一个web服务软件,和apache是一类软件,目前使用nginx的企业越来越多lMySQL是当前最为流行的小型关系型数据库lLNMP就是一个支持解析php程序的环境


先安装Mysql 过程和LAMP 是一样的,参见前面LAMP 的笔记。再安装 PHP.


Mysql 安装 看到以下两个OK 表示安装成功。 也可以eche $?

when specifying MySQL privileges !

Installing MySQL system tables...

OK

Filling help tables...

OK

-------------------------------------------------------------------------

PHP 下载 5.6 的版本

[root@LNMP src]# wget http://cn2.php.net/distributions/php-5.6.27.tar.bz2 #下载


[root@LNMP src]# tar jxvf php-5.6.27.tar.bz2 #解压


[root@LNMP src]# cd /php-5.6.27/

编译安装

l./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm--with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql--with-mysql-sock=/tmp/mysql.sock --with-libxml-dir--with-gd --with-jpeg-dir--with-png-dir --with-freetype-dir--with-iconv-dir --with-zlib-dir--with-mcrypt --enable-soap --enable-gd-native-ttf--enable-ftp --enable-mbstring --enable-exif--enable-zend-multibyte --disable-ipv6 --with-pear--with-curl

[root@LNMP src]# make # 这一步楼主还是报错,上次安装LAMP 是一样的

configure: error: xml2-config not found. Please check your libxml2 installation.


yuminstall-ylibxml2-devel#安装libxml2-devel

-----------------------------------

configure: error: Please reinstall the libcurl distribution -


[root@LNMP php-5.6.27]# yum -y install curl-devel #安装


还是报下面的错

configure: error: jpeglib.h not found.


[root@LNMP php-5.6.27]#yum -y install libjpeg-devel #安装


configure: error: png.h not found.

yum -y install libpng-devel


configure: error: freetype-config not found.

yum -y install freetype-devel


configure: error: mcrypt.h not found. Please reinstall libmcrypt.

################################################################

小插曲 SZ 工具的的安装

rz,sz是Linux/Unix同Windows进行ZModem文件传输的命令行工具。

优点就是不用再开一个sftp工具登录上去上传下载文件。


sz:将选定的文件发送(send)到本地机器

rz:运行该命令会弹(www.111cn.net)出一个文件选择窗口,从本地选择文件上传到Linux服务器


安装命令:


yum install lrzsz


从服务端发送文件到客户端:


sz filename


从客户端上传文件到服务端:


from:http://www.111cn.net/sys/linux/67810.htm

####################################################################

[root@LNMP php-5.6.27]#yum -y install freetype-devel #安装(此处没有安装成功)

-----------------------------------------------------

方案二:

[root@LNMP src]# tar zxvf libmcrypt-2.5.7.tar.gz #解压


[root@LNMP src]# cd libmcrypt-2.5.7/ #进入安装目录


[root@LNMP src]# ./configure #配置


[root@LNMP libmcrypt-2.5.7]# make #编译

[root@LNMP libmcrypt-2.5.7]# make install #安装


[root@LNMP libmcrypt-2.5.7]# echo $? #检测有没有问题

0

-----------------------------------------------------------


终于第二个方案解决了。接着进行PHP 的下一步


[root@LNMP php-5.6.27]# make # 这个过程大约5分钟


[root@LNMP php-5.6.27]# echo $?

0

[root@LNMP php-5.6.27]# make install


[root@LNMP php-5.6.27]# echo $?

0


[root@LNMP php-5.6.27]# ls /usr/local/php/

bin etc include lib php sbin var


拷贝php 的配置文件

[root@LNMP php-5.6.27]# cp php.ini-production /usr/local/php/etc/php.ini

拷贝启动脚本

[root@LNMP php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[root@LNMP php-5.6.27]# chmod 755 /etc/init.d/php-fpm #授予执行权限


[root@LNMP php-5.6.27]# chkconfig --add php-fpm #加入到系统服务列表


[root@LNMP php-5.6.27]# chkconfig php-fpm on # 开机启动


[root@LNMP php-5.6.27]# service php-fpm start #吂动服务(因配置文件不存在,启动不起来)

Starting php-fpm [03-Nov-2016 01:35:33] ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)

[03-Nov-2016 01:35:33] ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'

[03-Nov-2016 01:35:33] ERROR: FPM initialization failed

failed

[root@LNMP php-5.6.27]# cd /usr/local/php/etc/ #进入到配置文件目录
[root@LNMP etc]# ls #查看配置文件
pear.conf php-fpm.conf.default php.ini #红色的就是配置文件

[root@LNMP etc]# mv php-fpm.conf.default php-fpm.conf #拷贝配置文件

[root@LNMP etc]# /usr/local/php/sbin/php-fpm -t # 检查配置文件有没有错误
[03-Nov-2016 01:40:02] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful


[root@LNMP etc]# service php-fpm start # 再次启动还是报错(因为没有创建用户)

Starting php-fpm [03-Nov-2016 01:42:52] ERROR: [pool www] cannot get uid for user 'php-fpm'

[03-Nov-2016 01:42:52] ERROR: FPM initialization failed

failed


[root@LNMP etc]# useradd -s /sbin/nologin php-fpm #创建用户,但不需要用户登录

#php-fpm 这个用户在编译的时候就已经定义了。

[root@LNMP etc]# service php-fpm start #再次启动 OK

Starting php-fpm done


[root@LNMP etc]# ps aux |grep php-fpm # 查看启动的进程

root 34321 0.0 0.4 109096 4264 ? Ss 01:44 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)

php-fpm 34322 0.0 0.3 109096 3912 ? S 01:44 0:00 php-fpm: pool www

php-fpm 34323 0.0 0.3 109096 3912 ? S 01:44 0:00 php-fpm: pool www

root 34325 0.0 0.0 103252 824 pts/0 S+ 01:46 0:00 grep php-fpm


[root@LNMP etc]# netstat -lnp #查看监听的端口

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1080/sshd

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1306/master

tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 34321/php-fpm

tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1217/mysqld

tcp 0 0 :::22 :::* LISTEN 1080/sshd

tcp 0 0 ::1:25 :::* LISTEN 1306/master

udp 0 0 0.0.0.0:68 0.0.0.0:* 1563/dhclient

PHP 的安装至此告一段落。