千家信息网

ubuntu12.04 下搭建LNMP+memcahce+memcahced+redis+mongodb扩展

发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,一.安装MySQLcd /data/softsudo wget http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.45.tar.gzsud
千家信息网最后更新 2025年02月02日ubuntu12.04 下搭建LNMP+memcahce+memcahced+redis+mongodb扩展

一.安装MySQL

cd /data/softsudo wget http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.45.tar.gzsudo tar zxvf mysql-5.0.45.tar.gzcd mysql-5.0.45/sudo apt-get install libncurses5-dev(如果没有需要安装)sudo apt-get install build-essential(如果没有需要安装gcc)sudo ./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-embedded-server --enable-local-infile --with-plugins=innobasesudo make && make install cleancd /usr/local/mysqlcp ./share/mysql/my-medium.cnf ./my.cnf./bin/mysql_install_dbcp ./share/mysql/mysql.server /etc/init.d/mysqlchmod +x /etc/init.d/mysql#/etc/init.d/mysql start 及 /etc/init.d/mysql stop 运行和结束mysql服务。#注意:如遇到下面问题:#Starting MySQL/etc/init.d/mysql: line 159: kill: (21755) - No such process解决办法#vim /etc/init.d/mysql#找到类似这样一行(我这里是304行):#$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/  dev/null 2>&1 &#改为(加上参数--user=root):#$bindir/mysqld_safe --user=root --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &#即可启动成功!!!#/usr/local/mysql/bin/mysql -uroot -p 进入mysql !!

二.安装Nginx

cd /data/softwget http://nginx.org/download/nginx-0.8.37.tar.gztar zxvf nginx-0.8.37.tar.gzcd nginx-0.8.37apt-get install libpcre3-dev(如果需要)apt-get install openssl(如果需要)apt-get install libssl-dev(如果需要)sudo ./configure --prefix=/usr/local/nginx --with-http_stub_status_modulesudo make && make installcp nginx.sh /etc/init.d/nginx#/etc/init.d/nginx start(stop) http://127.0.0.1测试

三.安装PHP

cd /data/softwget http://cn2.php.net/distributions/php-5.3.23.tar.gztar zxvf php-5.3.23.tar.gzcd php-5.3.23apt-get install libxml2-devapt-get install libjpeg-devapt-get install libpng-devapt-get install libfreetype6-dev./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --enable-mbstring --enable-ftp --with-gd --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr/include --enable-gd-native-ttf --with-zlib --with-libxml-dir=/usr/include --with-xmlrpc --enable-zip --enable-fpm --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --enable-soap --enable-pcntl --enable-climake && make installcp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmchmod +x /etc/init.d/php-fpmcd /usr/local/php/etcmv php-fpm.conf.default php-fpm.confvim php-fpm.conf#去掉25行前的分号 pid = run/php-fpm.pid#修改第131和132行的user和group为当前用户(安装系统时设置的帐户名)jane jane#去掉161、166、171、176行前面的分号保存并退出。#cp 代码包里的php.ini.development 到 /usr/local/php php.ini#/etc/init.d/php-fpm start 与 /etc/init.d/php-fpm stop (启动和停止)

四.配置nginx支持PHP

mkdri /data/htdocsvi /usr/local/nginx/conf/nginx.conf#修改43、44行#root   /data/htdocs;#index  index.html index.htm index.php;#修改63行#location ~ \.php$ {fastcgi_pass   127.0.0.1:9001;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;include        fastcgi_params;}#/etc/init.d/nginx reload(http://127.0.0.1测试)

五.安装memcached

cd /data/softwget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gztar zxvf memcached-1.4.15.tar.gzcd memcached-1.4.15apt-get install libevent-dev./configure --prefix=/usr/local/memcachedmake && make install/usr/local/memcached/bin/memcached -d -m 50 -p 11211 -u root -l 127.0.0.1

六.安装mongodb

cd /data/softwget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.8.tgztar zxvf mongodb-linux-x86_64-2.0.8.tgzmv mongodb-linux-x86_64-2.0.8 /usr/local/mongodbmkdir -p /data/db/mongodb/datamkdir -p /data/db/mongodb/logscd /usr/local/mongodb/./bin/mongod --dbpath=/data/db/mongodb/data/ --logpath=/data/db/mongodb/logs/log.log --logappend --port=27017 --fork --source=127.0.0.1

七.安装redis

cd /data/softwget http://redis.googlecode.com/files/redis-2.6.9.tar.gztar zxvf redis-2.4.18.tar.gzmv redis-2.6.9 /usr/local/rediscd /usr/local/redismake#安装完成后,执行一下make test看是否正常。#如果出现"You need 'tclsh8.5' in order to run the Redis test"。 则可运行 sudo apt-get install tcl8.5 来安装tcl。#src/redis-server redis.conf(默认配置文件,启动前daemonize参数为no,所以redis不会在后台运行,改成yes)#src/redis-cliredis 127.0.0.1:6379> 成功!

八.配置mongodb扩展

wget http://pecl.php.net/get/mongo-1.4.2.tgztar zxf mongo-1.4.2.tgzsudo apt-get install php5-devphpize5./configure --enable-mongomake install#这样mongodb的php扩展就装好了,然后在php.ini文件中增加extension=mongo.so即可。#注意:为了能加载扩展,需要修改php.ini中到 extension_dir="/usr/lib/php5/20090626/"#重启php-fpm phpinfo查看

九、配置redis扩展

wget --no-check-certificate http://github.com/owlient/phpredis/tarball/master -O phpredis.tar.gztar zxvf phpredis.tar.gzcd owlient-phpredis-90ecd17/#修改/usr/local/php/bin/php-config extension_dir="/usr/lib/php5/20090626"phpize5./configure -with-php-config=/usr/local/php/bin/php-configsudo makesudo make install#在php.ini文件中增加extension=redis.so即可#重启php-fpm phpinfo查看

十、配置memcache扩展

wget http://pecl.php.net/get/memcache-2.2.6.tgztar zxvf memcache-2.2.6.tgzcd memcache-2.2.6/#修改/usr/local/php/bin/php-config extension_dir="/usr/lib/php5/20090626"phpize5./configure -with-php-config=/usr/local/php/bin/php-configsudo makesudo make install#在php.ini文件中增加extension=memcache.so即可#重启php-fpm phpinfo查看

十一、安装并配置memcached扩展(lnmp下)

wget https://launchpad.net/libmemcached/1.0/1.0.8/+download/libmemcached-1.0.8.tar.gzwget http://pecl.php.net/get/memcached-2.0.1.tgztar zxf libmemcached-1.0.8.tar.gzcd libmemcached-1.0.8sudo apt-get install cloop-ppl0./configure --prefix=/usr/local/libmemcached --with-memcachedsudo makesudo make installtar zxf memcached-2.0.1.tgzcd memcached-2.0.1/usr/local/php/bin/phpize./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcachedsudo make & make installvim php.ini加入 extension=memcached.so#重启php-fpm phpinfo查看

大功告成!!!!

0