標籤:kill make nat mat log htm tco timezone nginx
簡介:
PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本前置處理器”)是一種通用開源指令碼語言。文法吸收了C語言、Java和Perl的特點,利於學習,使用廣泛,主要適用於Web開發領域。
需要安裝以下安裝包:(可以使用網路yum源安裝,本教程大部分使用下載的源碼安裝進行編譯安裝)
標註:首先配置網路yum源線上安裝以下四個php依賴包,配置網路yum源教程:
http://www.cnblogs.com/zoulongbin/p/5773330.html
[[email protected] src]# yum -y install libcurl-devel (必須安裝)
[[email protected] src]# yum -y install libXpm-devel (必須安裝)
[[email protected] src]# yum -y install libxml2-devel (必須安裝)
[[email protected] src]# yum -y install php-mbstring (自行選擇安裝)
標註:下載的軟體安裝包統一存放路徑在 /usr/local/src 目錄下進行解壓編譯安裝
1、 安裝yasm
:http://www.tortall.net/projects/yasm/releases/
[[email protected] src]# cd yasm-1.3.0
[[email protected] yasm-1.3.0]# ./configure
[[email protected] yasm-1.3.0]# make
[[email protected] yasm-1.3.0]# make install
2、 安裝libmcrypt
:https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/
[[email protected] src]# cd libmcrypt-2.5.8
[[email protected] libmcrypt-2.5.8]# ./configure
[[email protected] libmcrypt-2.5.8]# make
[[email protected] libmcrypt-2.5.8]# make install
3、 安裝libvpx
: http://www.linuxfromscratch.org/blfs/view/svn/multimedia/libvpx.html
[[email protected] src]# cd libvpx-1.6.0
[[email protected] libvpx-1.6.0]#./configure --prefix=/usr/local/libvpx --enable-shared --enable-vp9
[[email protected] libvpx-1.6.0]# make
[[email protected] libvpx-1.6.0]# make install
4、 安裝tiff
: http://download.osgeo.org/libtiff/
[[email protected] src]# cd tiff-4.0.6
[[email protected] tiff-4.0.6]#./configure --prefix=/usr/local/tiff --enable-shared
[[email protected] tiff-4.0.6]# make
[[email protected] tiff-4.0.6]# make install
5、 安裝libpng
:http://www.libpng.org/pub/png/libpng.html
[[email protected] src]# cd libpng-1.6.28
[[email protected] libpng-1.6.28]#./configure --prefix=/usr/local/libpng --enable-shared
[[email protected] libpng-1.6.28]# make
[[email protected] libpng-1.6.28]# make install
6、 安裝freetype
:http://ring.u-toyama.ac.jp/archives/graphics/freetype/freetype2/
[[email protected] src]# cd freetype-2.7.1
[[email protected] freetype-2.7.1]#./configure --prefix=/usr/local/freetype --enable-shared
[[email protected] freetype-2.7.1]# make
[[email protected] freetype-2.7.1]# make install
7、 安裝jpeg
:http://www.ijg.org/files/
[[email protected] src]# cd jpeg-9a
[[email protected] jpeg-9a]#./configure --prefix=/usr/local/jpeg --enable-shared
[[email protected] jpeg-9a]# make
[[email protected] jpeg-9a]# make install
8、 安裝libgd
:https://github.com/libgd/libgd/releases
[[email protected] src]# cd libgd-2.2.0
[[email protected] libgd-2.2.0]#./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-webp=/usr/local/libwebp/
[[email protected] libgd-2.2.0]# make
[[email protected] libgd-2.2.0]# make install
9、 安裝t1lib
:http://download.csdn.net/download/sunkaivg/9696064
[[email protected] src]# cd t1lib-5.1.2
[[email protected] t1lib-5.1.2]#./configure --prefix=/usr/local/t1lib --enable-shared
[[email protected] t1lib-5.1.2]# make without_doc
[[email protected] t1lib-5.1.2]# make install
10、 安裝php
:http://www.php.net/downloads.php
[[email protected] src]# ls
php-7.1.0 php-7.1.0.tar.gz
[[email protected] src]# pwd
/usr/local/src
[[email protected] src]# cd php-7.1.0
[[email protected] php-7.1.0]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-pdo-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 --with-png-dir=/usr/local/libpng --with-jpeg-dir=/usr/local/jpeg --with-freetype-dir=/usr/local/freetype --with-xpm-dir=/usr/ --with-zlib-dir=/usr/local/zlib --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
[[email protected] php-7.1.0]# make
[[email protected] php-7.1.0]# make install
11、配置PHP
[[email protected] src]# pwd
/usr/local/src
[[email protected] src]# ls
php-7.1.0 php-7.1.0.tar.gz
[[email protected] src]# cd php-7.1.0
[[email protected] php-7.1.0]# cp php.ini-production /usr/local/php/etc/php.ini
[[email protected] php-7.1.0]# rm -rf /etc/php.ini
[[email protected] php-7.1.0]# ln -s /usr/local/php/etc/php.ini /etc/php.ini
[[email protected] php-7.1.0]# ls -l /etc/php.ini
lrwxrwxrwx 1 root root 26 Jan 6 02:22 /etc/php.ini -> /usr/local/php/etc/php.ini
[[email protected] php-7.1.0]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[[email protected] php-7.1.0]#ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf
[[email protected] php-7.1.0]# vim /usr/local/php/etc/php-fpm.conf
:wq! 退出並儲存
[[email protected] php-7.1.0]# cd /usr/local/php/etc/php-fpm.d/
[[email protected] php-fpm.d]# ls
www.conf.default
[[email protected] php-fpm.d]# cp www.conf.default www.conf
[[email protected] php-fpm.d]# ls
www.conf www.conf.default
[[email protected] php-fpm.d]# pwd
/usr/local/php/etc/php-fpm.d
[[email protected] php-fpm.d]# vim www.conf
:wq! #儲存退出
12、設定php-fpm開機自啟動
[[email protected] ~]# cp /usr/local/src/php-7.1.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] ~]# ls -l /etc/init.d/php-fpm
-rw-r--r-- 1 root root 2401 Jan 6 20:58 /etc/init.d/php-fpm
[[email protected] ~]# chmod 755 /etc/init.d/php-fpm
[[email protected] ~]# ls -l /etc/init.d/php-fpm
-rwxr-xr-x 1 root root 2401 Jan 6 20:58 /etc/init.d/php-fpm
[[email protected] ~]# chkconfig php-fpm on
[[email protected] ~]# chkconfig --list php-fpm
php-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[email protected] ~]# vim /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
找到: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緩衝功能 (在文本按Shift+G就能跳到最後一行)
:wq! #儲存退出
13、配置nginx支援php
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf
user www www;
#首行user去掉注釋,修改Nginx運行組為www www;必須與/usr/local/php/etc/php-fpm.d/www.conf中的user,group配置相同,否則php運行出錯
location / {
root html;
index index.html index.htm index.php; #添加index.php
}
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,或者使用絕對路徑
:wq! #退出並儲存
[[email protected] php-fpm.d]# /etc/init.d/nginx restart
[[email protected] php-fpm.d]# /etc/init.d/php-fpm start
14、測試php配置
[[email protected] ~]# cd /usr/local/nginx/html/
[[email protected] html]# ls
50x.html index.html
[[email protected] html]# rm -rf /usr/local/nginx/html/*
[[email protected] html]# pwd
/usr/local/nginx/html
[[email protected] html]# vim index.php
<?php
phpinfo();
?>
:wq! 儲存並退出
[[email protected] html]# chown www.www /usr/local/nginx/html/ -R
[[email protected] html]# chmod 755 /usr/local/nginx/html/ -R
開啟瀏覽器輸入伺服器IP地址,會看到下面的介面就是php安裝成功
Linux 系統安裝配置PHP服務