1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
| 10、安装php
#注意:如果系统是64位,请执行以下两条命令,否则安装php会出错(32位系统不需要执行)
[iyunv@domain t1lib-5.1.2]# \cp -frp /usr/lib64/libltdl.so* /usr/lib/
[iyunv@domain t1lib-5.1.2]# \cp -frp /usr/lib64/libXpm.so* /usr/lib/
[iyunv@domain t1lib-5.1.2]# cd /usr/local/src
[iyunv@domain src]# tar zxvf php-5.6.3.tar.gz
[iyunv@domain src]# cd php-5.6.3
[iyunv@domain php-5.6.3]# export LD_LIBRARY_PATH=/usr/local/libgd/lib
[iyunv@domain php-5.6.3]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc
--with-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-vpx-dir=/usr/local/libvpx/
--with-zlib-dir=/usr/local/zlib --with-t1lib=/usr/local/t1lib --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
[iyunv@domain php-5.6.3]# make
[iyunv@domain php-5.6.3]# make install
[iyunv@domain php-5.6.3]# cp php.ini-production /usr/local/php/etc/php.ini #复制php配置文件到安装目录
[iyunv@domain php-5.6.3]# rm -rf /etc/php.ini #删除系统自带配置文件
[iyunv@domain php-5.6.3]# ln -s /usr/local/php/etc/php.ini /etc/php.ini #添加软链接到 /etc目录
[iyunv@domain php-5.6.3]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件
[iyunv@domain php-5.6.3]# ln -s /usr/local/php/etc/php-fpm.conf /etc/php-fpm.conf #添加软连接到 /etc目录
[iyunv@domain php-5.6.3]# vim /usr/local/php/etc/php-fpm.conf #编辑
user = www #设置php-fpm运行账号为www
group = www #设置php-fpm运行组为www
pid = run/php-fpm.pid #取消前面的分号
#设置php-fpm开机启动
[iyunv@domain php-5.6.3]# cp /usr/local/src/php-5.6.3/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录
[iyunv@domain php-5.6.3]# chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限
[iyunv@domain php-5.6.3]# chkconfig php-fpm on #设置开机启动
[iyunv@domain php-5.6.3]# 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
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;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=0 #php支持opcode缓存
修改为:opcache.enable_cli=1
在最后一行添加:zend_extension=opcache.so #开启opcode缓存功能
[iyunv@domain php-5.6.3]# vim /usr/local/nginx/conf/nginx.conf
user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
index index.html index.htm index.php; #添加index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
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,或者使用绝对路径
[iyunv@domain php-5.6.3]# service nginx restart
[iyunv@domain php-5.6.3]# service php-fpm start
[iyunv@domain php-5.6.3]# cd /usr/local/nginx/html
[iyunv@domain html]# rm -rf *
[iyunv@domain html]# vim index.php
<?
phpinfo();
?>
[iyunv@domain html]# chown -R www.www /usr/local/nginx/html
[iyunv@domain html]# chmod 700 /usr/local/nginx/html/ -R
至此,CentOS6.6 源码安装配置LNMP架构完毕,在浏览器输入对应的IP地址或域名访问测试
|