1.安装依赖于函数库
[root@lnmp ~]
-rw-r--r--. 1 root root 4984397 Aug 4 03 : 16 libiconv-1.14 .tar.gz
-rw-r--r--. 1 root root 15008639 Aug 4 00 : 29 php-5.3 .27 .tar.gz
[root@lnmp ~]
libpng gd zlib-devel libxml2-devel libjpeg-devel freetype-devel \
libpng-devel gd-devel curl-devel libxslt-devel openssl-devel -y
[root@lnmp ~]
[root@lnmp ~]
[root@lnmp libiconv-1.14 ]
[root@lnmp libiconv-1.14 ]
2.安装PHP
2.1解压php安装包
[root@lnmp ~]
[root@lnmp ~]
2.2编译PHP
[ - . . ] . - -
- - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
- - - - - - - - - - -
[ - . . ]
[ - . . ] -
3.配置PHP
3.1修改配置文件
[root@nginx php-5.3 .27 ]# \cp php.ini-production /application/php/lib/php.ini
[root@nginx php-5.3 .27 ]# cd /application/php/
[root@nginx ~]# egrep -v "^$|^;" /application/php/etc/php-fpm.conf|cat -n
1 [global]
2 pid = /app/logs/php-fpm.pid
3 error_log = /app/logs/php-fpm.log
4 log_level = error
5
6 rlimit_files = 32768
7
8 events.mechanism = epoll
9 [www]
10 user = nginx
11 group = nginx
12 listen = 127.0 .0 .1 :9000
13 listen.owner = nginx
14 listen.group = nginx
15 pm = dynamic
16 pm.max _children = 1024
17 pm.start _servers = 16
18 pm.min _spare_servers = 5
19 pm.max _spare_servers = 20
20 pm.process _idle_timeout = 15 s
21 pm.max _requests = 2048
22 slowlog = /app/logs/$pool.log .slow
23 request_slowlog_timeout = 10
24 php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f 1093626742 @qq.com
3.2创建日志目录
[root@lnmp php]
3.3设置环境变量
[root@lnmp php]
3.4检查语法,启动php
[root@lnmp php]
[06 -Aug -2018 11 : 22 : 37 ] NOTICE : configuration file /usr/local/php/etc/php-fpm.conf test is successful
[root@lnmp php]
[root@lnmp php]
tcp 0 0 127.0 .0 .1 : 9000 0 .0 .0 .0 :* LISTEN 6625 /php-fpm
4.整合nginx与PHP
4.1修改nginx配置文件
[root@lnmp php]
10 server {
11 listen 80 ;
12 server_name www.liang.com;
13 root html/www;
14 index index .php index .html index .htm;
15 location ~ \.php$ {
16 root html/www;
17 fastcgi_pass 127.0 .0 .1 :9000 ;
18 fastcgi_index index .php;
19 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name ;
20 include fastcgi.conf;
21 }
22 }
4.2检查语法,启动nginx
[root@lnmp php]
nginx: the configuration file /usr/local /nginx-1.6 .2 /conf/nginx.conf syntax is ok
nginx: configuration file /usr/local /nginx-1.6 .2 /conf/nginx.conf test is successful
[root@lnmp php]
4.3编写php网页测试
[root@lnmp php]# cat /application/nginx/html/www/index.php
<?php
phpinfo();
?>
4.4网页查看
4.5测试mysql连接
[root@lnmp php]
<?php
//$link_id =mysql_connect('主机名' ,'用户' ,'密码' );
$link_id =mysql_connect('localhost' ,'root' ,'000000' ) or mysql_error();
if ($link_id ){
echo "mysql successful by https://blog.csdn.net/liang_operations!" ;
}else {
echo mysql_error();
}
?>