天天看點

L N M P----源碼安裝

<b>L N M P</b>   <b>源碼安裝</b>

<b> </b>

<b>簡介:</b>

      <b>LNMP=Nginx+MySQL+PHP </b><b>網絡伺服器架構;</b>

 【

<b>一、與之前的LAMP</b><b>相比較而言,最大的不同就是</b><b> Nginx </b><b>的引用,Nginx</b><b>一種小巧而效率很高的伺服器軟體,性能穩定,功能豐富,運作簡單,處理靜态檔案速度比較快而且消耗的資源也比較少!</b>

<b>   </b><b>二、與之前的LAMP</b><b>相比較,支援更多的并發連接配接,效率更高!安裝比較簡單,配置檔案比較簡潔,還支援在不間斷服務的情況下進行軟體版本的更新!</b>

<b>搭建</b><b>LNMP</b><b>所用到的:</b>

<b>系統的平台: Linux Redhat 5.4 </b><b>企業版</b>

<b> </b><b>使用到的源碼包</b>

<b>nginx-1.1.18.tar.gz</b>

<b>MySQL-5.5.22-1.rhel5.i386.tar</b>

<b>php-5.4.0.tar.bz2</b>

<b>***</b><b>安裝之前的準備工作!檢測一下group</b><b>組中是否存在那些必需的工具***</b>

[root@HanYu ~]# yum grouplist

<b>Development Libraries</b>

<b>Development Tools</b>

<b>X Software Development</b>

[root@HanYu ~]# yum -y install pcre-devel

<b>一、    </b><b>源碼安裝</b><b>Nginx</b>

<b> </b><b>首先增加使用者</b><b> nginx   </b><b>用于實作和運作</b><b>nginx</b><b>服務程序!</b>

<b>[root@HanYu ~]# useradd -r -g nginx -s /bin/false -M </b>

<b>[root@HanYu ~]# useradd -r -g nginx -s /bin/false -M nginx</b>

<b>編譯及安裝</b>

<b>[root@HanYu ~]# tar xf nginx-1.1.18.tar.gz -C /usr/src/</b>

<b>[root@HanYu ~]# cd /usr/src/nginx-1.1.18/</b>

<b>[root@HanYu nginx-1.1.18]# ./configure \   </b>

<b>  --prefix=/usr \</b>

<b>  --sbin-path=/usr/sbin/nginx \</b>

<b> --conf-path=/etc/nginx/nginx.conf \</b>

<b>  --error-log-path=/var/log/nginx/error.log \</b>

<b> --http-log-path=/var/log/nginx/access.log \</b>

<b> --pid-path=/var/run/nginx/nginx.pid \</b>

<b> --lock-path=/var/lock/nginx.lock \</b>

<b> --user=nginx \</b>

<b> --group=nginx \</b>

<b> --with-http_ssl_module \</b>

<b> --with-http_flv_module \</b>

<b> --with-http_stub_status_module \</b>

<b> --with-http_gzip_static_module \</b>

<b> --http-client-body-temp-path=/var/tmp/nginx/client/ \</b>

<b> --http-proxy-temp-path=/var/tmp/nginx/proxy/ \</b>

<b> --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \</b>

<b> --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \</b>

<b> --http-scgi-temp-path=/var/tmp/nginx/scgi \</b>

<b> --with-pcre</b>

<b>[root@HanYu nginx-1.1.18]# make</b>

<b>[root@HanYu nginx-1.1.18]# make install</b>

<b>[root@localhost nginx-1.1.18]# netstat -tupln |grep nginx</b>

<b>tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      11369/nginx: master</b>

<b>驗證nginx:</b>

L N M P----源碼安裝

<b>二、        </b><b>配置</b><b>mysql</b>

<b>源碼安裝之前進行的操作!</b><b>   </b><b>安裝一些關聯的軟體包:</b>

<b>[root@localhost Server]# useradd -M -s /sbin/nologin mysql</b>

<b>[root@localhost Server]# rpm -ivh ncurses-devel-5.5-24.20060715.i386.rpm</b>

<b>                </b>

<b>[root@localhost ~]# tar -zxvf mysql-5.0.95.tar.gz -C /usr/src/</b>

<b>[root@localhost ~]# cd /usr/src/mysql-5.0.95/</b>

<b>[root@localhost mysql-5.0.95]# ./configure \</b>

<b>--prefix=/usr/local/mysql \</b>

<b>--without-debug \</b>

<b>--with-extra-charsets=utf8,gbk \</b>

<b>--enable-assembler \</b>

