an installation article
1. Installing NginxYum check-update #更新yum源yum Remove httpd* php* #删除系统自带的软件包yum install Nginx #安装nginx Follow the prompts to enter Y for installation chkconfig nginx on #设置ngin X Boot service Nginx start #启动nginx
2. Install MySQLYum install MySQL mysql-server #安装mysql/etc/init.d/mysqld start #启动MySQLchkconfig mysqld on #设为开机启动cp/usr/share/mysql/ MY-MEDIUM.CNF/ETC/MY.CNF #拷贝配置文件etc/init.d/mysqld Restart #重启mysql
3. Installing PHP5Yum install PHP php-fpm #安装php及php-fpmyum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml ph P-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt #安装php相关模块chkconfig php-fpm on #设置php-fpm boot up/etc/ INIT.D/PHP-FPM Start #启动php-fpm
two configuration documentation
1. Configure Nginx support PHPCp/etc/nginx/nginx.conf/etc/nginx/nginx.confbak #备份原有配置文件vi/etc/nginx/nginx.conf #编辑user nginx; #修改nginx运行账号为: Nginx user of Nginx group 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:9000Location ~ \.php$ {root html; fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $do Cument_root$fastcgi_script_name; Include Fastcgi_params;}#取消FastCGI the comment for the server section location, and note the parameters of the Fastcgi_param line, change to $document_root$fastcgi_script_name, or use the absolute path service Nginx Restart #重启nginx
2. PHP ConfigurationVi/etc/php.ini #编辑Date.timezone = PRC #在946行 Remove the preceding semicolon and change to Date.timezone = PRCdisable_functions = Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini _alter,ini_alter,ini_restore,dl,ope Nlog,syslog,readlink,symlink,popepassthru,stream_socket_server, Escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdns Rr,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行 lists the functions that PHP can disable, and if some programs need to use this function, you can delete and cancel the disabled. expose_php = Off #在432行 Suppress the PHP version informationMAGIC_QUOTES_GPC = on #在745行 open MAGIC_QUOTES_GPC to prevent SQL injectionShort_open_tag = on #在229行支持php短标签Open_basedir =.:/ tmp/#在380行 settings means that the current directory (i.e. the directory where the php script file resides) and the/tmp/directory are allowed to prevent the PHP Trojan from cross-site
3. Configure PHP-FPMCp/etc/php-fpm.d/www.conf/etc/php-fpm.d/www.confbak #备份原有配置文件vi/etc/php-fpm.d/www.conf# Editoruser = Nginx #修改用户为nginxGroup = Nginx #修改组为nginx
three test articlesCd/usr/share/nginx/htmlvi index.php<?phpphpinfo ();?>Chown nginx.nginx/usr/share/nginx/html-r #设置权限service nginx restart #重启nginxservice php-fpm Restart #重启php-fpm Enter this in the browser Machine IP address test to see if the services are working properly.
CentOS 6.4 Installation Configuration Lnmp server (nginx+php+mysql)