“我们要做一个伟大的项目,We have a big plan!balabala……”,领导又突发奇想要做一个项目了,上一个项目还没做完又放弃了,唉,白做了!正当我发呆的时候领导朝向我说:“村长啊,咱们这次要做一个P2P网贷网站,需要你‘敏捷’开发一下”,我说:“好啊,没问题!”,心想:不定什么时候就又下掉了,随便弄一个机器跑就行了!下面就开始了:
我选择了CentOS-6.3-x86_64,Nginx1.4.4,MySQL5.6.15,PHP-5.4.23 LNMP环境。
1、首先安装系统,按照图形界面提示安装,需要注意的是自定义分区,根据自己需要分区,我设置如
/boot 128M / 20480M swap(内存的1.5~2倍) /data(剩余分区)
关闭selinux和防火墙iptables
vim /etc/selinux/config #找到SELINUX=****改成SELINUX=disabled #关闭防火墙iptables -F,并且关闭自启动chkconfig iptables off
最后需要选择软件包时选择Server就好,最小化安装,其他就按照提示走就好了
2、安装必要的库
yum -y install patch cmake make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap
3、编译安装其他库
tar -zxvf autoconf-2.69.tar.gz cd autoconf-2.69/ ./configure --prefix=/data/soft/autoconf make && make install tar -zxvf libiconv-1.14.tar.gz cd libiconv-1.14/ ./configure --prefix=/data/soft/libiconv make && make install tar -zxvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8/ ./configure make && make install /sbin/ldconfig cd libltdl/ ./configure --enable-ltdl-install make && make install ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la >/dev/null 2>&1 ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so >/dev/null 2>&1 ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4 >/dev/null 2>&1 ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 >/dev/null 2>&1
4、安装MySQL
tar zxvf mysql-5.6.15.tar.gz cd mysql-5.6.15/ mkdir -p /data/soft/mysql/data cmake -DCMAKE_INSTALL_PREFIX=/data/soft/mysql -DMYSQL_DATADIR=/data/soft/mysql/data -DSYSCONFDIR=/data/soft/mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS:STRING=utf8,gbk -DWITH_DEBUG=0 make && make install #这个过程会很慢,要有耐心 groupadd mysql useradd -s /sbin/nologin -g mysql mysql /data/soft/mysql/scripts/mysql_install_db --basedir=/data/soft/mysql --datadir=/data/soft/mysql/data --defaults-file=/data/soft/mysql/my.cnf --user=mysql chwon -R mysql.mysql /data/soft/mysql /data/soft/mysql/support-files/mysql.server start #mysql启动 /data/soft/mysql/bin/mysqladmin -u root password ****** #星号为你的密码 /data/soft/mysql/support-files/mysql.server restart #mysql重启
5、安装php
tar zxvf php-5.4.23.tar.gz cd php-5.4.23/ ./configure --prefix=/data/soft/php --with-config-file-path=/data/soft/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-mysql-sock=/tmp/mysqld.sock --without-pear make ZEND_EXTRA_LIBS= '-liconv' make install cp php.ini-production /data/soft/php/etc/php.ini cp /data/soft/php/etc/php-fpm.conf.default /data/soft/php/etc/php-fpm.conf /data/soft/php/sbin/php-fpm #执行启动php-fpm
6、安装nginx
#nginx的rewrite模块需要依赖pcre库 tar zxvf pcre-8.32.tar.gz cd pcre-8.32/ ./configure make && make install #安装nginx tar zxvf nginx-1.4.4.tar.gz cd nginx-1.4.4/ ./configure --prefix=/data/soft/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module make && make install #启动nginx /data/soft/nginx/sbin/nginx
7、访问php
#打开nginx配置文件,指定php-cgi,找到和下面相似的代码,然后去掉注释,修改SCRIPT_FILENAME后面的为$document_root$fastcgi_script_name location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } #检测配置是否正确 /data/soft/nginx/sbin/nginx -t #如果正确重载配置 /data/soft/nginx/sbin/nginx -s reload #最后在nginx目录下的html目录建一个index.php文件,通过ip访问即可
忙活了半天终于搞定了,代码已经开发完成了,赶紧部署到服务器上,调试一下很快就通了,赶紧想老大汇报:“老大,‘敏捷’开发完了,可以对外服务了”,老大听了笑逐颜开啊,赶紧看了一下,对我各种夸奖,我当时就飘了,心想:我这是架构师的节奏啊(各种YY)。很快网站对外服务了,以为可以清闲一下了,其实故事才刚刚开始,预知后事如何,请听下回分解……