<b>--with-mysqld-ldflags=-all-static \</b>

<b>--with-client-ldflags=-all-static \</b>

<b>--with-unix-socket-path=/tmp/mysql.sock \</b>

<b>--with-ssl</b>

<b>編譯及安裝!</b>

<b>[root@localhost mysql-5.0.95]# make &amp;&amp; make install</b>

<b>[root@localhost mysql-5.0.95]# cp support-files/my-medium.cnf /etc/my.cnf</b>

<b>[root@localhost mysql-5.0.95]# cp support-files/mysql.server /etc/init.d/mysqld</b>

<b>[root@localhost mysql-5.0.95]# chmod +x /etc/init.d/mysqld</b>

<b>[root@localhost mysql-5.0.95]# ln -s /usr/local/mysql/bin/* /usr/local/bin/</b>

<b>[root@localhost mysql-5.0.95]# ln -s /usr/local/mysql/lib/mysql/lib* /usr/lib/</b>

<b>初始化資料庫;</b>

<b>[root@localhost mysql-5.0.95]# mysql_install_db --user=mysql</b>

<b>[root@localhost mysql-5.0.95]# chown -R root.mysql /usr/local/mysql/</b>

<b>[root@localhost mysql-5.0.95]# chown -R mysql.mysql /usr/local/mysql/var/</b>

<b>配置完成後啟動</b><b>mysql</b><b>!</b>

<b>[root@localhost mysql-5.0.95]# service mysqld start</b>

<b>Starting MySQL.                                            [</b><b>确定</b><b>]</b>

<b>檢視</b><b>mysql</b><b>所屬的端口是否被占用</b><b> 3306</b><b>端口</b><b>1</b>

<b>[root@localhost mysql-5.0.95]# netstat -tupln |grep 3306</b>

<b>tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      8315/mysqld</b>

<b>驗證</b><b>mysql</b><b>是否配置成功!</b>

<b>[root@localhost mysql-5.0.95]# mysql</b>

<b>Welcome to the MySQL monitor. Commands end with ; or \g.</b>

<b>Your MySQL connection id is 1</b>

<b>Server version: 5.0.95-log Source distribution</b>

<b>Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.</b>

<b>Oracle is a registered trademark of Oracle Corporation and/or its</b>

<b>affiliates. Other names may be trademarks of their respective</b>

<b>owners.</b>

<b>Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</b>

<b>mysql&gt;</b>

<b>mysql&gt; show databases;</b>

<b>+--------------------+</b>

<b>| Database           |</b>

<b>| information_schema | </b>

<b>| mysql              | </b>

<b>| test               | </b>

<b>3 rows in set (0.03 sec)</b>

<b>mysql&gt;quit</b>

<b>三、           </b><b>源碼安裝</b><b>php</b>

<b>  </b><b>安裝之前</b><b>  </b><b>需要安裝幾個依賴包:</b>

<b>             </b><b>【一】、</b><b>libmcrypt-2.5.8.tar.bz2</b>

<b>             </b><b>【二】、</b><b>mhash-0.9.9.9.tar.bz2</b>

<b>             </b><b>【三】、</b><b>mcrypt-2.6.8.tar.gz</b>

<b>1</b><b>、</b><b>libmcrypt-2.5.8.tar.bz2</b>

<b>[root@localhost ~]# tar -jxvf libmcrypt-2.5.8.tar.bz2 -C /usr/src/</b>

<b>[root@localhost ~]# cd /usr/src/libmcrypt-2.5.8/</b>

<b>[root@localhost libmcrypt-2.5.8]# make &amp;&amp; make install</b>

<b>[root@localhost libmcrypt-2.5.8]#./configure</b>

<b>[root@localhost libmcrypt-2.5.8]#make &amp;&amp; make install</b>

<b>2</b><b>、</b><b>mhash-0.9.9.9.tar.bz2</b>

<b>[root@localhost ~]# tar -jxvf mhash-0.9.9.9.tar.bz2 -C /usr/src/</b>

<b>[root@localhost ~]# cd /usr/src/mhash-0.9.9.9/</b>

<b>[root@localhost mhash-0.9.9.9]# ./configure</b>

<b>[root@localhost mhash-0.9.9.9]# make &amp;&amp; make install</b>

<b>[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmcrypt* /usr/lib</b>

<b>[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.* /usr/lib</b>

<b>3</b><b>、</b><b>mcrypt-2.6.8.tar.gz</b>

<b>[root@localhost ~]# tar -zxvf mcrypt-2.6.8.tar.gz -C /usr/src/</b>

<b>[root@localhost ~]# cd /usr/src/mcrypt-2.6.8/</b>

<b>[root@localhost mcrypt-2.6.8]# ./configure</b>

<b>[root@localhost mcrypt-2.6.8]# make &amp;&amp; make install</b>

<b>進行</b><b>php</b><b>的源碼安裝</b><b> </b>

<b>安裝之前還要進行一些跟</b><b>php</b><b>依賴的安裝!</b>

<b>[root@localhost ~]# yum -y install libxml2-devel curl-devel libpng-devel openldap-devel</b>

<b>[root@localhost ~]# tar -jxvf php-5.4.0.tar.bz2 -C /usr/src/</b>

<b>[root@localhost ~]# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap</b>

<b>Installing PHP CLI binary:        /usr/local/php/bin/</b>

<b>Installing PHP CLI man page:      /usr/local/php/php/man/man1/</b>

<b>Installing PHP FPM binary:        /usr/local/php/sbin/</b>

<b>Installing PHP FPM config:        /usr/local/php/etc/</b>

<b>Installing PHP FPM man page:      /usr/local/php/php/man/man8/</b>

<b>Installing PHP FPM status page:      /usr/local/php/php/fpm/</b>

<b>Installing PHP CGI binary:        /usr/local/php/bin/</b>

<b>Installing build environment:     /usr/local/php/lib/php/build/</b>

<b>Installing header files:          /usr/local/php/include/php/</b>

<b>Installing helper programs:       /usr/local/php/bin/</b>

<b> program: phpize</b>

<b> program: php-config</b>

<b>Installing man pages:             /usr/local/php/php/man/man1/</b>

<b> page: phpize.1</b>

<b> page: php-config.1</b>

<b>Installing PEAR environment:      /usr/local/php/lib/php/</b>

<b>[PEAR] Archive_Tar    - installed: 1.3.7</b>

<b>[PEAR] Console_Getopt - installed: 1.3.0</b>

<b>[PEAR] Structures_Graph- installed: 1.0.4</b>

<b>[PEAR] XML_Util       - installed: 1.2.1</b>

<b>[PEAR] PEAR           - installed: 1.9.4</b>

<b>Wrote PEAR system config file at: /usr/local/php/etc/pear.conf</b>

<b>You may want to add: /usr/local/php/lib/php to your php.ini include_path</b>

<b>/usr/src/php-5.4.0/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin</b>

<b>ln -s -f /usr/local/php/bin/phar.phar /usr/local/php/bin/phar</b>

<b>Installing PDO headers:          /usr/local/php/include/php/ext/pdo/</b>

<b>為</b><b>php</b><b>建立配置檔案</b>

<b>[root@localhost php-5.4.0]# cp php.ini-production /usr/local/php/php.ini</b>

<b>[root@localhost php-5.4.0]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf</b>

<b>[root@localhost php-5.4.0]# ln -s /usr/local/bin/php /usr/bin/</b>

<b>配置</b><b>php-fpm   </b><b>編輯</b><b> php-fpm.conf</b>

<b>[root@localhost php-5.4.0]# vim /usr/local/php/etc/php-fpm.conf </b>

<b>143 listen = /var/run/php-fpm/php-fpm.sock</b>

<b>[root@localhost php-5.4.0]# vim /usr/local/nginx/conf/nginx.conf</b>

<b>43         location / {</b>

<b> 44             root   html;</b>

<b> 45             index index.html index.htm index.php;</b>

<b> 46         }</b>

<b>57        location ~ \.php$ {</b>

<b> 58           # root           html;</b>

<b> 59            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;</b>

<b> 60            fastcgi_index index.php;</b>

<b> 61         fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_na    me;</b>

<b> 62            include        fastcgi_params;</b>

<b> 63            include        fastcgi.conf;</b>

<b> 64        }</b>

<b>[root@localhost php-5.4.0]# make &amp;&amp; make install</b>

<b>重新開機</b><b>nginx</b>

<b>[root@localhost php-5.4.0]# pkill -9 niginx</b>

<b>pkill -9   </b><b>強制殺死</b><b>   </b><b>!</b>

<b>pkill -1   </b><b>殺死重新讀取!</b>

<b>[root@localhost php-5.4.0]# cd /usr/local/nginx/html/</b>

<b>[root@localhost html]# vim index.php</b>

<b>&lt;?php</b>

<b>phpinfo();</b>

<b>?&gt;</b>

<b>驗證</b><b>php</b><b>是否配置成功:</b>

L N M P----源碼安裝

繼續閱讀