先我們要準備配置環境的檔案
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 |