lnmp安裝---源碼安裝mysql5.6--nginx--php--memached


LNMP ---》源碼包裝nginx MySQL5.6  php

1.安裝mysql

#先解開mysql5.6源碼包

#tar -zxf mysql-5.6.25.tar.gz
#cd mysql-5.6.25/
#useradd mysql
#yum -y install cmake  gcc
#yum install gcc-c++
# yum -y install  ncurses-devel
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc   -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306  -DMYSQL_USER=mysql   -DEXTRA_CHARSETS=all
#make &&make install
#cd /usr/local/mysql/
#./scripts/mysql_install_db --datadir=/usr/local/mysql/data/  --user=mysql   (初始化數(shù)據(jù)庫)
#ls /usr/local/mysql/data/
#ls -l /usr/local/mysql/data/mysql


復(fù)制主配置文件啟動腳本:
#ls support-files/
#cp support-files/my-default.cnf /etc/my.cnf

#cp support-files/mysql.server /etc/init.d/mysql

#chmod +x /etc/init.d/mysql
#chkcpmfig --add mysql  (添加為系統(tǒng)服務(wù))
#chkconfig --list mysql
#chkconfig  mysql on

#service mysql status

#netstat -anptu |grep :3306

#service mysql start


#ln -s /usr/local/mysql/*    /bin  把命令的路徑添加到path變量里

#echo "export PATH=$PATH:/usr/local/mysql/bin"  >>/etc/profile

#source /etc/profile
#echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin

#mysql -uroot -p
mysql>quit

設(shè)置數(shù)據(jù)庫管理員從本機登錄的密碼
#mysqladmin  -hlocalhost -uroot password "123456" 這是設(shè)置密碼

#mysql -uroot -p123456    

mysql>quit

修改密碼

# mysqladmin -hlocalhost -uroot -p password "11"  (新密碼)

Enter password:  (這填舊密碼)

#mysql -uroot -p11

#vim /etc/ls.so.conf  (庫文件連接   系統(tǒng)啟動會讀這個文件,會加載程序的庫文件,第三方軟件就能找到mysql庫文件位置)

/usr/local/mysql/lib/

#ldconfig -v |grep -i --color mysql

2.安裝PHP

安裝PHP 先安裝擴展包
libmcrypt-2.5.8.tar.gz
mhash-0.9.9.9.tar.gz

# tar zxf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9/
# ./configure
# make &&make install
# tar -zxf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8/
# ./configure
# make &&make install

把庫文件更新到系統(tǒng)默認(rèn)搜索的目錄下

# ln -s /usr/local/lib/libmcrypt* /usr/lib/

# ln -vs /usr/local/lib/libmhash.* /usr/lib/

#ldconfig -v

安裝PHP
# tar zxf php-5.4.24.tar.gz

# cd php-5.4.24/

#  ./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql  --enable-fpm  --enable-mbstring --with-mcrypt --with-mhash --with-config-file-path=/usr/local/php5/etc --with-mysqli=/usr/local/mysql/bin/mysql_config   --enable-memached
# yum list |grep xml2*   (看上面報錯,缺少什么先找到再裝)
# yum -y install *xml2*
# ./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql  --enable-fpm  --enable-mbstring --with-mcrypt --with-mhash --with-config-file-path=/usr/local/php5/etc --with-mysqli=/usr/local/mysql/bin/mysql_config
# make && make install

3.安裝nginx

配置nginx服務(wù)接收到訪問php文件的請求,把請求發(fā)給本機的9000端口

安裝nginx

創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站設(shè)計、網(wǎng)站制作、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)海湖新,十年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

#useradd  nginx

#tar -zxf nginx-1.8.0.tar.gz

#cd nginx-1.8.0/

#yum  -y  install   gcc   gcc-c++   openssl    openssl-devel  pcre   pcre-devel

安裝依賴包,由于lnmp安裝在一臺服務(wù)器上,有些已經(jīng)安裝過了,可用直接./configure編譯了,缺少什么包會報錯再安裝就行,一般是下面這些依賴:)[[#yum -y install gcc zlib-devel openssl-devel ]]


#./configure --prefix=/usr/local/nginx    --with-http_ssl_module    --with-http_stub_status_module


#yum list |grep pcre
#yum -y install pcre*

# ./configure  --prefix=/usr/local/nginx    --with-http_ssl_module    --with-http_stub_status_module

#make  && make install

#ln -s  /usr/local/nginx/sbin/nginx  /usr/sbin/

#netstat -anptu |grep nginx   (先要把之前別的占用80端口關(guān)了)

#nginx    (#chkconfig nginx on  這里nginx沒有啟動腳本,不能設(shè)置開機自啟 寫腳本)

# echo  1111   >  /usr/local/nginx/html/test.html

# yum  -y   install  elinks

# elinks   --dump   http://localhost/test.html
                    1111


#vim /usr/local/nginx/conf/nginx.conf

65-71 注釋去掉

69行:  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


#nginx -s reload


編寫php腳本文件

#cat /usr/local/nginx/html/test.php

<?php

phpinfo();

?>


客戶端訪問

#http://192.168.4.254/test.php (能解釋php代碼)


測試php程序能否連接數(shù)據(jù)庫

先把數(shù)據(jù)庫服務(wù)開啟

# netstat -anptu |grep :3306
tcp        0      0 :::3306                     :::*                        LISTEN      2634/mysqld

#mysql -hlocalhost -uroot -p123456

mysql>grant all on bbsdb.* to webadmin@"localhost" identified by "123456";

mysql>create database bbsdb;

mysql>quit


#vim /usr/local/nginx/html/db.php

<?php

mysql_connect("localhost","webadmin","123456");

if($x){

      echo "ok";

}else{

      echo "err";

}

?>

測試

#http://192.168.4.254/db.php

ok


(諾數(shù)據(jù)庫沒開啟,測試得到的就是err)


——————————————————————————————————————————————————————
4.安裝memcached

安裝memcached服務(wù)   (memcache,內(nèi)存存儲——要先裝事件觸發(fā)器的包libevent,libevent和memache要版本兼容,這里libevent-2.0.21,memcached-1.4.24)

   先安裝libevent

#yum  -y install gcc

#tar -xf libevent-2.0.21-stable.tar.gz  (memcached服務(wù)庫文件)

#cd libevent-2.0.21-stable

#./configure

#make && make install


可以直接給庫文件做鏈接也可在庫配置文件中寫進去,做下面其一就行。

1)  #ln -s /usr/local/lib/libevent/* /usr/lib/

     #ldconfig   (//刷新)


2)  #vim /etc/ld.so.conf (庫文件的配置文件)

    /usr/local/lib/

    #ldconfig  (//刷新)


