停止apache:
1 2 |
chkconfig httpd off service httpd stop |
安装nginx : http://blog.csdn.net/lane_l/article/details/20235909
1 2 |
yum -y install nginx php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt /etc/init.d/nginx start / service nginx restart |
1 2 |
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak vim /etc/nginx/nginx.conf |
1 |
user nginx nginx; #修改nginx运行账号为:nginx组的nginx用户 |
1 2 |
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak vim /etc/nginx/conf.d/default.conf |
——————————————修改成
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#listen [::]:80 default_server; #要注释掉 location / { root /usr/share/nginx/html; index index.php index.html index.htm; } location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } |
配置php
1 2 |
cp /etc/php.ini /etc/php.ini.bak vi /etc/php.ini #编辑 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
date.timezone= PRC #在946行 把前面的分号去掉,改为date.timezone = PRC disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec ,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink ,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen ,disk_free_space,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 #在386行 列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。 expose_php = Off #在432行 禁止显示php版本的信息 magic_quotes_gpc = On #在745行 打开magic_quotes_gpc来防止SQL注入 open_basedir = .:/tmp/ #在380行,设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站,如果改了之后安装程序有问题,可注销此行,或者直接写上程序目录路径/var/www/html/www.osyunwei.com/:/tmp/ |
1 2 |
cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak vim /etc/php-fpm.d/www.conf |
1 2 |
user = nginx #修改用户为nginx group = nginx #修改组为nginx |
启动php-fpm
1 2 |
etc/rc.d/init.d/php-fpm start chkconfig php-fpm on |
1 2 |
cd /usr/share/nginx/html vim info.php |
1 2 3 |
<?php phpinfo(); ?> |
访问:http://……………/info.php 可以查看表示成功
开机启动:
1 |
chkconfig nginx on |
配置根站点:
1 |
vim /etc/nginx/conf.d/default.conf |
修改location的root为:/home/dev/php/wordpress
配置针对wordpress的伪静态:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
location / { root /home/dev/php/wordpress; index index.php index.html index.htm; if (-f $request_filename/index.html){ rewrite (.*) $1/index.html break; } if (-f $request_filename/index.php){ rewrite (.*) $1/index.php; } if (!-f $request_filename){ rewrite (.*) /index.php; } } location ~ \.php$ { root /home/dev/php/wordpress; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #include fastcgi.conf; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } |
仔细瞧瞧再说!