在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1.1 编译安装1.1.1 安装前的准备下载并安装libmcrypt 和 libmcrypt-devel 1.1.2 下载PHP[root@test /opt]# wget http://cn2.php.net/distributions/php-5.3.29.tar.gz 1.1.3 编译安装[root@test /opt/php-5.3.29]# ./configure --prefix=/usr/local/php --disable-rpath --enable-bcmath --enable-calendar --enable-dba --enable-debug --enable-embed=fpm --enable-exif --enable-fpm --enable-ftp --enable-gd-jis-conv --enable-gd-native-ttf --enable-inline-optimization --enable-intl=shared --enable-maintainer-zts --enable-mbregex --enable-mbstring --enable-pcntl --enable-pdo --enable-shmop --enable-short-tags --enable-soap --enable-sockets --enable-static --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-xml --enable-zend-multibyte --enable-zip --infodir=/usr/local/share/info --mandir=/usr/local/share/man --with-bz2 --with-config-file-path=/usr/local/php/etc --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-imap --with-imap-ssl --with-jpeg-dir --with-kerberos --with-libxml-dir --with-mcrypt --with-mhash --with-mysql=/usr/local/mysql --with-openssl --with-pcre-regex --with-pear --with-png-dir --with-t1lib --with-xmlrpc --with-xpm-dir --with-xsl --with-zlib --with-fpm-user=nginx --with-fpm-group=nginx
这里需要注意的是--with-mysql这个参数:
可能遇到的一些错误: 1. configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing 2. configure: error: libXpm.(a|so) not found. 3. configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works. 4. [...]/sapi/cli/php:error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory 安装完成:... configure: creating ./config.status creating main/internal_functions.c creating main/internal_functions_cli.c +--------------------------------------------------------------------+ | License: | | This software is subject to the PHP License, available in this | | distribution in the file LICENSE. By continuing this installation | | process, you are bound by the terms of this license agreement. | | If you do not agree with the terms of this license, you must abort | | the installation process at this point. | +--------------------------------------------------------------------+ Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/fpm/php-fpm.conf config.status: creating sapi/fpm/init.d.php-fpm config.status: creating sapi/fpm/php-fpm.service config.status: creating sapi/fpm/php-fpm.8 config.status: creating sapi/fpm/status.html config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands [root@test /opt/php-5.3.29]# make install 编译时可能出现的错误:--(这种情况出现在使用mysql的二进制包,没有找到库文件libmysqlclient.so.18)
... Installing shared extensions: /usr/local/php/lib/php/extensions/debug-zts-20131226/ Installing PHP CLI binary: /usr/local/php/bin/ Installing PHP CLI man page: /usr/local/share/man/man1/ Installing PHP FPM binary: /usr/local/php/sbin/ Installing PHP FPM config: /usr/local/php/etc/ Installing PHP FPM man page: /usr/local/share/man/man8/ Installing PHP FPM status page: /usr/local/php/php/php/fpm/ Installing PHP CGI binary: /usr/local/php/bin/ Installing PHP CGI man page: /usr/local/share/man/man1/ Installing build environment: /usr/local/php/lib/php/build/ Installing header files: /usr/local/php/include/php/ Installing helper programs: /usr/local/php/bin/ program: phpize program: php-config Installing man pages: /usr/local/share/man/man1/ page: phpize.1 page: php-config.1 Installing PEAR environment: /usr/local/php/lib/php/ [PEAR] Archive_Tar - installed: 1.4.0 [PEAR] Console_Getopt - installed: 1.4.1 [PEAR] Structures_Graph- installed: 1.1.1 [PEAR] XML_Util - installed: 1.3.0 [PEAR] PEAR - installed: 1.10.1 Wrote PEAR system config file at: /usr/local/php/etc/pear.conf You may want to add: /usr/local/php/lib/php to your php.ini include_path /opt/php-5.6.21/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin ln -s -f phar.phar /usr/local/php/bin/phar Installing PDO headers: /usr/local/php/include/php/ext/pdo 编译安装memcache扩展,此步骤非必须: wget http://pecl.php.net/get/memcache-2.2.7.tgz tar xf memcache-2.2.7.tar.gz cd memcache-2.2.7 /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make make install
1.2 相关设置设置php.ini文件,这里需要注意的是,因为在编译时,我修改了php配置文件目录路径,所以存放时要放在编译时制定的目录--with-config-file-path=/usr/local/php/etc,而不是默认目录: 查看默认目录: 拷贝到制定的配置文件目录中: 编辑Nginx配置文件,添加以下配置(蓝色部分内容): [root@test /usr/local/nginx]# egrep -v "^$|#" conf/nginx.conf user nginx; worker_processes 2; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } PS: nginx的SPEC打包安装:http://www.cnblogs.com/jonsea/p/5481580.html mysql 5.7.12安装:http://www.cnblogs.com/jonsea/p/5503267.html 2. 启动php-fm制作服务脚本并启动php-fpm: 方法1----拷贝源文件中的制作好的脚本[root@test /opt/php-5.3.29]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
[root@test /opt/php-5.3.29]# chmod 755 /etc/rc.d/init.d/php-fpm [root@test /opt/php-5.3.29]# /etc/init.d/php-fpm start Starting php-fpm done [root@test /opt/php-5.3.29]# chkconfig --add php-fpm --level 35
方法2----制作启动脚本(推荐)#!/bin/bash # php-fpm startup script for php-fpm # # chconfig: - 82 14 # processname: php-fpm # ### BEGIN INIT INFO # Default-Start : 3 5 # Default-Sop: 0 1 2 4 6 # Short-Description: start and stop php-fpm ### END INIT INFO # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 phpfpm="/usr/local/php/sbin/php-fpm" prog=$(basename ${phpfpm}) lockfile=/var/lock/subsys/phpfpm start() { [ -x ${phpfpm} ] || exit 5 echo -n $"Starting $prog: " daemon ${phpfpm} retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc ${phpfpm} -HUP RETVAL=$? echo } force_reload() { restart } configtest() { ${phpfpm} -t } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; status) rh_status ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|configtest}" exit 2 esac [root@test /opt/php-5.3.29]# /etc/init.d/fpm start Starting php-fpm: [ OK ] [root@test /opt/php-5.3.29]# ps -ef | grep php-fpm root 9473 1 0 18:04 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf) nobody 9474 9473 0 18:04 ? 00:00:00 php-fpm: pool www nobody 9475 9473 0 18:04 ? 00:00:00 php-fpm: pool www [root@test /opt/php-5.3.29]# /etc/init.d/fpm stop Stopping php-fpm: [ OK ] 3. 测试web和数据库链接web测试代码和mysql测试代码 [root@test /usr/local/nginx/html]# cat t.php <?php phpinfo(); ?> [root@test /usr/local/nginx/html]# cat m.php <?php $link=mysql_connect("localhost","root","【你的mysql账户密码】"); if(!$link) echo "FAILD!连接错误,用户名密码不对"; else echo "OK!可以连接"; ?>
测试通过!!!
|
2022-08-17
2022-11-06
2022-07-29
2022-08-18
2022-08-13
请发表评论