首页 技术 正文
技术 2022年11月11日
0 收藏 418 点赞 2,241 浏览 3108 个字

检查安装PHP所需的lib库

yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
yum -y install freetype-devel libpng-devel gd libcurl-devel libxslt-devel
yum -y install openssl openssl-devel        #PHP所需的依赖包

安装yum无法安装的libiconv库  #以下4个包可以下载后打包为rpm包以供下次使用

yum -y install wget  
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar xf libiconv-1.14.tar.gz -C /usr/src/
cd /usr/src/libiconv-1.14/
./configure --prefix=/usr/local/libiconv && make && make install

安装libmcrypt库  mhash加密扩展库  mcrvpt加密扩展库

用 epel  yum源 进行安装

yum -y install mhash mcrypt  libmcrypt-devel

解压PHP的源码包

tar xf php-5.3..tar.gz -C /usr/src/
cd /usr/src/php-5.3./

编译

./configure --prefix=/usr/local/php5.3.28 --with-mysql=/usr/local/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-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --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=www --with-fpm-group=www --enable-ftp

PHP安装     (结合之前的nginx安装与mysql安装组合为lnmp)

编译后这样显示表示编译成功

#部分参数解释

:–prefix=/usr/local/php5.2.28

表示指定PHP的安装路径为/usr/local/php5.3.28

:–with-mysql=/usr/local/mysql

表示需要指定MySQL的安装路径,安装PHP需要的MySQL相关内容。当然,如果没有MySQL软件包,也可以不单独安装,这样的情况可使用–with-mysql=mysqlnd替代–with-mysql=/usr/local/mysql,因为PHP软件里已经自带了连接MySQL的客户端工具。

:–with-fpm-user=www

nginx表示指定PHP-FPM进程管理的用户为www,此处最好和Nginx服务用户统一

: –with-fpm-group=www

表示指定PHP-FPM进程管理的组为www,此处最好与Nginx服务用户组统一。

:–enable-fpm

表示激活PHP-FPM方式服务,即以FastCGIF方式运行PHP服务。

正确执行前文配置PHP软件的./configure系列命令后,就可以编译PHP软件了,具体操作过程如下:

ln -s /usr/local/mysql/lib/libmysqlclient.so.
ln -s /usr/local/mysql/lib/libmysqlclient.so. /usr/lib64/
touch ext/phar/phar.phar
make
#make最后的正确提示
Build complete.
Don't forget to run 'make test'.
make install

配置文件

ln -s /usr/local/php5.3.28/ /usr/local/php      #拷贝PHP配置文件到PHP默认目录,并更改文件名称为php.in
cd /usr/src/php-5.3./
cp php.ini-production /usr/local/php/lib/php.ini    #配置PHP(FastCGI方式)的配置文件php-fpm.conf
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf           
#启动PHP服务php-fpm,命令如下
/usr/local/php/sbin/php-fpm            
ps -ef | grep php-fpm
root : ? :: php-fpm: master process (/usr/local/php5.3.28/etc/php-fpm.conf)
nginx : ? :: php-fpm: pool www
nginx : ? :: php-fpm: pool www
root : pts/ :: grep php-fpm

配置Nginx支持PHP程序请求访问

修改/usr/local/nginx/conf/extra下的www.conf 虚拟用户配置文件
server {
listen ;
server_name www.wk.com;
location / {
root /var/www/html/wwwcom;
index index.html index.htm;
}
error_page /50x.html;
location = /50x.html {
root /var/www/html;
}
location ~.*\.(php|php5)?$ { #新增支持php
root /var/www/html/wwwcom;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf;
} }nginx -t            #检测语法
nginx -s reload        #重新启动

测试lnmp                     

cd /var/www/html/wwwcom/
echo "<?php phpinfo(); ?>" >test_info.php

客户端web服务:i服务端p地址/test_info.php

PHP安装     (结合之前的nginx安装与mysql安装组合为lnmp)

针对Nginx请求访问PHP,然后对PHP连接MySQL的情况进行测试

vim test_mysql.php
<?php
//$link_id=mysql_connect('主机名','用户','密码');
$link_id=mysql_connect('localhost','root','');
if($link_id){
echo "mysql successful by Mr.wang!";
}else{
echo mysql_error();
}
?>

 

上一篇: omniplan
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,085
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,560
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,409
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,182
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,819
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,902