In linux, nginx + php + mysql environment setup ++ ++ operating system: [CentOS6.0] server: [nginx-1.1.8] PHP: [php-5.2.6] database: [mysql-5.1.59] ++ ++ prepare for software installation (download) 1 [n
In linux, nginx + php + mysql environment setup ++ ++ operating system: [CentOS6.0] server: [nginx-1.1.8] PHP: [php-5.2.6] database: [mysql-5.1.59] ++ ++ prepare for software installation (download) 1 [n
Build an nginx + php + mysql environment in linux
++ ++
Operating System: [CentOS6.0]
Server: [nginx-1.1.8]
PHP: [php-5.2.6]
Database: [mysql-5.1.59]
++ ++
Prepare to install software (download)
1> [nginx-1.1.8] http://nginx.org/download/nginx-1.1.8.tar.gz
2> [php-5.2.6] http://museum.php.net/php5/php-5.2.6.tar.gz
3> export php-5.2.6-fpm-0.5.8.diff.gz] http://php-fpm.org/downloads/php-5.2.6-fpm-0.5.8.diff.gz
4> [mysql-5.1.59] http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.59.tar.gz
5> [libxml2-2.6.30] http://download.chinaunix.net/down.php? Id = 28491 & ResourceID = 6095 & site = 1
6> [libmcrypt-2.5.8] http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
7> [zlib-1.2.3] http://sourceforge.net/projects/libpng/files/zlib/1.2.3/zlib-1.2.3.tar.gz/download
8> [libpng-1.2.31] http://files.directadmin.com/services/custombuild/libpng-1.2.31.tar.gz
9> [small SRC. v6b] http://download.chinaunix.net/down.php? Id = 10021 & ResourceID = 5095 & site = 1
10> [freetype-2.3.5] http://nongnu.askapache.com/freetype/freetype-2.3.5.tar.gz
11> [autoconf-2.61] http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz
12> [gd-2.0.35] http://code.google.com/p/google-desktop-for-linux-mirror/downloads/detail? Name1_gd-2.0.35.tar.gz & can = 2 & q =
13> [ncurses-5.6] http://ftp.gnu.org/gnu/ncurses/ncurses-5.6.tar.gz
14> [pcre-8.10] http://sourceforge.net/projects/pcre/files/pcre/8.10/pcre-8.10.tar.gz/download
15> [openssl-1.0.0e] http://www.openssl.org/source/openssl-1.0.0e.tar.gz ++ ++
1> [install gcc, gcc-c ++]
[Html]View plaincopyprint?
- Yum install gcc
- Yum install gcc-c ++
2> [open ports 80, 3306, and 22]
[Html]View plaincopyprint?
- # Disable the Firewall
- Service iptables stop
- Vi/etc/sysconfig/iptables
- # Add
- -A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
- -A input-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
- -A input-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
- # Restarting the Firewall
- Service iptables restart
3> [Create a lamp/src directory and upload the source code package] 4> [install libxml2]
[Html]View plaincopyprint?
- Tar-zxvf libxml2-2.6.30.tar.gz
- Cd libxml2-2.6.30
- ./Configure -- prefix =/usr/local/libxml2/
- Make
- Make install
5> [install libmcrypt]
[Html]View plaincopyprint?
- Tar-zxvf libmcrypt-2.5.8.tar.gz
- Cd libmcrypt-2.5.8
- ./Configure -- prefix =/usr/local/libmcrypt/-- enable-ltdl-install
- Make
- Make install
6> [install libxml2-devel]
[Html]View plaincopyprint?
- Yum install libxml2-devel
7> [install zlib]
[Html]View plaincopyprint?
- Tar-zxvf zlib-1.2.3.tar.gz
- Cd zlib-1.2.3
- ./Configure
- Make
- Make install
8> [install libpng]
[Html]View plaincopyprint?
- Tar-zxvf libpng-1.2.31.tar.gz
- Cd libpng-1.2.31
- ./Configure -- prefix =/usr/local/libpng/
- Make
- Make install
9> [install composer SRC. v6b]
[Html]View plaincopyprint?
- Mkdir/usr/local/limit 6
- Mkdir/usr/local/partition 6/bin
- Mkdir/usr/local/IPv6/lib
- Mkdir/usr/local/users 6/include
- Mkdir-p/usr/local/users 6/man/man1
-
- Tar-zxvf restart src.v6b.tar.gz
- Cd jpeg-6b
- ./Configure -- prefix =/usr/local/configure 6/-- enable-shared -- enable-static
- Make
- Make install
10> [install freetype]
[Html]View plaincopyprint?
- Tar-zxvf freetype-2.3.5.tar.gz
- Cd freetype-2.3.5
- ./Configure -- prefix =/usr/local/freetype/
- Make
- Make install
11> [install autoconf]
[Html]View plaincopyprint?
- Tar-zxvf autoconf-2.61.tar.gz
- Cd autoconf-2.61
- ./Configure
- Make
- Make install
12> [install gd]
[Html]View plaincopyprint?
- Tar-zxvf gd-2.0.35.tar.gz
- Cd gd-2.0.35
- ./Configure -- prefix =/usr/local/gd2/-- with-jpeg =/usr/local/versions 6/-- with-freetype =/usr/local/freetype/
- Make
- Make install
13> pcre-8.10]
[Html]View plaincopyprint?
- Tar-zxvf pcre-8.10.tar.gz
- Cd pcre-8.10
- ./Configure
- Make
- Make install
14> [install openssl]
[Html]View plaincopyprint?
- Tar-zxvf openssl-1.0.0e.tar.gz
- Cd openssl-1.0.0e
- ./Config -- prefix =/usr/local/openssl
- Make
- Make install
15> [install nginx]
[Html]View plaincopyprint?
- Groupadd www
- Useradd-g www
- Tar-zxvf nginx-1.1.8.tar.gz
- Cd nginx-1.1.8
- ./Configure -- user = www -- group = www -- prefix =/usr/local/nginx -- with-openssl =/lamp/src/openssl-1.0.0e -- with-http_stub_status_module -- with-http_ssl_module
- Make
- Make install
16> [install ncurses]
[Html]View plaincopyprint?
- Tar-zxvf ncurses-5.6.tar.gz
- Cd ncurses-5.6
- ./Configure -- with-shared -- without-debug -- without-ada -- enable-overwrite
- Make
- Make install
17> [install mysql]
[Html]View plaincopyprint?
- Groupadd mysql
- Useradd-g mysql
- Tar-zxvf mysql-5.1.59.tar.gz
- Cd mysql-5.1.59
- ./Configure -- prefix =/usr/local/mysql/-- with-extra-charsets = all
- Make
- Make install
-
- Cp support-files/my-medium.cnf/etc/my. cnf
- /Usr/local/mysql/bin/mysql_install_db -- user = mysql
- Chown-R root/usr/local/mysql
- Chown-R mysql/usr/local/mysql/var
- Chgrp-R mysql/usr/local/mysql
-
- /Usr/local/mysql/bin/mysqld_safe -- user = mysql &
- Cp/lamp/src/mysql-5.1.59/support-files/mysql. server/etc/rc. d/init. d/mysqld
- Chown root. root/etc/rc. d/init. d/mysqld
- Chmod 755/etc/rc. d/init. d/mysqld
- Chkconfig -- add mysqld
- Chkconfig -- list mysqld
- Chkconfig -- levels 245 mysqld off
-
- # Configuring mysql
- Cd/usr/local/mysql
- # Simple test
- Bin/mysqladmin version
- # View all mysql Parameters
- Bin/mysqladmin Variables
- # Directly log on to the server without a password
- Bin/mysql-uroot
- Delete from mysql. user WHERE Host = 'localhost' AND User = '';
- Flush privileges;
- # Set the root password to 123456
- Set password for 'root' @ 'localhost' = PASSWORD ('123 ');
- # Configure remote connection to mysql
- Use mysql
- SELECT user, password, host FROM user;
- Delete from user WHERE host = 'localhsot. localdomain'
- Delete from user WHERE host = '2017. 0.0.1 ';
- UPDATE user SET host = '%' WHERE user = 'root ';
- # Restart mysql
- Service mysqld restart
18> [install php]
[Html]View plaincopyprint?
- Tar-zxvf php-5.2.6.tar.gz
- Gzip-cd php-5.2.6-fpm-0.5.8.diff.gz | patch-d php-5.2.6-p1
-
- Cd php-5.2.6
- . /Configure -- prefix =/usr/local/php/-- with-config-file-path =/usr/local/php/etc/-- with-mysql =/usr/local/ mysql/-- with-libxml-dir =/usr/local/libxml2/-- with-jpeg-dir =/usr/local/defaults 6/-- with-freetype-dir =/usr/ local/freetype/-- with-gd =/usr/local/gd2/-- with-mcrypt =/usr/local/libmcrypt/-- with-mysqli =/usr/local/mysql/ bin/mysql_config -- enable-soap -- enable-mbstring = all -- enable-sockets -- enable-fastcgi -- enable-fpm
- Make
- Make install
- Cp php. ini-dist/usr/local/php/etc/php. ini
- # Modifying php-fpm.conf
- 6/usr/local/php/etc/php-fpm.conf
- # Search for lines and remove comments
- Nobody
- Nobody
- # Start php
- /Usr/local/php/sbin/php-fpm start
19> [nginx configuration]
[Html]View plaincopyprint?
- Vi/usr/local/nginx/conf/nginx. conf
- # Locate the location/modify the path for parsing the PHP file under the server and change it:
- Location /{
- Root/var/www/html;
- Index index.html index.htm index. php;
- }
- # Root indicates that the virtual directory is set to/var/www/html, and the default resolution index. php is added.
- # Locate location ~ under server ~ /. Php $ modify the FastCGI configuration of the php interpreter:
- Location ~ \. Php $ {
- Root/var/www/html;
- Fastcgi_pass 127.0.0.1: 9000;
- Fastcgi_index index. php;
- Fastcgi_param SCRIPT_FILENAME/var/www/html $ fastcgi_script_name;
- Include fastcgi_params;
- }
- # Add nginx to auto-start
- Echo "/usr/local/nginx/sbin/nginx">/etc/rc. d/rc. local
- # Add php to auto-start
- Echo "/usr/local/php/sbin/php-fpm start">/etc/rc. d/rc. local
20> [nginx virtual host configuration]
Vi/usr/local/nginx/conf/nginx. conf # Add include/usr/local/nginx/conf/vhost/dev_localhost.config to the last line of http; # rewrite without url
[Html]View plaincopyprint?
- Server {
- Listen 80 default;
- Server_name dev. localhost;
- Access_log logs/dev. access. log;
-
-
- Root/var/www/html/dev;
-
-
- Server_name_in_redirect off;
-
-
- Location /{
- Index index.html index. php;
- }
-
-
- Location ~ \. Php $ {
- Fastcgi_pass 127.0.0.1: 9000;
- Fastcgi_index index. php;
- Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
- Include fastcgi_params;
- }
- }
# Zend framework)
[Html]View plaincopyprint?
- Server {
- Listen 80;
- Server_name dev. localhost;
- Access_log logs/dev. access. log;
-
- Root/var/www/html/dev/code/html;
- Location /{
- Index index.html index. php;
-
-
- If (-e $ request_filename ){
- Break;
- }
-
- If ($ request_filename ~ * \. (Js | ico | gif | jpg | jpeg | xml | swf | txt | png | css | html | htm) $ ){
- Return 404;
- }
-
- Rewrite. * index. php;
- }
- Location ~ . * \. Php $ {
- Include fastcgi_params;
- Fastcgi_param SCRIPT_FILENAME $ document_root/index. php;
- # Fastcgi_param REQUEST_URI $ document_uri? $ Query_string;
- Fastcgi_read_timeout 120;
- Fastcgi_pass 127.0.0.1: 9000;
- Fastcgi_index index. php;
- }
- }
[Html]View plaincopyprint?
- # Restart nginx
- /Usr/local/nginx/sbin/nginx-s reload
- # Restart php
- /Usr/local/php/sbin/php-fpm restart