编译安装Nginx1.10.1-7.2.1511-CentOS-PHP5.6.26运行环境-MySQL5.6.33

技术教程 2026-01-08 21:18:32 浏览

三、安装php 1、安装yasmcd /usr/local/srctar zxvf yasm-1.3.0.tar.gzcd yasm-1.3.0./configuremakemake install2、安装liBMCryptcd /usr/local/srctar zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8./configuremakemake install3、安装libvpxcd /usr/local/srctar xvf libvpx-1.6.0.tar.bz2cd libvpx-1.6.0./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9makemake install4、安装tiffcd /usr/local/srctar zxvf tiff-4.0.6.tar.gzcd tiff-4.0.6./configure --prefix=/usr/local/tiff --enable-sharedmakemake install5、安装libpngcd /usr/local/srctar zxvf libpng-1.6.25.tar.gzcd libpng-1.6.25./configure --prefix=/usr/local/libpng --enable-sharedmakemake install6、安装freetypecd /usr/local/srctar zxvf freetype-2.7.tar.gzcd freetype-2.7./configure --prefix=/usr/local/freetype --enable-sharedmake #编译make install #安装7、安装jpegcd /usr/local/srctar zxvf jpegsrc.v9b.tar.gzcd jpeg-9b./configure --prefix=/usr/local/jpeg --enable-sharedmake #编译make install #安装8、安装libgdcd /usr/local/srctar zxvf libgd-2.1.1.tar.gz #解压cd libgd-2.1.1 #进入目录./configure --prefix=/usr/local/libgd --enable-shared --with-jpeg=/usr/local/jpeg --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype --with-fontconfig=/usr/local/freetype --with-xpm=/usr/ --with-tiff=/usr/local/tiff --with-vpx=/usr/local/libvpx/ #配置make #编译make install #安装说明:如果libgd编译失败,可以先跳过,直接使用系统默认的2.1.0版本,在编译php的时候把参数--with-gd=/usr/local/libgd修改为--with-gd即可。9、安装t1libcd /usr/local/srctar zxvf t1lib-5.1.2.tar.gzcd t1lib-5.1.2./configure --prefix=/usr/local/t1lib --enable-sharedmake without_docmake install 10、安装php 注意:如果系统是64位,请执行以下两条命令,否则安装php会出错(32位系统不需要执行)\cp -frp /usr/lib64/libltdl.so* /usr/lib/\cp -frp /usr/lib64/libxpm.so* /usr/lib/cd /usr/local/srctar -zvxf php-5.6.26.tar.gzcd php-5.6.26export ld_library_path=/usr/local/libgd/lib./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd=/usr/local/libgd --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/lib64 --with-vpx-dir=/usr/local/libvpx/ --with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype #配置make #编译make install #安装如果编译错误,可以清理后在编译一次make clean #清理make #编译cp php.ini-production /usr/local/php/etc/php.ini #复制php配置文件到安装目录rm -rf /etc/php.ini #删除系统自带配置文件ln -s /usr/local/php/etc/php.ini /etc/php.ini #添加软链接到 /etc目录cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf #添加软连接到 /etc目录vi /usr/local/php/etc/php-fpm.conf #编辑User = www #设置php-fpm运行账号为wwwgroup = www #设置php-fpm运行组为wwwpid = run/php-fpm.pid #取消前面的分号:wq! #保存退出设置 php-fpm开机启动cp /usr/local/src/php-5.6.26/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限chkconfig php-fpm on #设置开机启动vi /usr/local/php/etc/php.ini #编辑配置文件找到:disable_functions =修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname#列出php可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。找到:;date.timezone =修改为:date.timezone = prc #设置时区找到:expose_php = on修改为:expose_php = off #禁止显示php版本的信息找到:short_open_tag = off修改为:short_open_tag = on #支持php短标签找到opcache.enable=0修改为opcache.enable=1 #php支持opcode缓存找到:;opcache.enable_cli=1 #php支持opcode缓存修改为:opcache.enable_cli=0在最后一行添加:zend_extension=opcache.so #开启opcode缓存功能:wq! #保存退出 编译安装 配置nginx支持php vi /usr/local/nginx/conf/nginx.conf修改/usr/local/nginx/conf/nginx.conf 配置文件,需做如下修改user www www; #首行user去掉注释,修改nginx运行组为www www;必须与/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错index index.html index.htm index.php; #添加index.php# pass the php scripts to fastcgi server listening on 127.0.0.1:9000#location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param script_filename $document_root$fastcgi_script_name;include fastcgi_params;}#取消fastcgi server部分location的注释,注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径/etc/init.d/nginx restart #重启nginxservice php-fpm start #启动php-fpm测试篇cd /usr/local/nginx/html/ #进入nginx默认网站根目录rm -rf /usr/local/nginx/html/* #删除默认测试页vi index.php #新建index.php文件

本文版权声明本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请联系本站客服,一经查实,本站将立刻删除。

发表评论

热门推荐