LNMP之PHP 编译安装
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 的版本
# wget http://cn2.php.net/distributions/php-5.6.27.tar.bz2#下载
# tar jxvf php-5.6.27.tar.bz2 #解压
# 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
# make # 这一步楼主还是报错,上次安装LAMP 是一样的
configure: error: xml2-config not found. Please check your libxml2 installation.
yum install -y libxml2-devel#安装libxml2-devel
-----------------------------------
configure: error: Please reinstall the libcurl distribution -
# yum -y install curl-devel#安装
还是报下面的错
configure: error: jpeglib.h not found.
#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
####################################################################
#yum -y install freetype-devel#安装(此处没有安装成功)
-----------------------------------------------------
方案二:
# tar zxvf libmcrypt-2.5.7.tar.gz#解压
# cd libmcrypt-2.5.7/ #进入安装目录
# ./configure #配置
# make #编译
# make install #安装
# echo $? #检测有没有问题
0
-----------------------------------------------------------
终于第二个方案解决了。接着进行PHP 的下一步
# make# 这个过程大约5分钟
# echo $?
0
# make install
# echo $?
0
# ls /usr/local/php/
binetcincludelibphpsbinvar
拷贝php 的配置文件
# cp php.ini-production /usr/local/php/etc/php.ini
拷贝启动脚本
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod 755 /etc/init.d/php-fpm #授予执行权限
# chkconfig --add php-fpm #加入到系统服务列表
# chkconfig php-fpm on # 开机启动
# service php-fpm start#吂动服务(因配置文件不存在,启动不起来)
Starting php-fpm ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
ERROR: failed to load configuration file '/usr/local/php/etc/php-fpm.conf'
ERROR: FPM initialization failed
failed
# cd /usr/local/php/etc/#进入到配置文件目录
# ls #查看配置文件
pear.confphp-fpm.conf.defaultphp.ini #红色的就是配置文件
# mv php-fpm.conf.default php-fpm.conf#拷贝配置文件
# /usr/local/php/sbin/php-fpm -t# 检查配置文件有没有错误
NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful
# service php-fpm start# 再次启动还是报错(因为没有创建用户)
Starting php-fpm ERROR: cannot get uid for user 'php-fpm'
ERROR: FPM initialization failed
failed
# useradd -s /sbin/nologin php-fpm#创建用户,但不需要用户登录
#php-fpm这个用户在编译的时候就已经定义了。
# service php-fpm start #再次启动 OK
Starting php-fpmdone
# ps aux |grep php-fpm# 查看启动的进程
root 343210.00.4 1090964264 ? Ss 01:44 0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
php-fpm343220.00.3 1090963912 ? S 01:44 0:00 php-fpm: pool www
php-fpm343230.00.3 1090963912 ? S 01:44 0:00 php-fpm: pool www
root 343250.00.0 103252 824 pts/0 S+ 01:46 0:00 grep php-fpm
# 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 的安装至此告一段落。
页:
[1]