Detailed method to configure Php+mysql environment under Nginx/linux

Source: Internet
Author: User
Tags configuration php fpm install php mssql mysql download php download sqlite zend

First we're going to prepare the files for the configuration environment

Nginx Download Address: http://nginx.org/download/nginx-1.3.14.zip

PHP Download Address: http://windows.php.net/downloads/releases/php-5.2.17-nts-Win32-VC6-x86.zip

MySQL Download Address: http://www.mysql.com/downloads/installer/

2, installation configuration nginx:

Extract Nginx, modify configuration file:

The code is as follows Copy Code

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 502 503 504/50x.html;
Location =/50x.html {
Root/var/www/nginx-default;
}

}

2, installation configuration PHP:

Decompression PHP to C disk: Configure PHP.ini, find a lot of configuration files on the Internet, configure MySQL and GD when all use the problem, is the DEDECMS configuration file:

The code is as follows Copy Code


[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
;d Efault_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

; ------------------------
; Common parameter settings
; ------------------------
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

; ------------------------
; Error Debugging settings
; ------------------------
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 Directory
; -----------------------------
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 Extended Component Directory
; -----------------------------
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]
; --------------------------
; Default Save directory for session file
; --------------------------
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"

Note: Configure PHP to support MySQL and GD

[Zend]

The code is as follows Copy Code
Zend_extension_manager.optimizer_ts= "c:/php5liboptimizer-3.3.0"
Zend_extension_ts= "C:/php5libzendextensionmanager.dll"

Start PHP:

The code is as follows Copy Code
RunHiddenConsole.exe c:php5php-cgi.exe-b 127.0.0.1:9000-c C:php5php.ini


Linux version

First uninstall the system from Apache

The code is as follows Copy Code

Yum Remove httpd

2, install MySQL, set password, etc.,

The code is as follows Copy Code

Yum Install wget #安装下载工具wget
wget http://www.atomicorp.com/installers/atomic #下载atomic Yum Source
Sh./atomic #安装
Yum Check-update #更新yum软件包

Install Nginx:

Yum install Nginx #安装nginx, according to the prompts, the input y installation can be successfully installed

The code is as follows Copy Code
#修改配置文件, omitted here, mainly to specify the directory to/home/ngmsw-files

Service Nginx Start #启动
Chkconfig Nginx on #设为开机启动

3, installation vsftpd:

The code is as follows Copy Code

Yum Install vsftpd # Press Y to install successfully


4. New FTP User:

useradd-d/home/ngmsw-files-m Nmswxt_files

The code is as follows Copy Code

#设置密码, passwd nmswxt_files # enter 2 times password
#修改/etc/vsftpd/vsftpd.conf

#注释掉:
#userlist_enable =yes
#tcp_wrappers =yes

# User specified to Directory
Chown Nmswxt_files:nmswxt_files/home/nmswxt_files
# Directory Permissions
chmod 777-r/home/nmswxt_files

If the FTP user does not have permission to add files or directories, refer to the following:

#

The code is as follows Copy Code
View SELinux Settings
Getsebool-a|grep FTP

#etsebool使用-P parameter without having to enter this command every time the boot is turned on
Setsebool-p Ftp_home_dir 1

And then we'll

The code is as follows Copy Code

Yum install MySQL Mysql-server

3, installation Nginx, if Yum installation can not be referred to: http://www.111cn.net/database/mysql/48960.htm

The code is as follows Copy Code

Yum Install Nginx


4, the installation of PHP and related modules

The code is as follows Copy Code

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-mcryp T php-mssql php-snmp Php-soap Php-tidy

#编辑文件php. ini, add cgi.fix_pathinfo = 1 at the end of the file
Vi/etc/php.ini

#启动php-FPM
Service PHP-FPM Start


Related nginx configuration file:

The code is as follows Copy Code

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 502 503 504/50x.html;
Location =/50x.html {
Root/var/www/nginx-default;
}

}

Finally create a new PHP file, add:

The code is as follows Copy Code

<?php
Phpinfo ();
?>

Date.timezone = asia/chongqing

Session.auto_start =1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.