關閉防禦牆等php
systemctl stop firewalld.service systemctl disable firewalld.service firewall-cmd --state sed -i '/^SELINUX=.*/c SELINUX=disabled' /etc/selinux/config sed -i 's/^SELINUXTYPE=.*/SELINUXTYPE=disabled/g' /etc/selinux/config setenforce 0 mkdir -p /app/pack mkdir /app/service
安裝epel源mysql
yum -y install epel-release
安裝PHP可能用到的依賴包等linux
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel -y yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y yum -y install libmcrypt-devel mhash #非必須 cd /app/pack #有個包會安裝不上,由於源裏並無,故手動安裝 wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz tar xf libiconv-1.16.tar.gz -C /app/service/ cd /app/service/libiconv-1.16/ ./configure --prefix=/app/libiconv make && make install
下載安裝PHPnginx
cd /app/pack wget http://mirrors.sohu.com/php/php-7.2.4.tar.gz tar xf php-7.2.4.tar.gz cd php-7.2.4 ./configure --prefix=/app/service/php-7.2.4 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/app/service/libiconv-1.16 --with-freetype-dir --with-jpeg-dir --with-libxml-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbstring --enable-fpm --enable-mbregex --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 make && make install 會持續漫長的過程,建議進行完後 輸入 echo $?
修改部分PHP的配置sql
cd /app/pack/php-7.2.4 ls php.ini-* php.ini-development php.ini-production development是測試版開發版,production 生產版,兩個的區別是 測試版裏面是打開報錯提示的 咱們將使用測試版, cp php.ini-development /app/service/php/lib/php.ini cd /app/service/php/etc/ ls pear.conf php-fpm.conf.default php-fpm.d cp php-fpm.conf.default php-fpm.conf cd php-fpm.d cp www.conf.default www.conf /app/service/php/sbin/php-fpm 啓動php
測試 PHPapp
vi /app/service/nginx/nginx.conf http { include mime.types; default_type application/octet-stream; include /app/service/nginx/conf.d/*; #添加這一行 mkdir -p /app/service/nginx/conf.d vi /app/service/nginx/conf.d/php.conf server { echo "mysql listen IP/域名:80; server_name php.test.php; root /test; location ~ \.php$ { root /test; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } } mkdir /test echo "<?php phpinfo(); ?>" > /test/test_info.php
網頁訪問curl
IP/域名/test_info.php 注意測試頁面完成後必定要刪除頁面