3)  #vim /etc/ld.so.conf/libevent.conf

     /usr/local/lib/

   #ldconfig


#tar -zxf memcached-1.4.24.tar.gz

#cd memcached-1.4.24

#./configure

#make && make install

#ln -s /usr/local/bin/memached /bin

#memcached -h (查看幫助)


[root@proxe ~]# memcached -u   root -m 64 -vv -d   啟動memcached

#####啟動memcached

用如下命令進行啟動

/usr/local/memcached/bin/memcached -d -m 1024 -u ths -l 198.28.1.237 -p 11211 -c1024 -P /tmp/memcached.pid

以上參數(shù)解釋如下:

-d選項是啟動一個守護進程,

-m是分配給Memcache使用的內(nèi)存數(shù)量,單位是MB,我這里是10MB,

-u是運行Memcache的用戶,我這里是ths,

-l是監(jiān)聽的服務(wù)器IP地址,如果有多個地址的話,我這里指定了服務(wù)器的IP地址192.28.1.237,

-p是設(shè)置Memcache監(jiān)聽的端口。默認(rèn)是11211

-c選項是最大運行的并發(fā)連接數(shù),默認(rèn)是1024,按照你服務(wù)器的負(fù)載量來設(shè)定,

-P是設(shè)置保存Memcache的pid文件,我這里是保存在/tmp/memcached.pid,

#####



查看服務(wù)是否啟動:

[root@proxe ~]# netstat -anptu |grep :11211

tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      6813/memcached      

tcp        0      0 :::11211                    :::*                        LISTEN      6813/memcached      

udp        0      0 0.0.0.0:11211               0.0.0.0:*                               6813/memcached      

udp        0      0 :::11211                    :::*                                    6813/memcached      


【memcached 沒有關(guān)閉服務(wù)腳本,殺進程  pkill -9 memcached  停止服務(wù)】



測試:

[root@host b]# yum -y install telnet


[root@host b]# telnet 192.168.4.5  11211

Trying 192.168.4.5...

Connected to 192.168.4.5.

Escape character is '^]'.


set name 0  100 3

tom

STORED

get name

VALUE name 0 3

tom

END

replace name 0  200 3

asc

STORED

get name

VALUE name 0 3

asc

END

add  set  replace  delete  get

#cd /usr/lcoal/bin

#./php -m  (查看php所支持的功能)

#./php -m |grep memcached (查php是否支持memcached)


讓php支持memcached

#cd

# tar -zxvf memcahce-2.2.5

# cd memcahce-2.2.5

#/usr/local/php5/bin/phpize

#./configure  --with-php-config=/usr/local/php5/bin/php-config  --anable-memcache

#make  && make install

#vim  /usr/local/php5/etc/php.ini
extension_dir="/usr/local/php5nginx/lib/php/extensions/no-

debug-non-zts-20100525/"
extension=memcache.so

#/etc/init.d/php-fpm restart

修改nginx服務(wù)的主配置文件,接收到請求時,先訪問11211端口。 (設(shè)置先從緩存中查找,沒有再從數(shù)據(jù)庫中查詢)
#vim /usr/local/nginx/conf/nginx.conf


編寫測試文件
 #cat  /usr/local/nginx/html/mem.php

<?php$memcache=new Memcache;//創(chuàng)建memcache對象


$memcache->connect('localhost',11211) or die ('could not

connect!! ');

$memcache->set('name', 'jim'); //定義變量


$get_values=$memcache->get('name');//獲取變量值echo

$get_values;?>

#http://nginx-ip/mem.php
    jim

分享題目:lnmp安裝---源碼安裝mysql5.6--nginx--php--memached
瀏覽路徑:http://muchs.cn/article18/gesigp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、關(guān)鍵詞優(yōu)化、外貿(mào)網(wǎng)站建設(shè)靜態(tài)網(wǎng)站、域名注冊、App設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)