1、
PHP lib库安装
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
验证rpm -qa zlib-devel libxml2-devel libjpeg-turbo-devel libiconv-devel rpm -qa freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
下载libiconv包wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz #一样寻常速率很慢,提早
下载传下去
好一些。 cd /server/tools/ 上传libiconv-1.16.tar.gz
安装
libiconv包tar zxf libiconv-1.16.tar.gz cd libiconv-1.16 ./configure --prefix=/application/libiconv make make install cd ../
依赖安装
yum install libmcrypt-devel -y yum install mhash -y yum install mcrypt -y
epel源安装
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2、
PHP下载php-7.3.5.tarphp-7.3.5.tar.gz wget https://www.php.net/distributions/php-7.3.5.tar.gz cd /server/tools/ tar xf php-7.3.5.tar.gz cd php-7.3.5/
3、
PHP编译安装
./configure \--prefix=/application/php-7.3.5 \--enable-mysqlnd \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-iconv-dir=/application/libiconv \--with-freetype-dir \--with-jpeg-dir \--with-png-dir \--with-zlib \--with-libxml-dir=/usr \--enable-xml \--disable-rpath \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--with-curl \--enable-mbregex \--enable-fpm \--enable-mbstring \--with-gd \--with-openssl \--with-mhash \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-soap \--enable-short-tags \--enable-static \--with-xsl \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-ftp \--enable-opcache=no
4、
安装
实现
5、
将nginx的用户以及
PHP的用户同一:(nginx)[root@web02 /server/tools/php-7.3.5]# useradd nginx -u 1111 -s /sbin/nologin -M [root@web02 /server/tools/php-7.3.5]# id nginx uid=1111(nginx) gid=1111(nginx) 组=1111(nginx) [root@web02 /server/tools/php-7.3.5]# vim /application/nginx/conf/nginx.conf worker_processes 1; user nginx nginx;(编译的时间就改用nginx)
6、
创立
软毗连[root@web02 ~]# ln -s /application/php-7.3.5/ /application/php [root@web02 ~]# ls /application/php/ bin etc include lib php sbin var
7、
配置
PHP剖析器配置
php.ini(PHP剖析器配置
文件) [root@web02 /application/php]# cd /server/tools/php-7.3.5/ [root@web02 /server/tools/php-7.3.5]# ls php.ini-* php.ini-development php.ini-production [root@web02 /server/tools/php-7.3.5]# cp php.ini-development /application/php/lib/php.ini [root@web02 /server/tools/php-7.3.5]# ls -l /application/php/lib/php.ini -rw-r--r-- 1 root root 71648 5月 6 11:51 /application/php/lib/php.ini
8、
配置
PHP FPM[root@web02 /server/tools/php-7.3.5]# cd /application/php/etc/ [root@web02 /application/php/etc]# ls pear.conf php-fpm.conf.default php-fpm.d [root@web02 /application/php/etc]# cp php-fpm.conf.default php-fpm.conf [root@web02 /application/php/etc]# cd php-fpm.d/ [root@web02 /application/php/etc/php-fpm.d]# ls www.conf.default [root@web02 /application/php/etc/php-fpm.d]# cp www.conf.default www.conf [root@web02 /application/php/etc/php-fpm.d]# ls www.conf www.conf.default
9、
启动PHP效力
[root@web02 /application/php/etc/php-fpm.d]# /application/php/sbin/php-fpm [root@web02 /application/php/etc/php-fpm.d]# netstat -lntup|grep php-fpm tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 12214/php-fpm: mast
十、
开机自启动[root@web02 /application/php/etc/php-fpm.d]# tail -2 /etc/rc.local /application/nginx/sbin/nginx /application/php/sbin/php-fpm
十1、
配置
nginx转发PHP乞求
办法
一: 乐成的配置
:[root@web02 /application/nginx/conf]# vim nginx.conf
location ~ .*\.(php|php5)?$ { root html/blog; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; }
办法
二: 乐成的配置
:[root@web02 /application/nginx/conf]# vim nginx.conf
server { listen 80; server_name blog.etiantian.org; location / { root html/blog; index index.html index.htm; } location ~ .*\.(php|php5)?$ { root html/blog; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } }
编写测试文件[root@web02 /application/nginx/conf]# echo "" > ../html/blog/test_info.php [root@web02 /application/nginx/conf]# cat ../html/blog/test_info.php
当地假造机测试:[root@web02 /application/nginx/conf]# /application/php/bin/php /application/nginx/html/blog/test_info.php
nginx校验:[root@web02 /application/nginx/conf]# nginx -t nginx: the configuration file /application/nginx-1.16.0//conf/nginx.conf syntax is ok nginx: configuration file /application/nginx-1.16.0//conf/nginx.conf test is successful [root@web02 /application/nginx/conf]# nginx -s reload
测试PHP毗连mysql[root@web02 /application/nginx/html/blog]# vim /application/nginx/html/blog/test_mysql.php
当地假造机测试毗连MySQL[root@web02 /application/nginx/html/blog]# /application/php/bin/php /application/nginx/html/blog/test_mysql.php mysql successful by zhangweibin.
12、
配置
win中的hosts文件,并到赞赏
器访问
测试。http://blog.etiantian.org/test_mysql.php LNMP环境搭建乐成。
来源:https://www.jianshu.com/p/12bc4623e34d 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |