- A+
总结:
Linux:CentOS-7-x86_64-DVD-1503-01.iso
PHP:php-5.6.11.tar.gz
Nginx:nginx-1.4.7
MySQL:mysql-cluster-gpl-7.4.7.tar.gz
1、检查并安装组件
1 | yum -y install gcc automake autoconf libtool make gcc -c++ glibc |
2、安装库
1 2 3 4 5 | yum -y install libxslt-devel \ libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \ zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2 -devel \ ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \ krb5-devel libidn libidn-devel openssl openssl-devel |
3、安装libmcrypt
1 2 3 4 5 6 7 8 9 | cd /usr/local/src wget ftp : //mcrypt .hellug.gr /pub/crypto/mcrypt/libmcrypt/libmcrypt-2 .5.7. tar .gz tar zxvf libmcrypt-2.5.7. tar .gz cd libmcrypt-2.5.7 . /configure --prefix= /usr/local/libmcrypt make && make install vi /etc/ld .so.conf.d /local .conf 添加 “ /usr/local/libmcrypt/lib ” ldconfig - v |
4、安装PHP
1 2 3 4 5 6 7 8 9 10 | wget http: //cn2 .php.net /get/php-5 .6.11. tar .gz /from/this/mirror tar zxvf php-5.6.11. tar .gz cd php-5.6.11 . /configure --prefix= /usr/local/php -- enable -fpm --with-mcrypt= /usr/local/libmcrypt \ -- enable -mbstring --disable-pdo --with-curl --disable-debug --disable-rpath \ -- enable -inline-optimization --with-bz2 --with-zlib -- enable -sockets \ -- enable -sysvsem -- enable -sysvshm -- enable -pcntl -- enable -mbregex \ --with-mhash -- enable -zip --with-pcre-regex --with-mysql --with-mysqli \ --with-gd --with-jpeg- dir --with-openssl make && make install |
配置php-fpm
1 2 | cd /usr/local/php/etc cp php-fpm-default.conf php-fpm.conf |
修改php-fpm.conf
将user = nobody group = nobody 修改为 user = phpz group = phpz
创建用户phpz和用户组phpz
1 2 | group add phpz user add -g phpz phpz |
创建php.ini
1 | cp /usr/local/src/php-5 .6.11 /php .ini-production /usr/local/php/lib/php .ini |
设置php-fpm.pid
将;pid = run/php-fpm.pid 前面的分号删掉。
注:重启php-fpm 命令:kill -USR2 `cat var/run/php-fpm.pid`
4、安装Nginx
1 | cd /usr/local/src |
下载并解压pcre-8.36.tar.gz:
1 2 | wget ftp : //ftp .csx.cam.ac.uk /pub/software/programming/pcre/pcre-8 .36. tar .gz tar zxvf pcre-8.36. tar .gz |
下载并解压zlib-1.2.8.tar.gz:
1 2 | wget http: //zlib .net /zlib-1 .2.8. tar .gz tar zxvf zlib-1.2.8. tar .gz |
下载并解压openssl-1.0.1g.tar.gz:
1 2 | wget http: //www .openssl.org /source/openssl-1 .0.1g. tar .gz tar zxvf openssl-1.0.1g. tar .gz |
下载并解压nginx-1.4.7.tar.gz:
1 2 | wget http: //nginx .org /download/nginx-1 .4.7. tar .gz tar zxvf nginx-1.4.7. tar .gz |
安装Nginx
1 2 3 4 5 6 7 | vi /usr/bin/pod2man #注释第69行 cd /usr/local/src/nginx-1 .4.7 . /configure --prefix= /usr/local/nginx \ --with-http_ssl_module \ --with-pcre= /usr/local/src/pcre-8 .36 \ --with-zlib= /usr/local/src/zlib-1 .2.8 \ --with-openssl= /usr/local/src/openssl-1 .0.1g |
启动nginx
1 2 | cd /usr/local/nginx . /sbin/nginx |
配置nginx.conf ,让Nginx通过PHP的FastCGI处理请求,首先到nginx的安装目录cd /usr/local/nginx,修改vi conf/nginx.conf 文件,找到如下内容:
取消注释,再将/scripts$fastcgi_script_name 修改为 $document_root$fastcgi_script_name
新建一个php文件
1 2 | cd /usr/local/nginx/html vi index.php |
1 2 3 | <?php echo phpinfo(); ?> |
启动php-fpm ,重启nginx
1 2 | /usr/local/php/sbin/php-fpm /usr/local/nginx/sbin/nginx -s reload |
浏览器访问http://127.0.0.1/index.php
5、安装MySQL
下载:
1 2 | cd /usr/local/src wget http: //mirrors .sohu.com /mysql/MySQL-Cluster-7 .4 /mysql-cluster-gpl-7 .4.7. tar .gz |
先安装cmake:
1 | yum -y install cmake |
添加名为「mysql」的用户和组:
1 2 | group add mysql user add -r -g mysql mysql |
解压mysql-cluster-gpl-7.4.7.tar.gz:
1 | tar zxvf mysql-cluster-gpl-7.4.7. tar .gz |
cmake命令如下:
1 2 3 4 5 6 7 8 | cmake \ -DCMAKE_INSTALL_PREFIX= /usr/local/mysql \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DMYSQL_TCP_PORT=3306 \ -DMYSQL_UNIX_ADDR= /usr/local/mysql/run/mysql .sock \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_SSL= yes |
安装MySQL:
1 | make && make install |
初始化数据库,先切换目录到MySQL的安装目录:
1 | cd /usr/local/mysql/ |
然后改变安装目录下所有文件的用户及组为mysql
1 2 | chown -R mysql . chgrp -R mysql . |
初始化数据库:
1 | . /scripts/mysql_install_db --user=mysql --basedir= /usr/local/mysql |
然后将目录的所有文件的所属用户改为「root」,接着将目录「data」的所属用户改为「mysql」(这一步很重要,否则数据库可能无法对这个目录进行操作):
1 2 3 4 | chown -R root . chown -R mysql data chown -R mysql data /mysql chown -R mysql.mysql /usr/local/mysql/data |
将MySQL的配置文件拷贝到配置文件目录「/etc/」下,询问是否覆盖源文件输入「yes」即可:
1 | cp support-files /my-medium .cnf /etc/my .cnf |

2015-11-07 16:57 沙发
涨姿势了!