LNMP Centos安装

=============================== 安装 postgresql ===========================
wget http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.gz
tar zxvf postgresql-9.2.4.tar.gz
cd postgresql-9.2.4
./configure –prefix=/uwiki
同步时间
1 0 * * * /usr/sbin/ntpdate stdtime.hichina.com >/dev/null
配置安装环境
yum -y install gcc gcc-c++ perl wget libxslt-devel libicu-devel libreadline gmp-devel postgresql-devel libpq* libcurl-devel libtool libpcre pcre pcre-devel libssl autoconf 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 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libmcrypt-devel yum install ImageMagick ImageMagick-devel
安装 mysql
yum install mysql mysql-devel mysql-server mysql-client
启动 mysql 服务
service mysqld start
修改 mysqla 管理密码
mysqladmin -u root -p “new-password”
设置 mysqld 自动启动
chkconfig –level 2345 mysqld on

安装 PCRE
cd /usr/local/websoft
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
tar zvxf pcre-8.31.tar.gz
cd pcre-8.31
下面步骤不执行也可以,安装 nginx 的时候必须指定到 PCRE 源码目录,NGINX 会编译安装PCRE.
./configure –prefix=/usr/local/websoft/pcre
make && make install
yum -y install pcre pcre-devel
错误:
gmake[3]: Entering directory /usr/local/websoft/pcre-8.31' CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /usr/local/websoft/pcre-8.31/missing --run aclocal-1.11 -I m4 aclocal-1.11: couldn't open directorym4’: No such file or directory
gmake[3]: *** [aclocal.m4] Error 1
在目录下新建m4目录

安装 libmcrypt
添加一个新源 EPEL(Extra Package for Enterprise Linux)
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
yum install libmcrypt-devel
安装nginx
mkdir /usr/local/websoft;cd /usr/local/websoft
wget http://nginx.org/download/nginx-1.2.4.tar.gz
tar zvxf nginx-1.2.4.tar.gz
cd nginx-1.2.4
./configure –prefix=/usr/local/websoft/nginx –with-pcre=/usr/local/websoft/pcre-8.31
make && make install
==========================或安装openresty nginx ===================================
wget http://agentzh.org/misc/nginx/ngx_openresty-1.2.4.14.tar.gz
tar xvf ngx_openresty-1.2.4.14.tar.gz
cd ngx_openresty-1.2.4.14
./configure –prefix=/usr/local/websoft/openresty/ –with-luajit –with-pcre=/usr/local/websoft/pcre-8.31 –with-http_stub_status_module
gmake
gmake install
安装 php
wget cn2.php.net/get/php-5.4.7.tar.bz2/from/this/mirror
低版本的cn2.php.net/get/php-5.3.18.tar.bz2/from/this/mirror
tar jvxf php-5.4.7.tar.bz2
cd php-5.4.7
(安装配置版本1)

./configure –prefix=/usr/local/websoft/php –enable-fpm –with-config-file-path=/etc –enable-bcmath –with-curl –enable-exif –with-zlib –with-gd –enable-intl –enable-mbstring –with-mcrypt –with-mysql=/usr/bin/mysql_config –with-mysqli=/usr/bin/mysql_config –with-pdo-mysql –enable-soap –enable-sockets –with-jpeg-dir –with-png-dir –enable-zip
(安装配置版本2)
./configure –prefix=/usr/local/websoft/php5.4.7 –with-config-file-path=/usr/local/websoft/php/lib –with-iconv –with-zlib –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –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-pear –with-pgsql –with-pdo-mysql –enable-ftp –with-jpeg-dir –with-freetype-dir –with-png-dir –enable-fpm –with-gettext –with-ldap –with-xsl –with-gmp –enable-exif –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config
./configure –prefix=/usr/local/websoft/php –with-config-file-path=/usr/local/websoft/php/lib –with-iconv –with-zlib –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –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-pear –with-mysql=/usr/local/mysql/ –with-mysqli=/usr/local/mysql/bin/mysql_config –with-pgsql –with-pdo-mysql –enable-ftp –with-jpeg-dir –with-freetype-dir –with-png-dir –enable-fpm –with-gettext –with-ldap –with-xsl –with-gmp –enable-exif
–with-mysql是mysql的安装路径,比如–with-mysql=/usr/local/mysql/
–with-mysqli是mysql_config的安装路径,比如–with-mysqli=/usr/bin/mysql_config
make && make install
php错误:
configure: error: mcrypt.h not found. Please reinstall libmcrypt
解决:
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure prefix=/usr/local/libmcrytp/ 默认也可以
make
make install
php错误:
Cannot find libpq-fe.h
解决:
yum install postgresql-devel libpq*
php错误:
make: ** [sapi/cli/php] Error 1
make ZEND_EXTRA_LIBS=’-liconv’
加make参数
php错误:
configure: error: Unable to locate gmp.h
yum install gmp-devel
php错误:
configure: error: Cannot find ldap libraries in /usr/lib.
cp -frp /usr/lib64/libldap
/usr/lib/
php错误:
configure: error: Cannot find MySQL header files under /usr/local/mysql/.
–with-mysql 不加参数值(=XXXX不要了)
find / -name mysql_config 后的路径写在–with-mysqli
–with-mysqli=/usr/bin/mysql_config
PHP错误:
configure: error: xslt-config not found Please reinstall the libxslt >= 1.1.0
yum install libxslt-devel
php执行后错误:
connect() to unix:/tmp/php-cgi.sock failed (2: No such file or directory)
找到/etc/php-fpm.conf文件中的 127.0.0.1:9000
将其修改为/tmp/php-cgi.sock

安装PHP的rar扩展
wget http://pecl.php.net/get/rar-3.0.0.tgz
tar xvf rar-3.0.0.tgz
cd rar-3.0.0
/usr/local/websoft/php/bin/phpize
./configure –with-php-config=/usr/local/websoft/php/bin/php-config
make
make test
make install
php.ini增加
extension=/usr/local/websoft/php/lib/php/extensions/no-debug-non-zts-20100525/rar.so
安装PHP的phpredis扩展
tar xvf phpredis.tar
cd phpredis
/usr/local/websoft/php/bin/phpize
./configure –with-php-config=/usr/local/websoft/php/bin/php-config
make
make test
make install
php.ini增加
extension=/usr/local/websoft/php/lib/php/extensions/no-debug-non-zts-20100525/redis.so

/****yum 安装 redis 及 php-redis start***
//http://blog.csdn.net/musicrabbit/article/details/9729941
redis和php-redis在官方源上是没有的,需要安装其他的源,其他源的地址为
http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
安装步骤如下
wget http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum install redis php-redis
这样就安装成功了
启动redis
/etc/init.d/redis start

==========================
php-redis 安装了,试验了多次,均失败,未知原因
解决:
1、下载php-redis zip安装包
https://github.com/nicolasff/phpredis
或我上传的
http://download.csdn.net/detail/musicrabbit/5865115
2、找到PHP安装路径
命令whereis phpize和whereis php-config 找到phpize和php-config路径
3、生成configure
/usr/bin/phpize
4、编译安装
./configure –with-php-config=/usr/bin/php-config
make && make install
5、加入安装的redis.so模块
vim /etc/php.ini

6、重启apache或nginx
7、测试
[php] view plaincopyprint?connect('127.0.0.1',6379); $redis->set('test','hello world!'); echo $redis->get('test'); ?> connect('127.0.0.1',6379); $redis->set('test','hello world!'); echo $redis->get('test'); ?>
***yum 安装 redis 及 php-redis end**/
安装PHP的mongo扩展
https://github.com/mongodb/mongo-php-driver下载ZIP文件并解压
进入解压后目录
/usr/local/websoft/php/bin/phpize
./configure –with-php-config=/usr/local/websoft/php/bin/php-config
make
make test
make install
php.ini增加
extension=/usr/local/websoft/php/lib/php/extensions/no-debug-non-zts-20100525/mongo.so
安装radius扩展
wget http://pecl.php.net/get/radius-1.2.7.tgz
tar zxvf radius-1.2.7.tgz
cd radius-1.2.7
/usr/local/websoft/php/bin/phpize
./configure –with-php-config=/usr/local/websoft/php/bin/php-config
make
make test
make install
php.ini增加
extension=/usr/local/websoft/php/lib/php/extensions/no-debug-non-zts-20100525/radius.so

=============================安装mongoDB=====================================
wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.1.tgz
tar zxvf mongodb-linux-i686-1.8.1.tgz
cp -rf mongodb-linux-i686-1.8.1 /usr/local/websoft/
mkdir -p /data/mongo/mongodb_data
mkdir -p /data/mongo/mongodb_log
/usr/local/websoft/mongodb-linux-i686-1.8.1/bin/mongod –dbpath=/data/mongo/mongodb_data/ –logpath=/data/mongo/mongodb_log/mongodb.log –logappend &

vim /usr/local/websoft/nginx/conf/nginx.conf
在 http 中增加 Virtual Host
server {
listen 80;
server_name manage.union.com;
location / {
root /var/www/manage.union.24quan.com;
index index.html index.php;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php
fastcgi_param SCRIPT_FILENAME /var/www/manage.union.24quan.com$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string
fastcgi_param QUERY_METHOD $query_type
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
}
}
server {
listen 80;
server_name union.com;
location / {
root /var/www/union.24quan.com;
index index.html index.php;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/union.24quan.com$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param QUERY_METHOD $query_type;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
}
}
=================下面配置是OK的========================
server {
listen 8088;
server_name 223.4.35.78;
location / {
root /www/weidian/application;
index index.html index.php;
try_files $uri $uri/ index.php$uri?$args;
}
location ~ ^(.+.php)(.)$ {
fastcgi_split_path_info ^(.+.php)(.
)$;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/weidian/application$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffers 4 256k;
fastcgi_buffer_size 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
client_max_body_size 20m;
}
}
/usr/local/websoft/nginx/sbin/nginx 启动 nginx
=============================== 安装 redis-2.6.7 ===========================
redis-2.6.7要安装tcl8.5 的版本 不要tcl8.6的版本
http://archive.linuxfromscratch.org/blfs-museum/snapshot-20121101/blfs-20121102/general/tcl.html
wget http://downloads.sourceforge.net/tcl/tcl8.5.12-src.tar.gz
tar zxvf tcl8.5.12-src.tar.gz
cd tcl8.5.12
wget http://downloads.sourceforge.net/tcl/tcl8.5.12-html.tar.gz
cd unix
./configure –prefix=/usr –enable-threads –mandir=/usr/share/man
make
sed -e “s@^(TCL_SRC_DIR=’).@\1/usr/include‘@” -e “/TCL_B/s@=’(-L)?.unix@=’\1/usr/lib@” -i tclConfig.sh
make test
make install
make install-private-headers
ln -v -sf tclsh8.5 /usr/bin/tclsh
chmod -v 755 /usr/lib/libtcl8.5.so

wget http://redis.googlecode.com/files/redis-2.6.7.tar.gz
tar zxvf redis-2.6.7.tar.gz
cp -rf redis-2.6.7 /usr/local/websoft/
cd /usr/local/websoft/redis-2.6.7/
cd redis-2.6.7
make
make test

sr/local/websoft/pgsql
make
make install
groupadd postgres
useradd -g postgres postgres
mkdir -p /usr/local/websoft/pgsql/data
cd /usr/local/websoft/pgsql
chown postgres:postgres data -R
su - postgres
$ vi .bash_profile
$ source ./.bash_profile
$ echo $PG_DATA /usr/local/websoft/pgsql/data
$ /usr/local/websoft/pgsql/bin/initdb -E UTF8 -D /usr/local/websoft/pgsql/data
$ cd /usr/local/websoft/pgsql/data
$ touch pgsql.log
$ vi postgresql.conf
listen_addresses = ‘*’
port = 5432
$ /usr/local/websoft/pgsql/bin/postgres -D /usr/local/websoft/pgsql/data &
$ exit
(或) su -c ‘/usr/local/websoft/pgsql/bin/postgres -D /usr/local/websoft/pgsql/data & ‘ -l postgres

b. 创建数据库用户(wifidog)
su postgres
$ createuser wifidog –pwprompt
could not change directory to “/root”
Enter password for new role:(请输入wifidog)
Enter it again:(请输入wifidog)
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
$ exit
c.创建数据库(hefei_yintai_center)
su postgres
$ createdb hefei_yintai_center –encoding=UTF-8 –owner=wifidog
d. 远程拷贝hefei_yintai_center_20130717_ok.sql数据库脚本
cd /home/www/source
scp 223.4.7.122:/var/wwwroot/yintaimall/demo_mall_v1.2_20130717_ok.sql ./hefei_yintai_center_20130717_ok.sql
替换hefei_yintai_center_20130717_ok.sql文件中DemoMall为新mall的id,如:
sed -i “s/DemoMall/HefeiYintaiCenter/g” grep DemoMall -rl hefei_yintai_center_20130717_ok.sql
然后导入数据sql脚本:
cd /home/www/source
su postgres
psql hefei_yintai_center -U wifidog -f hefei_yintai_center_20130717_ok.sql

开启 yii code generator (Gii 基于WEB的代码生成器)
用于生成 Controller, Table Model, CRUD…
下载 yiiframework
cd /var/www
wget http://yii.googlecode.com/files/yii-1.1.12.b600af.tar.gz
tar zvxf yii-1.1.12.b600af.tar.gz
mv yii-1.1.12.b600af yii
cd yii/framework
vim /etc/environment 加入 php 环境变量,指向到 php/bin 目录
source /etc/environment 重新加载环境变量文件
./yiic webap /var/www/yiic
cd /var/www/yiic/protected/config/
vim main.php
将 21~29 行的注释去掉,使yii加载gii module
修改 gii 数组中的 password 值,改成所需要的密码,保存退出
访问 yiic.com/index.php?r=gii
输入密码后,便可生成相应的module,model,controller, curd…

至此, 关于 LNMP 环境搭建, YIIC 应用, GII 加载全部完成。
=========================================下面是完整的nginx配置文件===========================================

user nobody;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
pid /tmp/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile        on;
tcp_nopush     on;
keepalive_timeout  0;
keepalive_timeout  65;
gzip  on;
server {
    listen       80;
    server_name  www.union.com;
    location / {
        root   /www/union/union.com;
        index  index.html index.php;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/union/union.com$fastcgi_script_name;
        include        fastcgi_params;
                    fastcgi_param QUERY_STRING $query_string;
                    fastcgi_param REQUEST_METHOD $request_method;
                    fastcgi_param CONTENT_TYPE $content_type;
                    fastcgi_param CONTENT_LENGTH $content_length;
                    fastcgi_intercept_errors on;
    }
}
server {
    listen       80;
    server_name  manage.union.com;
    location / {
        root   /www/union/manage.union.com;
        index  index.html index.php;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /www/union/manage.union.com$fastcgi_script_name;
        include        fastcgi_params;
                    fastcgi_param QUERY_STRING $query_string;
                    fastcgi_param REQUEST_METHOD $request_method;
                    fastcgi_param CONTENT_TYPE $content_type;
                    fastcgi_param CONTENT_LENGTH $content_length;
                    fastcgi_intercept_errors on;
    }
}

}

====================================== 安装SVN客户端 =============================================================
yum install subversion subversion-devel

打赏 支付宝打赏 微信打赏

未经允许不得转载!

评论列表 0

访客
取消