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

49次阅读
没有评论

共计 5444 个字符,预计需要花费 14 分钟才能阅读完成。

自动写代码机器人,免费开通

一. 安装 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 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 查看 

大功告成!!!!

向 AI 问一下细节

丸趣 TV 网 – 提供最优质的资源集合!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-12-18发表,共计5444字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)