lnmp+redis+solr+rabbitmq+memcache+nginx_mogilefs_module+jdk1.8.0_73环境配置

富建章
2023-12-01

1,先安装nginx1.8.0,编译安装

cd /usr/local/src

#下载pcre安装nginx压缩包
wget http://121.42.40.26:8082/pcre-8.36.tar.gz
wget http://121.42.40.26:8082/nginx-1.8.0.tar.gz
wget http://121.42.40.26:8082/openssl-1.0.0r.tar.gz
wget http://121.42.40.26:8082/nginx_mogilefs_module-1.0.4.tar.gz
wget http://121.42.40.26:8082/zlib-1.2.7.tar.gz

tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure --prefix=/usr/local/pcre
make && make install

cd /usr/local/src
tar -zxvf nginx_mogilefs_module-1.0.4.tar.gz

tar -zxvf openssl-1.0.0r.tar.gz
cd opensshl-1.0.0r
./config
make && make install

cd /usr/local/src
tar -zxvf zlib-1.2.7.tar.gz
./configure=/usr/local/zlib
make && make install


cd /usr/local/src
tar -zxvf nginx-1.4.7.tar.gz
cd nginx-1.4.7
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre-8.36 --with-http_stub_status_module --with-http_ssl_module --add-module=
/usr/local/src/nginx_mogilefs_module-1.0.4/ --with-openssl=/usr/local/src/openssl-1.0.0r
make && make install
这也可以把目录改成自己的想要的,也可以将所需的东西都下载成最新版本的,

如果在编译安装pcre-8.36 出现configure: error: You need a C++ compiler for C++ support.,请执行:

apt-get install build-essential
如果出现 
./configure: error: the HTTP gzip module requires the zlib library. 
You can either disable the module by using --without-http_gzip_module 
option, or install the zlib library into the system, or build the zlib library 
statically from the source with nginx by using --with-zlib=<path> option. 

则安装

sudo apt-get install libssl-dev  

最后 ln -s /home/zzw/software/nginx/sbin/nginx /etc/init.d/nginx

2,如果在编译安装的过程中出现类似于make -f objs/makefile的字样,请用 vim  nginx-1.80/objs/Makefile  然后去掉 -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g 中的 -Werror

成功之后创建软链接 ln -s /usr/local/nginx/sbin/nginx /etc/init.d/nginx,这样就可以操作 service nginx   service nginx -t     service nginx -s reload 等方法

3,安装php5-fpm mysql

apt-get install php5-fpm
apt-get install mysql-server
apt-get install mysql-client
apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode
 php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-memcached php5-redis php5-svn php5-xdebug

4 ,php配置

php5-fpm监听改成9000:文件在/etc/php5/fpm/pool.d/www.conf

listen = 127.0.0.1:9000
5 ,nginx配置

server {
        listen       8082;
        server_name  localhost;

        #charset koi8-r;

        access_log  /home/zzw/software/logs/access.log;
	error_log  /home/zzw/software/logs/error.log;
	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
            root   /home/zzw/webserver/lianxi/;
        }
        location / {
            	root   /home/zzw/webserver/lianxi/;
	    	index  index.htm index.html index.php;  
		if (!-e $request_filename) {
			rewrite ^(.*)$ /index.php?s=$1 last;
			break;
		}
        }
	location ~ \.php$ {
			root   /home/zzw/webserver/lianxi/;
			fastcgi_split_path_info ^(.+.php)(/.+)$;
			fastcgi_param PATH_INFO $fastcgi_path_info;
			include /home/zzw/software/nginx/conf/fastcgi.conf;
			#fastcgi_pass unix:/var/run/php5-fpm.sock;
			fastcgi_pass 127.0.0.1:9000;
			include /home/zzw/software/nginx/conf/fastcgi_params;
        		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
			
		}
        location ~ /\.ht {
            deny  all;
        }
       
    }
include /home/zzw/software/nginx/conf/fastcgi.conf;
其中
if (!-e $request_filename) {
			rewrite ^(.*)$ /index.php?s=$1 last;
			break;
		}
指的就是对于mvc框架的二级寻址

6,redis安装

apt-get install redis-server
然后在下载redis-2.8.9, 然后进行编译安装

