php技术博客
让天下没有搞不定的bug~

分享LNMP环境下一些重要php配置

vi /usr/local/php5/etc/php.ini #编辑配置文件
找到:;open_basedir =
修改为:open_basedir = .:/tmp/ #防止php木马跨站,重要!!

找到: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, osix_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,posi
x_uname
#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
找到:;date.timezone =
修改为:date.timezone = PRC #设置时区
找到:expose_php = On
修改为:expose_php = OFF #禁止显示php版本的信息
找到:display_errors = On
修改为:display_errors = OFF #关闭错误提示
七、配置nginx支持php
vi /usr/local/nginx/conf/nginx.conf
修改/usr/local/nginx/conf/nginx.conf 配置文件,需做如下修改
user www www; #首行user去掉注释,修改Nginx运行组为www www;必须与/usr/local/php5/etc/php-fpm.conf中的user,group配置相同,否则php运行出错
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行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
/etc/init.d/nginx restart #重启nginx
八、配置php支持Zend Guard
温馨提醒:qihang01原创内容版权所有,转载请注明出处及原文链接
安装Zend Guard
cd /usr/local/src
mkdir /usr/local/zend #建立Zend安装目录
tar xvfz ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz #解压安装文件
cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/ #拷贝文件到安装目录
vi /usr/local/php5/etc/php.ini #编辑文件
在最后位置添加以下内容
[Zend Guard]
zend_extension=/usr/local/zend/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
测试篇
cd /usr/local/nginx/html/ #进入nginx默认网站根目录
rm -rf /usr/local/nginx/html/* #删除默认测试页
vi index.php #新建index.php文件
<?php
phpinfo();
?>
:wq! #保存
chown www.www /usr/local/nginx/html/ -R #设置目录所有者
chmod 700 /usr/local/nginx/html/ -R #设置目录权限
shutdown -r now #重启
在客户端浏览器输入服务器IP地址,可以看到相关的配置信息!
service nginx restart #重启nginx
service mysqld restart #重启mysql
/usr/local/php5/sbin/php-fpm #启动php-fpm
/etc/rc.d/init.d/php-fpm restart #重启php-fpm
/etc/rc.d/init.d/php-fpm stop #停止php-fpm
/etc/rc.d/init.d/php-fpm start #启动php-fpm
#############################################################################
备注:
nginx默认站点目录是:/usr/local/nginx/html/
权限设置:chown www.www /usr/local/nginx/html/ -R
MySQL数据库目录是:/data/mysql
权限设置:chown mysql.mysql -R /data/mysql

技术分享,技术交流,小涛与您共同成长

赞(0)
未经允许不得转载:PHP技术博客 » 分享LNMP环境下一些重要php配置