CentOS 6.5搭建 LNMP 生產環境

來源:互聯網
上載者:User

標籤:lnmp   centos整合mysql+php   

CentOS 6.5搭建 LNMP 生產環境


安裝前準備:

  1、軟體包下載:

MySQL5.6.5-M8 http://downloads.mysql.com/archives/get/file/mysql-5.6.5-m8.tar.gz
Cmake-2.8.8 http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
php-5.4.29 http://cn2.php.net.get/php-5.4.29.tar.gz/from/this/mirror
libiconv-1.14 http://ftp.gun.org/gnu/libiconv/libiconv-1.14.tar.gz
nginx-1.2.9 http://nginx.org/downlload/nginx-1.2.9.tar.gz


  2、安裝MySQL資料庫:因為MySQL從5.5版本開始,不再使用開源軟體通行使用的./configure指令碼來配置編譯選項,而改用cmake命令來編譯,而且cmake預設不安裝在系統中,所以,我們首先安裝cmake軟體包:

   a、Cmake安裝

[[email protected]_Server ~]# tar -zxvf cmake-2.8.8.tar.gz[[email protected]_Server ~]# cd cmake-2.8.8[[email protected]_Server ~]# ./bootstrap[[email protected]_Server ~]# gmake[[email protected]_Server ~]# gmake install

  

  3、安裝MySQL

[[email protected]_Server ~]# tar -zxvf mysql-5.6.5-m8.tar.gz[[email protected]_Server ~]# cd mysql-5.6.5-m8[[email protected]_Server ~]# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=UTF8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=all -DWITH_INNODB_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306[[email protected]_Server ~]# make                         #編輯[[email protected]_Server ~]# make install                        #安裝[[email protected]_Server ~]# useradd -s /sbin/nologin mysql    #添加mysql使用者[[email protected]_Server ~]# cp support-files/my-large.cnf /etc/my.cnf    #複製設定檔[[email protected]_Server ~]# cd /usr/local/server/mysql[[email protected]_Server ~]# mkdir -p /data/mysql/data            #建立mysql資料目錄[[email protected]_Server ~]# scripts/mysql_install_db --datadir=/data/mysql/data \    --defaults-file=/etc/my.cnf --user=mysql                    #初始化資料庫[[email protected]_Server ~]# cp support-files/mysql.server /etc/init.d/    #複製啟動指令碼[[email protected]_Server ~]# chkconfig --add mysql.server            #添加啟動服務[[email protected]_Server ~]# service mysql.server start                [[email protected]_Server ~]# echo "PATH=/opt/mysql/bin">>/etc/profile    #設定環境變數[[email protected]_Server ~]# echo "export PATH">>/etc/profile


  4、安裝PHP

    在安裝PHP之前,需要安裝libconv軟體包,其它PHP所需軟體包在前面都已經使用yum安裝完成了,所以無需重複安裝。

    a、安裝libiconv軟體包

[[email protected]_Server ~]# tar -zxvf libiconv-1.14.tar.gz[[email protected]_Server ~]# cd libiconv-1.14[[email protected]_Server ~]# ./configure --prefix=/usr/local[[email protected]_Server ~]# make && make install[[email protected]_Server ~]# ldconfig            #執行ldconfig命令更新動態庫緩衝

    b、安裝PHP

[[email protected]_Server ~]# tar -zxvf php-5.4.5.tar.gz[[email protected]_Server ~]# cd php-5.4.5[[email protected]_Server ~]# ./configure --prefix=/opt/php --disable-debug --disable-ipv6 --disable-rpath --enable-bcmath --enable-exif --enable-gd-native-ttf --enable-mbregex --enable-mbstring=all --enables-pcntl --enable-sage-mode --enable-shmop --enable-soap --enable-sockets --enable-xml --with-config-file-path=/opt/php/etc --with-curl --with-curlwrappers --with-freetype-dir --with\-gd --with-gettext --with-iconv-dir=/usr/local --with-jpeg-dir --with-ldap --with-ldap-sasl --with-libdir=lib --with-libxml-dir=/usr --with-mcrypt --with-mhash --with-openssl --with-pdo-mysql --with-pear --with-png-dir --with-xmlrpc --with-zlib-dir --with-mysqlli=/opt/mysql/bin/mysql_config --with-mysql=/opt/mysql --enable-fastcgi --enable-fpm --enable-force-cgi-redirect[[email protected]_Server ~]#  make ZEND_EXTRA_LIBS=‘-liconv‘[[email protected]_Server ~]# make install[[email protected]_Server ~]# cp php.ini-production /opt/php/etc/php.ini [[email protected]_Server ~]# cp /op/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf[[email protected]_Server ~]#

   5、安裝Nginx

   

[[email protected]_Server ~]# tar -zxvf nginx-1.2.9.tar.gz[[email protected]_Server ~]# cd nginx-1.2.9[[email protected]_Server ~]# ./configure --prefix=/opt/nginx --user=nobody --group=nobody --with-poll_module --with-http_ssl_module --with-http_sub_module --with-http_perl_module --with-mail --with-pcre[[email protected]_Server ~]# make [[email protected]_Server ~]# make install


   6、啟動服務

[[email protected]_Server ~]# /opt/php/sbin/php-fpm[[email protected]_Server ~]# killall -php-fpm[[email protected]_Server ~]# /opt/nginx/sbin/nginx[[email protected]_Server ~]# /opt/nginx/sbin/nginx -s stop


本文出自 “Elephant” 部落格,請務必保留此出處http://zlyang.blog.51cto.com/1196234/1745996

CentOS 6.5搭建 LNMP 生產環境

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.