tar xvfz redis-2.8.9.tar.gz
cd redis-2.8.9
make && make install
7,设置nginx redis开机启动, 在 /etc/rc.local中添加

/home/zzw/software/redis-2.8.9/src/redis-server /home/zzw/software/redis-2.8.9/redis.conf
/etc/init.d/nginx
8,安装 solr

点击打开链接中下载solr-2.2.0.tgz 然后

cd solr-2.2.0
phpize
apt-get install php5-dev
phpize
./configure
apt-get install libcurl4-gnutls-dev
apt-get install libxml2-dev
apt-get install libpcre3-dev
 ./configure
make
 sudo make install
在php.ini中添加

extension=/usr/lib/php5/20121212/solr.so
9,安装rabbitmq

安装rabbit-c客户端
先安装 apt-get install rabbitmq-server

然后启动 /etc/init.d/rabbitmq-server start

下载 rabbitmq-c-0.5.2.tar.gz
解压 后,进入目录 ,运行 autoreconf -i && ./configure && make && sudo make install

再下载 amqp-1.6.1.tgz

解压进入目录 ,运行 phpize && ./configure --with-amqp && make && sudo make install

1,在/etc/php5/mods-available 分别新建
solr.ini
amqp.ini
内容分别为 extension=redis.so  和 extension=amqp.so

2,然后在 /etc/php5/fpm/conf.d中建立两个软链接
分别为 
ln -s ../../mods-available/solr.ini 20-solr.ini
ln -s ../../mods-available/amqp.ini 20-amqp.ini

3,在php.ini中添加
extension=/usr/lib/php5/20121212/solr.so  
extension=/usr/lib/php5/20121212/amqp.so  

4,重启php5-fpm

service php5-fpm restart

apt-get install rabbitmq-server
然后编译安装amqp-1.6.1.tgz 点击打开链接下载

10,安装memcache

apt-get install memcache
11, 对于memcache,solr,rabbitmq的图形界面问题

rabbitmq先下载

wget https://raw.githubusercontent.com/rabbitmq/rabbitmq-management/rabbitmq_v3_6_0/bin/rabbitmqadmin<pre name="code" class="html">sudo cp rabbitmqadmin /usr/local/bin
cd /usr/local/bin
rabbitmq-plugins enable rabbitmq_management
sudo rabbitmq-plugins enable rabbitmq_management
/etc/init.d/rabbitmq-server restart
sudo rabbitmqctl add_user  zzw 123123 
sudo rabbitmqctl set_user_tags zzw administrator

 然后访问http://localhost:15672/#/ 

memcache先下载 memcache2.0.2然后解压放到web目录下,访问memcahe.php,打开memcache.php可以修改登录密码和用户名

solr下载 solr-5.0.0 然后解压,进入server中,用java -jar start.jar>/tmp/null &启动,打开http://localhost:8983/solr/

最后将server中solr/configsets/sample_techproducts_configs/conf复制出来,放到server/solr/test(新建的文件夹)/

然后在图形界面中点击core admin,再输入test test就可以直接访问了

ini_set('display_errors', '1');
$options = array
(
    'host'  => 'localhost',
    'port'  => '8983',
    'path'  => '/solr/test'
);

$client = new SolrClient($options);

$query = new SolrQuery();

$query->setQuery('lucene');

$query->setStart(0);

$query->setRows(50);

$query->addField('cat')->addField('features')->addField('id')->addField('timestamp');

$query_response = $client->query($query);

$response = $query_response->getResponse();

print_r($response);


12,jdk安装

1,解压jdk
 tar zxvf jdk-8u5-linux-i586.gz 
2,配置jdk
gedit ~/.bashrc

export JAVA_HOME=/home/zzw/software/jdk
export CLASSPATH=${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

source ~/.bashrc

gedit /etc/profile

export JAVA_HOME=/home/zzw/software/jdk
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export JRE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$PATH

source /etc/profile

# update-alternatives --install /usr/bin/java java /home/zzw/software/jdk/bin/java 300
# update-alternatives --install /usr/bin/javac javac /home/zzw/software/jdk/bin/javac 300
# update-alternatives --config java

最后三条没命令为让编辑器在ubuntu上的左边启动栏中可以点击使用,如果没有的话,只能在命令行中启动










 类似资料: