CentOS 6.x下LNMP环境源码编译安装及配置(2)

yum install gcc-c++ gd libxml2-devel libjpeg-devel libpng-devel net-snmp-devel curl-devel libxslt-devel pcre-devel libjpeg libpng libxml2 libcurl4-openssl-dev libcurl-devel libcurl freetype-config freetype freetype-devel unixODBC libxslt -y

开始编译安装php-5.6.30

tar -zxf php-5.6.30.tar.gz cd php-5.6.30

./configure --prefix=/usr/local/php-5.6.30 --with-curl --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysql --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-freetype-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml && make && make install

从php源码包复制php.ini配置文件到php安装目录,并做系统的软连接

cp -a /root/php-5.6.30/php.ini-production /usr/local/php-5.6.30/etc/php.ini ln -s /usr/local/php-5.6.30/etc/php.ini /etc/php.ini

从php源码包复制php-fpm.conf配置文件到php安装目录,并做系统的软连接

cp -a /usr/local/php-5.6.30/etc/php-fpm.conf.default /usr/local/php-5.6.30/etc/php-fpm.conf ln -s /usr/local/php-5.6.30/etc/php-fpm.conf /etc/php-fpm.conf

修改php-fpm.conf配置参数

sed -i '25s/;//g' /usr/local/php-5.6.30/etc/php-fpm.conf

sed -i '303s/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,esca peshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,p osix_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,pos ix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkf ifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posi x_times,posix_ttyname,posix_uname/g' /usr/local/php-5.6.30/etc/php.ini

sed -i '936s/;date.timezone =/date.timezone = PRC/g' /usr/local/php-5.6.30/etc/php.ini

sed -i '151s/; short_open_tag/short_open_tag = ON/g' /usr/local/php-5.6.30/etc/php.ini

sed -i '1905s/;opcache.enable=0/opcache.enable=1/g' /usr/local/php-5.6.30/etc/php.ini

sed -i '1908s/;opcache.enable_cli=0/opcache.enable_cli=0/g' /usr/local/php-5.6.30/etc/php.ini

sed -i '$a zend_extension=opcache.so' /usr/local/php-5.6.30/etc/php.ini

sed -i '509s/;env[PATH] = /usr/local/bin:/usr/bin:/bin/env[PATH] = /usr/local/bin:/usr/bin:/bin/:/usr/local/php5.6.30/bin/g' /usr/local/php-5.6.30/etc/php-fpm.conf

复制php启动脚本

cp -a /root/php-5.6.30/sapi/fpm/php-fpm /etc/init.d/

启动php

/etc/init.d/php-fpm

查看9000端口

netstat -ntpl |grep "9000"

(停止php)

killall php-fpm

测试nginx+php

mkdir /opt/test echo "<?php Phpinfo(); ?>" > /opt/test/index.php

nginx配置

vim /usr/local/nginx/conf/conf.d/test.conf

server { listen 80; server_name 192.168.1.2; index index.php; root /opt/test; location / { try_files $uri $uri/ /index.php?$args; } location ~ ^(.+.php)(.*)$ { fastcgi_split_path_info ^(.+.php)(.*)$; include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info; } }

浏览器输入192.168.1.2查看php页面

LNMP环境搭建(Discuz论坛)   

Ubuntu 14.04下apt-get方法安装LNMP环境   

CentOS 7源码编译安装PHP5.6和Nginx1.7.9及MySQL(搭建LNMP环境)  

Ubuntu 14.04 LTS 安装 LNMP Nginx\PHP5 (PHP-FPM)\MySQL   

CentOS 6.8 编译安装LNMP 简述   

Ubuntu 16.04 下源码配置LNMP开发环境  

CentOS 7源码编译安装PHP5.6和Nginx1.7.9及MySQL(搭建LNMP环境)  

CentOS 7源码安装最新版LNMP环境  

CentOS 6.8 安装LNMP环境(Linux+Nginx+MySQL+PHP)    

Ubuntu系统下LNMP环境的搭建   

编译LNMP之Nginx+php-fpm   

Ubuntu 16.04 LTS下LNMP环境配置简述   

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/4d1c1b0eb6d2d691236a225973baf241.html