lnmp架构之php安装及配置
一、安装
1、安装包 php-5.6.20.tar.bz2
解压:
tar jxf php-5.6.20.tar.bz2
2、编译:
./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --with-mysql --with-mysqli --with-pdo-mysql --enable-mysqld --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
编译中的报错及解决:<每次解决报错后重新编译>
<1> configure: error: xml2-config not found. Please check your libxml2 installation
解决:yum install libxml2-devel -y
<2> configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
解决:yum install libcurl-devel -y
<3> checking whether to enable truetype string function in GD... no
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-vpx-dir=<DIR>
configure: error: jpeglib.h not found.
解决:由于gd-devel由yum search找不到,所以需要从第三方下载
<4> configure: error: Unable to locate gmp.h
解决:yum install gmp-devel -y
<5> configure: error: mcrypt.h not found. Please reinstall libmcrypt
解决:同样需要第三方下载,libmcrypt和libmcrypt-devel都需要下载
<6> configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation
解决:yum install net-snmp-devel -y
3、生成配置文件:make
4、安装:make install
**
二、配置
**
[root@server1 php-5.6.20]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini
[root@server1 etc]# cd /usr/local/lnmp/php/etc/
[root@server1 etc]# vim php.ini
–> 1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock
1150 mysql.default_socket = /usr/local/lnmp/mysql/data/mysql.sock
1209 mysqli.default_socket = /usr/local/lnmp/mysql/data/mysql.sock
[root@server1 etc]# vim php-fpm.conf
–> 24 ; Default Value: none
25 pid = run/php-fpm.pid ##前面的注释去掉
[root@server1 ~]# cd php-5.6.20/sapi/fpm
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@server1 fpm]# chmod +x /etc/init.d/php-fpm
/etc/init.d/php-fpm start
此时可以开启成功,成功后如下图:
测试:
[root@server1 conf]# vim /usr/local/lnmp/nginx/conf/nginx.conf
73 location ~ \.php$ {
74 root html;
75 fastcgi_pass 127.0.0.1:9000;
76 fastcgi_index index.php;
77 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
78 include fastcgi.conf;
79 }
51 location / {
52 root html;
53 index index.php index.html index.htm;
54 }
[root@server1 html]# vim /usr/local/lnmp/nginx/html/index.php
--> 1 <?php
2 phpinfo()
3 ?>
测试结果如图: