成都创新互联网站制作重庆分公司

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

一.安装MySQL

和平网站建设公司成都创新互联,和平网站设计制作,有大型网站制作公司丰富经验。已为和平上千多家提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的和平做网站的公司定做!

cd /data/soft
sudo wget http://downloads.mysql.com/archives/mysql-5.0/mysql-5.0.45.tar.gz
sudo tar zxvf mysql-5.0.45.tar.gz
cd 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=innobase
sudo make && make install clean
cd /usr/local/mysql
cp ./share/mysql/my-medium.cnf ./my.cnf
./bin/mysql_install_db
cp ./share/mysql/mysql.server /etc/init.d/mysql
chmod +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/soft
wget http://nginx.org/download/nginx-0.8.37.tar.gz
tar zxvf nginx-0.8.37.tar.gz
cd nginx-0.8.37
apt-get install libpcre3-dev(如果需要)
apt-get install openssl(如果需要)
apt-get install libssl-dev(如果需要)
sudo ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
sudo make && make install
cp nginx.sh /etc/init.d/nginx
#/etc/init.d/nginx start(stop) http://127.0.0.1测试

 

三.安装PHP

cd /data/soft
wget http://cn2.php.net/distributions/php-5.3.23.tar.gz
tar zxvf php-5.3.23.tar.gz
cd php-5.3.23
apt-get install libxml2-dev
apt-get install libjpeg-dev
apt-get install libpng-dev
apt-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-cli
make && make install
cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
cd /usr/local/php/etc
mv php-fpm.conf.default php-fpm.conf
vim 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/htdocs
vi /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/soft
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
tar zxvf memcached-1.4.15.tar.gz
cd memcached-1.4.15
apt-get install libevent-dev
./configure --prefix=/usr/local/memcached
make && make install
/usr/local/memcached/bin/memcached -d -m 50 -p 11211 -u root -l 127.0.0.1

六.安装MongoDB

cd /data/soft
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.8.tgz
tar zxvf mongodb-linux-x86_64-2.0.8.tgz
mv mongodb-linux-x86_64-2.0.8 /usr/local/mongodb
mkdir -p /data/db/mongodb/data
mkdir -p /data/db/mongodb/logs
cd /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/soft
wget http://redis.googlecode.com/files/redis-2.6.9.tar.gz
tar zxvf redis-2.4.18.tar.gz
mv redis-2.6.9 /usr/local/redis
cd /usr/local/redis
make
#安装完成后,执行一下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-cli
redis 127.0.0.1:6379> 成功!

八.配置mongodb扩展

wget http://pecl.php.net/get/mongo-1.4.2.tgz
tar zxf mongo-1.4.2.tgz
sudo apt-get install php5-dev
phpize5
./configure --enable-mongo
make 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.gz
tar zxvf phpredis.tar.gz
cd 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-config
sudo make
sudo make install
#在php.ini文件中增加extension=redis.so即可
#重启php-fpm phpinfo查看

十、配置memcache扩展

wget http://pecl.php.net/get/memcache-2.2.6.tgz
tar zxvf memcache-2.2.6.tgz
cd 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-config
sudo make
sudo 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.gz
wget http://pecl.php.net/get/memcached-2.0.1.tgz
tar zxf libmemcached-1.0.8.tar.gz
cd libmemcached-1.0.8
sudo apt-get install cloop-ppl0
./configure --prefix=/usr/local/libmemcached --with-memcached
sudo make
sudo make install
tar zxf memcached-2.0.1.tgz
cd 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/libmemcached
sudo make & make install
vim php.ini
加入 extension=memcached.so
#重启php-fpm phpinfo查看

大功告成!!!!


网站栏目:ubuntu12.04下搭建LNMP+memcahce+memcahced+redis+mongodb扩展
网址分享:http://cxhlcq.com/article/gojcic.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部