先我们要准备配置环境的文件
Nginx 下载地址: http://nginx.org/download/nginx-1.3.14.zip
PHP 下载地址: http://windows.php.net/downloads/releases/php-5.2.17-nts-Win32-VC6-x86.zip
MySQL 下载地址:http://www.mysql.com/downloads/installer/
2、安装配置nginx:
解压nginx,修改配置文件:
代码如下 | 复制代码 |
server { listen 80; server_name localhost; #access_log d:/nginx/logs/acccess-ebiz.log; # proxy the PHP scripts to Apache listening on 127.0.0.1:80 location / { root D:wwwdede; index index.html index.htm index.php; autoindex on; } # location ~ .php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ .php$ { root D:wwwdede; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # #error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/nginx-default; } } |
2、安装配置php:
解压php到C盘:配置php.ini,在网上找了很多的配置文件,配置mysql和gd的时候都用问题,一下是dedecms的配置文件:
代码如下 | 复制代码 |
[PHP] engine = On expose_php = On zend.ze1_compatibility_mode = Off asp_tags = Off precision = 14 y2k_compliance = On implicit_flush = Off serialize_precision = 100 output_buffering = 4096 zlib.output_compression = Off ;default_charset = gb2312 default_mimetype = text/html safe_mode = Off safe_mode_gid = Off safe_mode_include_dir = safe_mode_exec_dir = safe_mode_allowed_env_vars = PHP_ safe_mode_protected_env_vars = LD_LIBRARY_PATH variables_order = "GPCS" auto_globals_jit = On magic_quotes_runtime = Off magic_quotes_sybase = Off register_long_arrays = Off register_argc_argv = Off ; ------------------------ ; 常用参数设置 ; ------------------------ max_execution_time = 3600 max_input_time = 3600 memory_limit = 128M disable_functions =exec,system,ini_alter,readlink,symlink,leak,proc_open, popepassthru,chroot,scandir,chgrp,chown,escapeshellcmd, escapeshellarg,shell_exec,proc_get_status,passthru,popen disable_classes = COM short_open_tag = On allow_call_time_pass_reference = On register_globals = Off magic_quotes_gpc = On ; ------------------------ ; 错误调试设置 ; ------------------------ display_errors = On error_reporting = E_ALL & ~E_NOTICE display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = Off ; ------------------------------ ; upload_tmp_dir 目录 ; ----------------------------- upload_tmp_dir = "C:/PHP5/tmp/uploads" file_uploads = On post_max_size = 64M upload_max_filesize = 64M allow_url_fopen = On allow_url_include = Off default_socket_timeout = 300 ; ------------------------------ ; extension_dir 扩展组件目录 ; ----------------------------- enable_dl = On extension_dir = "C:/PHP5/ext" extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_pdo.dll extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll extension=php_pdo_odbc.dll extension=php_pdo_sqlite.dll extension=php_sqlite.dll extension=php_xmlrpc.dll extension=php_xsl.dll extension=php_zip.dll [sqlite] sqlite.assoc_case = 0 [xmlrpc] xmlrpc_error_number = 0 xmlrpc_errors = 0 [Syslog] define_syslog_variables = Off [mail function] SMTP = localhost smtp_port = 25 [SQL] sql.safe_mode = Off [ODBC] odbc.allow_persistent = On odbc.check_persistent = On odbc.max_persistent = -1 odbc.max_links = -1 odbc.defaultlrl = 4096 odbc.defaultbinmode = 1 [MySQL] mysql.allow_persistent = On mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = mysql.default_socket = mysql.default_host = mysql.default_user = mysql.default_password = mysql.connect_timeout = 60 mysql.trace_mode = Off [Session] ; -------------------------- ; session文件默认保存目录 ; -------------------------- session.save_path = "C:/PHP5/tmp/sessions" session.save_handler = files session.use_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.cookie_httponly = session.serialize_handler = php session.gc_probability = 1 session.gc_divisor = 1000 session.gc_maxlifetime = 1440 session.bug_compat_42 = 0 session.bug_compat_warn = 1 session.referer_check = session.entropy_length = 0 session.entropy_file = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 session.hash_function = 0 session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" [MSSQL] mssql.allow_persistent = On mssql.max_persistent = -1 mssql.max_links = -1 mssql.min_error_severity = 10 mssql.min_message_severity = 10 mssql.compatability_mode = Off mssql.secure_connection = Off [mbstring] ;mbstring.language = Chinese ;mbstring.internal_encoding = GBK ;mbstring.http_input = auto ;mbstring.http_output = SJIS ;mbstring.encoding_translation = Off ;mbstring.detect_order = auto ;mbstring.substitute_character = none ;mbstring.func_overload = 0 ;mbstring.strict_encoding = Off [gd] gd.jpeg_ignore_warning = 0 [Zend] zend_extension_manager.optimizer_ts="C:/PHP5libOptimizer-3.3.0" zend_extension_ts="C:/PHP5libZendExtensionManager.dll" |
注意:是配置php支持mysql和gd
[Zend]
代码如下 | 复制代码 |
zend_extension_manager.optimizer_ts="C:/PHP5libOptimizer-3.3.0" zend_extension_ts="C:/PHP5libZendExtensionManager.dll" |
启动php:
代码如下 | 复制代码 |
RunHiddenConsole.exe C:PHP5php-cgi.exe -b 127.0.0.1:9000 -c C:PHP5php.ini |
linux版本
先卸载系统自带的apache
代码如下 | 复制代码 |
yum remove httpd |
2、安装mysql,设置密码等,
代码如下 | 复制代码 |
yum install wget #安装下载工具wget wget http://www.atomicorp.com/installers/atomic #下载atomic yum源 sh ./atomic #安装 yum check-update #更新yum软件包 |
安装nginx:
yum install nginx #安装nginx,根据提示,输入Y安装即可成功安装
代码如下 | 复制代码 |
#修改配置文件,这里省略,主要是将目录指定到 /home/ngmsw-files service nginx start #启动 chkconfig nginx on #设为开机启动 |
3、安装vsftpd:
代码如下 | 复制代码 |
yum install vsftpd # 按y安装成功 |
4、新建ftp用户:
useradd -d /home/ngmsw-files -M nmswxt_files
代码如下 | 复制代码 |
#设置密码, passwd nmswxt_files # 回车后 输入2次密码 #修改/etc/vsftpd/vsftpd.conf #注释掉 : #userlist_enable=YES #tcp_wrappers=YES # 用户指定到目录 chown nmswxt_files:nmswxt_files /home/nmswxt_files # 目录权限 chmod 777 -R /home/nmswxt_files |
如果还是出现 ftp用户无权限新增文件或者目录的情况,参考下面:
#
代码如下 | 复制代码 |
查看SELinux设置 getsebool -a|grep ftp #etsebool使用-P参数,无需每次开机都输入这个命令 setsebool -P ftp_home_dir 1 |
然后我们再
代码如下 | 复制代码 |
yum install mysql mysql-server |
3、安装nginx,如果yum安装不上可以参考:http://www.111cn.net/database/mysql/48960.htm
代码如下 | 复制代码 |
yum install nginx |
4、安装php及相关模块
代码如下 | 复制代码 |
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy #编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1 vi /etc/php.ini #启动php-fpm service php-fpm start |
相关nginx配置文件:
代码如下 | 复制代码 |
server { listen 80; server_name localhost; #access_log /var/nginx/logs/acccess-ebiz.log; # proxy the PHP scripts to Apache listening on 127.0.0.1:80 location / { root /var/www/ecshop; index index.html index.htm index.php; autoindex on; } # location ~ .php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ .php$ { root /var/www/ecshop; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # #error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/nginx-default; } } |
最后新建一个php文件,添加:
代码如下 | 复制代码 |
<?php phpinfo(); ?> date.timezone = Asia/Chongqing session.auto_start =1 |
时间: 2025-01-21 02:09:20