下面的是參考https://typecodes.com/ 過(guò)了一遍,和前面的nginx 連接 測(cè)試沒(méi)有問(wèn)題。 與MySQL連接的時(shí)候,注意參數(shù) --with-mysql-sock=/var/run/mysql/mysql.sock,需要和mysql里面設(shè)置的是一樣。 yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel groupadd -r php && useradd -r -g php -s /bin/false -d /usr/local/php7 -M php cd /usr/local/src wget http://au1.php.net/distributions/php-7.1.1.tar.gz
tar zxvf php-7.1.1.tar.gz cd php-7.1.1 ./configure \ --prefix=/usr/local/php7 \ --exec-prefix=/usr/local/php7 \ --bindir=/usr/local/php7/bin \ --sbindir=/usr/local/php7/sbin \ --includedir=/usr/local/php7/include \ --libdir=/usr/local/php7/lib/php \ --mandir=/usr/local/php7/php/man \ --with-config-file-path=/usr/local/php7/etc \ --with-mysql-sock=/var/run/mysql/mysql.sock \ --with-mcrypt=/usr/include \ --with-mhash \ --with-openssl \ --with-mysql=shared,mysqlnd \ --with-mysqli=shared,mysqlnd \ --with-pdo-mysql=shared,mysqlnd \ --with-gd \ --with-iconv \ --with-zlib \ --enable-zip \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-mbregex \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-curl \ --with-jpeg-dir \ --with-freetype-dir \ --enable-opcache \ --enable-fpm \ --enable-fastcgi \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --without-gdbm \ --disable-fileinfo make && make install make test ##不是必須 ll /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/
直接使用編譯后未經(jīng)優(yōu)化處理的配置 cp php.ini-production /usr/local/php7/etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
修改配置文件 vim /usr/local/php7/etc/php.ini ######避免PHP信息暴露在http頭中 expose_php = Off ######避免暴露php調(diào)用mysql的錯(cuò)誤信息 display_errors = Off ######在關(guān)閉display_errors后開(kāi)啟PHP錯(cuò)誤日志(路徑在php-fpm.conf中配置) log_errors = On ######設(shè)置PHP的擴(kuò)展庫(kù)路徑 extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/" ######設(shè)置PHP的opcache和mysql動(dòng)態(tài)庫(kù) zend_extension=opcache.so extension=mysqli.so extension=pdo_mysql.so ######設(shè)置PHP的時(shí)區(qū) date.timezone = PRC ######開(kāi)啟opcache [opcache] opcache.enable=1 ######設(shè)置PHP腳本允許訪(fǎng)問(wèn)的目錄(需要根據(jù)實(shí)際情況配置) open_basedir = /etc/nginx/html;
vim /usr/local/php7/etc/php-fpm.conf ######設(shè)置錯(cuò)誤日志的路徑 error_log = /var/log/php-fpm/error.log ######引入www.conf文件中的配置 include=/usr/local/php7/etc/php-fpm.d/*.conf
vim /usr/local/php7/etc/php-fpm.d/ ######設(shè)置用戶(hù)和用戶(hù)組 user = nginx group = nginx ######根據(jù)nginx.conf中的配置fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;設(shè)置PHP監(jiān)聽(tīng) ; listen = 127.0.0.1:9000 #####不建議使用(看自己設(shè)置情況) listen = /var/run/php-fpm/php-fpm.sock ######開(kāi)啟慢日志 slowlog = /var/log/php-fpm/$pool-slow.log request_slowlog_timeout = 10s ######設(shè)置php的session目錄(所屬用戶(hù)和用戶(hù)組都是nginx) php_value[session.save_handler] = files php_value[session.save_path] = /var/lib/php/session
echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n' >> /etc/profile && source /etc/profile mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm mkdir -p /var/lib/php/session chown -R nginx:nginx /var/lib/php chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm chkconfig php-fpm on php-fpm -t service php-fpm start ps -aux | grep php ##php-fpm進(jìn)程數(shù)和進(jìn)程用戶(hù)nginx都是由www.conf中pm.start_servers和user的值分別決定的 root 26007 0.0 0.0 182016 6324 ? Ss 13:36 0:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf) nginx 26008 0.0 0.0 182016 5884 ? S 13:36 0:00 php-fpm: pool www nginx 26009 0.0 0.0 182016 5884 ? S 13:36 0:00 php-fpm: pool www
測(cè)試 <?php phpinfo(); ?>
文章名稱(chēng):php7.1.1一鍵安裝/配置文件簡(jiǎn)單優(yōu)化
文章起源:http://aaarwkj.com/article14/pchpde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、響應(yīng)式網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)公司、網(wǎng)站內(nèi)鏈、網(wǎng)站維護(hù)、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)