- 论坛徽章:
- 3
|
6、安装php
cd /usr/local/src
tar -zvxf php-5.3.8.tar.gz
cd php-5.3.8
mkdir -p /usr/local/php5 #建立php安装目录
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-freetype --with-jpeg --with-png --with-zlib --with-libxml --enable-xml --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic --enable-suhosin --enable-session --with-mcrypt #配置
make #编译
make install #安装
cp php.ini-production /usr/local/php5/etc/php.ini #复制php配置文件到安装目录
rm -rf /etc/php.ini #删除系统自带配置文件
ln -s /usr/local/php5/etc/php.ini /etc/php.ini #添加软链接
cd /usr/local/php5/etc
cp php-fpm.conf.default php-fpm.conf
vi php-fpm.conf #编辑
pm.start_servers = 20 #取消前面的分号;
pm.min_spare_servers = 5
pm.max_spare_servers = 35
/usr/local/php5/sbin/php-fpm #启动php-fpm
设置 php-fpm开机启动
vi /etc/rc.d/init.d/php-fpm #新建启动文件,添加以下代码
##########################################################
#!/bin/sh
#chkconfig:345 62 62
#description:php-fpm
#
# php-fpm - this script starts and stops the php-fpm daemin
#
# chkconfig: - 85 15
# processname: php-fpm
# config: /usr/local/php/etc/php-fpm.conf
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="php-fpm daemon"
NAME=php-fpm
DAEMON=/usr/local/php5/sbin/php-fpm
CONFIGFILE=/usr/local/php5/etc/php-fpm.conf
PIDFILE=/usr/local/php5/var/run/php-fpm.pid
SCRIPTNAME=/etc/rc.d/init.d/php-fpm
# If the daemon file is not found, terminate the script.
test -x $DAEMON || exit 0
d_start(){
$DAEMON -y $CONFIGFILE || echo -n " already running"
}
d_stop(){
kill -QUIT `cat $PIDFILE` || echo -n " no running"
}
d_reload(){
kill -HUP `cat $PIDFILE` || echo -n " could not reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
d_reload
echo "Reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
# Sleep for two seconds before starting again, this should give the nginx daemon some time to perform a graceful stop
sleep 2
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload)" >&2
exit 3
;;
esac
exit 0
########################################################################################
chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限
chkconfig php-fpm on #设置开机启动
/etc/rc.d/init.d/php-fpm start #启动php-fpm
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, 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版本的信息
找到:display_errors = On
修改为:display_errors = OFF #关闭错误提示
7、安装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/ #拷贝文件到安装目录
8、配置php支持Zend Guard
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=
/etc/init.d/nginx restart #重启web服务器
9、配置nginx支持php
vi /usr/local/nginx/conf/nginx.conf
修改/usr/local/nginx/conf/nginx.conf 配置文件,需做如下修改
user nobody nobody; (首行user去掉注释,并与/usr/local/php5/etc/php-fpm.conf中的user,group配置同)
server {
listen 80; (修改所使用的端口)
server_name localhost; (修改所使用的服务器名)
index index.php index.html index.htm;
# 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
/etc/rc.d/init.d/php-fpm restart
=======================================================
service nginx restart #重启nginx
service mysqld restart #重启mysql
到此,Nginx+MySQL+PHP+Zend基本运行环境搭建完成!
网站程序上传到/usr/local/nginx/html目录里面,如果安装有问题,请检查目录权限,确保改目录为以下权限
chown nobody.nobody -R /usr/local/nginx/html
chmod 700 -R /usr/local/nginx/html
注意:如果要用于正式生产环境,还需要进一步详细的设置配置系统的安全等各个方面,安全设置不在本次教程的范围之内,请大家参考相关系统运行安全设置方面的教程!
http://www.osyunwei.com/archives/1098.html
|
|