|
配置篇
一、配置nginx支持phpcp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak#备份原有配置文件vi/etc/nginx/nginx.conf #编辑user nginx nginx; #修改nginx运行账号为:nginx组的nginx用户:wq #保存退出cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak #备份原有配置文件vi /etc/nginx/conf.d/default.conf #编辑
index index.php index.html index.htm; #增加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行的参数,/scripts$fastcgi_script_name改为$document_root$fastcgi_script_name,或者使用绝对路径,要不然浏览器访问,不能解析,会显示“ File notfound.”service nginx restart #重启nginx
二、php配置vi /etc/php.ini #编辑date.timezone = PRC #在946行 把前面的分号去掉,改为date.timezone = PRC
1
2
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-fpmcp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak #备份原有配置文件vi /etc/php-fpm.d/www.conf #编辑user = nginx #修改用户为nginxgroup = nginx #修改组为nginx:wq #保存退出
三、配置phpmyadmin
下载phpmyadmin到/usr/share/nginx/html下
然后解压访问,会出现
phpMyAdmin– ErrorCannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.的提示
我们可以从错误提示看到,php没有正确保存session。导致上面的错误提示个人认为原因在于没有给php正确设置session的临时目录导致。
在php.ini文件搜索查找
session.save_path
php.ini文件中显示 session.save_path = “N;/path”
需要将它修改为
session.save_path = "/var/lib/php/session"
修改/var/lib/php/session目录的所有权和属主
chown -R nobody:nobody /var/lib/php/session
修改此目录的属主为nobody
解决登录问题还应该修改/var/lib/php/session目录权限
chmod 777 /var/lib/php/session
然后重新启动php和nginx到服务即可正常登录phpMyAdmin,
phpmyadmin需要配置权限为755,不然会提示配置错误
好了。开始享受LNMP吧 |
|