标签:rpc warning 连接 env 依赖包 figure recommend php加密 code
测试环境:CentOS release 6.5 (Final)
软件安装:nginx mysql-5.5.32-linux2.6-x86_64.tar.gz php-5.3.27.tar.gz
1、mysql安装详见:https://www.cnblogs.com/su-root/p/10247514.html
2、nginx安装详见:https://www.cnblogs.com/su-root/p/10177045.html https://www.cnblogs.com/su-root/p/10230994.html
3、PHH安装如下:
一、php安装准备
①yum安装php所依赖的包
[root@bqh-118 php]# yum -y install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
②检测机器是否已经安装好
[root@bqh-118 php]# rpm -qa zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
③安装libiconv-1.14.tar.gz -----(https://excellmedia.dl.sourceforge.net/project/korwah/source/libiconv/libiconv-1.14.tar.gz)
[root@bqh-118 php]# tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
④快速安装libmcrypt扩展库(epel源方法来安装)
[root@bqh-118 yum.repos.d]#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
[root@bqh-118 yum.repos.d]#yum makecache
[root@bqh-118 yum.repos.d]# yum install libmcrypt-devel -y
⑤快速安装mhash加密算法扩展库
Mhash是基于离散数学原理的不可逆向的php加密方式扩展库,其在默认情况下开启,mhash的可以用于场景检验数值,消息摘要,小小认证码,以及无需原文的关键信息保存(如密码)等。
Mhash为PHP提供了多种哈希算法,如MD5,SHA1,GOST等,你可以通过MHASH_hashname()来查看支持的算法有哪些。
注意问题:该扩展不能提供 最新的哈希算法;该扩展结果原则上运算不可逆。
[root@bqh-118 php]# yum install mhash mhash-devel -y
⑥快速安装mcrypt加密扩展库
php程序员们在编写程序时,除了要保证代码的高性能之外,还有一点是非常重要的,那就是程序的安全性保障。php除了自带的几种加密函数外,还有功能更全面的php加密扩展库mcrypt和mhash。其中,mcrypt扩展可以实现加密解密功能,就是既能将明文密码加
密,也可以密文还原。mcrypt是php里面重要的加密支持扩扎库,该库在默认情况下不开启。编辑本段支持的算法和加密模式:mcrypt库支持20多种加密算法和8中加密模式,具体可以通过函数crypt_list_algorithms()和mcrypt_list_modes()来显示。
[root@bqh-118 php]# yum install mcrypt -y
⑦安装libxslt-devel
[root@bqh-118 php]# yum -y install libxslt-devel
以上安装php依赖包就ok了。
二、开始安装PHP服务
①下载php-5.3.27.tar.gz 并解压。
下载php:https://www.php.net/distributions/php-5.3.27.tar.gz
[root@bqh-118 php]# tar xf php-5.3.27.tar.gz
②编译安装PHP
[root@bqh-118 php]# cd php-5.3.27
[root@bqh-118 php-5.3.27]#./configure --prefix=/application/php-5.3.27 --with-mysql=/application/mysql --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-mbstring --enable-fpm --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-zend-multibyte --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp
注意:在make前加上这两条命令:
[root@bqh-118 php-5.3.27]# ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[root@bqh-118 php-5.3.27]# touch ext/phar/phar.phar
[root@bqh-118 php-5.3.27]# make && make install #安装php生成文件到系统
......
.........
Installing header files: /application/php-5.3.27/include/php/
Installing helper programs: /application/php-5.3.27/bin/
program: phpize
program: php-config
Installing man pages: /application/php-5.3.27/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /application/php-5.3.27/lib/php/
[PEAR] Archive_Tar - installed: 1.3.11
[PEAR] Console_Getopt - installed: 1.3.1
warning: pear/PEAR requires package "pear/Structures_Graph" (recommended version 1.0.4)
warning: pear/PEAR requires package "pear/XML_Util" (recommended version 1.2.1)
[PEAR] PEAR - installed: 1.9.4
Wrote PEAR system config file at: /application/php-5.3.27/etc/pear.conf
You may want to add: /application/php-5.3.27/lib/php to your php.ini include_path
[PEAR] Structures_Graph- installed: 1.0.4
[PEAR] XML_Util - installed: 1.2.1
/home/bqh/tools/php-5.3.27/build/shtool install -c ext/phar/phar.phar /application/php-5.3.27/bin
ln -s -f /application/php-5.3.27/bin/phar.phar /application/php-5.3.27/bin/phar
Installing PDO headers: /application/php-5.3.27/include/php/ext/pdo/
[root@bqh-118 php-5.3.27]# echo $?
0
③配置php引擎配置文件php.ini
设置软连接安全方便访问:
[root@bqh-118 php-5.3.27]# ln -s /application/php-5.3.27/ /application/php
[root@bqh-118 php-5.3.27]# ls -l /application/php
lrwxrwxrwx 1 root root 24 6月 23 07:07 /application/php -> /application/php-5.3.27/
拷贝php配置文件到php默认目录下并更名为php.ini
[root@bqh-118 php-5.3.27]# ll ./php.ini-*
-rw-r--r-- 1 101 101 69606 7月 11 2013 ./php.ini-development #开发
-rw-r--r-- 1 101 101 69627 7月 11 2013 ./php.ini-production #生产
[root@bqh-118 php-5.3.27]# cp php.ini-production /application/php/lib/php.ini
④配置php服务(fastcgi模式)配置文件php-fpm.conf
[root@bqh-118 php-5.3.27]# ll /application/php/etc/
总用量 28
-rw-r--r-- 1 root root 1242 6月 23 06:32 pear.conf
-rw-r--r-- 1 root root 21690 6月 23 06:32 php-fpm.conf.default
[root@bqh-118 php-5.3.27]# cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf
[root@bqh-118 php-5.3.27]# ll /application/php/etc/
总用量 52
-rw-r--r-- 1 root root 1242 6月 23 06:32 pear.conf
-rw-r--r-- 1 root root 21690 6月 23 07:31 php-fpm.conf
-rw-r--r-- 1 root root 21690 6月 23 06:32 php-fpm.conf.default
⑤启动php进程
[root@bqh-118 php-5.3.27]# /application/php/sbin/php-fpm
[root@bqh-118 php-5.3.27]# ps -ef|grep php-fpm|grep -v grep
root 128897 1 0 07:55 ? 00:00:00 php-fpm: master process (/application/php-5.3.27/etc/php-fpm.conf)
nginx 128898 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128899 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128900 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128901 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128902 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128903 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128904 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128905 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128906 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128907 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128908 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128909 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128910 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128911 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128912 128897 0 07:55 ? 00:00:00 php-fpm: pool www
nginx 128913 128897 0 07:55 ? 00:00:00 php-fpm: pool www
[root@bqh-118 php-5.3.27]# ss -lntup|grep php-fpm
tcp LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",128897,7),("php-fpm
",128898,0),("php-fpm",128899,0),("php-fpm",128900,0),("php-fpm",128901,0),("php-fpm",128902,0),("php-fpm",128903,0),("php-fpm",128904,0),("php-fpm",128905,0),("php-fpm",128906,0),("php-fpm",128907,0),("php-fpm",128908,0),("php-fpm",128909,0),("php-fpm",128910,0),("php-fpm",128911,0),("php-fpm",128912,0),("php-fpm",128913,0))
⑥测试php
在nginx站点目录下写一个test_phpinfo.php代码测试php
[root@bqh-118 html]# vim test_phpinfo.php <?php phpinfo(); ?>
配置nginx.conf
[root@bqh-118 conf]# vim nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.test.com;
root html;
location / {
index index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
error_page 500 502 503 504 /50x.html;
}
}
⑦ 刷新配置,打开浏览器输入地址结果看是否成功。
[root@bqh-118 html]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3/conf/nginx.conf test is successful
[root@bqh-118 html]# /application/nginx/sbin/nginx -s reload
http://192.168.0.118/test_phpinfo.php 或 http://www.test.com/test_phpinfo.php
ok,目前nginx到php已经通了,下面我们需要测试php到mysql是否通。
⑧在nginx站点目录下再写一个test_mysql.php代码测试php
[root@bqh-118 html]# vim test_mysql.php [root@bqh-118 html]# cat test_mysql.php <?php $link_id=mysql_connect(‘localhost‘,‘root‘,‘123456‘) or mysql_error(); if($link_id) { echo "MySQL connection succeeded!"; } else { echo mysql_error(); } ?>
浏览器输入地址:http://192.168.0.118/test_mysql.php 或 http://www.test.com/test_mysql.php
ok测试没有问题。
假如我们把mysql密码改了,我们再来测试一下效果:
到此为止,nginx→php→mysql测试一通; LNMP环境搭建ok。
LNMP环境搭建之编译安装指南(php-5.3.27.tar.gz)
标签:rpc warning 连接 env 依赖包 figure recommend php加密 code
原文地址:https://www.cnblogs.com/su-root/p/11073215.html