centos+nginx1.3.9+php5.4.9+mysql5.5.28+memcached

來源:互聯網
上載者:User

標籤:

一:安裝Nginx 1,添加一個不能登入且沒有主目錄的使用者:
# useradd www -M -s /sbin/nologin(www可以用nginx,說明是nginx使用者)
2,必要的組件
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.zip# unzip pcre-8.13.zip# cd pcre-8.13# ./configure# make && make install

(如果有錯誤提示:

./configure: error: the HTTP rewrite module requires the PCRE library.

請按照下面的安裝方法:安裝pcre-devel與openssl-devel解決問題

yum -y install pcre-devel openssl openssl-devel)

MGB,安裝出現一個問題 make: *** No rule to make targetbuild‘, needed bydefault‘. Stop.,莫名的奇妙;

安裝make:

yum -y install gcc automake autoconf libtool make

安裝g++:

yum install gcc gcc-c++yum -y install openssl openssl-devel
3,編譯nginx並安裝
# tar -zxvf nginx-1.3.9.tar.gz# cd nginx-1.3.9# ./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module  --with-pcre=/usr/local/src/pcre-8.34# make && make install --with-pcre 後面的路徑 為源碼包解壓後的路徑,而不是安裝路徑,否則會報錯!
[2].安裝PHP 1,安裝必要的組件
# yum -y install libjpeg-devel libpng-devel# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.8.tar.gz(下載,這個路徑不一定正確,可以通過其他方法下載)# tar -zxvf libmcrypt-2.5.8.tar.gz# cd libmcrypt-2.5.8# ./configure# make && make install

==64位系統==

ln -s /usr/lib64/mysql/ /usr/lib/mysql

==64位系統==

2,編譯php並安裝
# cd php-5.4.9# ./configure --prefix=/opt/php --with-iconv --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt =‘對於libmcrypt的安裝目錄‘ --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets  --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --enable-sqlite-utf8 --with-pdo-mysql --enable-ftp --with-jpeg-dir --with-freetype-dir --with-png-dir --enable-fpm --with-fpm-user=www --with-fpm-group=www# make && make install

相關錯誤解決:

checking for cURL in default path... not found

configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/

其實就是curl的dev包沒有安裝, 解決方案: 終端下

# yum -y install curl-devel

然後就可以繼續了

在CentOS編譯PHP5的時候有時會遇到以下的一些錯誤資訊,基本上都可以通過yum安裝相應的庫來解決。以下是具體的一些解決辦法:

checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution

Fix: yum install bzip2-devel

checking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution – easy.h should be in/include/curl/

Fix: yum install curl-devel

checking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).

Fix: yum install db4-devel

checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.

Fix: yum install libjpeg-devel

checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.

Fix: yum install libpng-devel

checking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir= configure: error: freetype.h not found.

Fix: Reconfigure your PHP with the following option. --with-xpm-dir=/usr

checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.

Fix: yum install libXpm-devel

checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.h

Fix: yum install gmp-devel

checking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

Fix: yum install libc-client-devel

checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.h

Fix: yum install openldap-devel

checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

Fix:

yum install unixODBC-devel

checking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix: yum install postgresql-devel

checking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distribution

Fix: yum install sqlite-devel

checking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspell

Fix: yum install aspell-devel

checking whether to enable UCD SNMP hack… yes checking for default_store.h… no checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.

Fix: yum install net-snmp-devel

checking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix: yum install libxslt-devel

configure: error: xml2-config not found. Please check your libxml2 installation.

Fix: yum install libxml2-devel

checking for PCRE headers location… configure: error: Could not find pcre.h in /usr

Fix: yum install pcre-devel

configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!

Fix: yum install mysql-devel

checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

Fix: yum install unixODBC-devel

checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:

yum install postgresql-devel

configure: error: Cannot find pspell

Fix: yum install pspell-devel

configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.

Fix: yum install net-snmp-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix: yum install libxslt-devel

3,拷貝和修改php設定檔
# cp php.ini-production /opt/php/lib/php.ini 或是/usr/local/lib/php.ini# cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf# /opt/php/bin/php --ini   //測試ini檔案是否載入

修改php.ini

[PHP]safe_mode = Onregister_globals = Offmagic_quotes_gpc = Offallow_url_fopen = Offallow_url_include = Offexpose_php=Offdisable_functions = shell_exec,system,exec,passthru,show_source,curl_exec,curl_multi_exec,get_cfg_var[Date]date.timezone = “Asia/Shanghai”

修改php-fpm.conf

[global]pid = run/php-fpm.piderror_log = log/php-fpm.loglog_level = noticeemergency_restart_threshold = 0emergency_restart_interval = 0[www]pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35(不能大於max_children)pm.max_requests = 500
4,添加服務啟動指令碼
# cp nginx /etc/init.d/nginx# cp php-fpm /etc/init.d/php-fpm# chmod 755 /etc/init.d/nginx# chmod 755 /etc/init.d/php-fpm# chkconfig --add nginx# chkconfig --add php-fpm# chkconfig nginx on# chkconfig php-fpm on
三:安裝Mysql 3.1, 建立mysql安裝目錄
mkdir -p /opt/mysql/
3.2, 建立資料存放目錄
mkdir -p /data/mysql/
3.3, 建立使用者和使用者組與賦予資料存放目錄許可權
# useradd mysql -M -s /sbin/nologin# chown mysql.mysql -R /data/mysql/
3.4, 安裝必要的組件
# yum -y install cmake# yum -y install ncurses-devel
3.5, 編譯安裝Mysql
tar -zxvf mysql-5.5.28.tar.gz cd mysql-5.5.28cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306# make && make install

安裝完mysql伺服器運行正常,但無法使用gbk字元集,系統裝了中文支援,mysql重裝了幾次都不行.

show character set裡沒有gbk;

set names gbk 就提示錯誤 #1115 - Unknown character set: ‘gbk‘

解決方案:

上面的編譯參數-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk這個參數引起的問題方法一、去掉這個參數,預設值是支援all的charset 方法二、直接改為-DWITH_EXTRA_CHARSETS=all加入-DDEFAULT_COLLATION=utf8_general_ci選項後,啟動mysql可能會有問題,須在my.cnf 檔案 [mysqld]加入character_set_server=utf8

3.6, 初始化資料庫
# cd /opt/mysql# scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/data/mysql/
3.7, 配置環境
# cp support-files/my-medium.cnf /etc/my.cnf(這裡的my.cnf參考伺服器的記憶體大小 一般my-medium.cnf是256M,my-large.cnf是512M)# cp support-files/mysql.server /etc/init.d/mysql# chmod 755 /etc/init.d/mysql# chkconfig mysql on# export PATH=/opt/mysql/bin:$PATH //設定環境變數
3.8, 啟動並設定初始密碼
# /etc/init.d/mysql start# mysqladmin -uroot password ‘123123‘

進行再修改密碼的語句

1: UPDATE mysql.user SET Password = PASSWORD(‘newpwd’) WHERE User = ‘root’;(生新設定密碼)2: flush privileges;(重新整理許可權)

註:mysql記錄檔儲存在/data/mysql/下面,對應資料檔案儲存的路徑(比如.err)。

四:安裝memcached 1.下載libevent和memcached
http://memcached.googlecode.com/files/memcached-1.4.13.tar.gzhttps://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz
2.安裝libevent
tar -zxvf libevent-2.0.18-stable.tar.gzcd libevent-2.0.18-stable./configure --prefix=/usr/local/libeventmake && make installcd ../
3.安裝memcached
tar -zxvf memcached-1.4.13.tar.gzcd memcached-1.4.13./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent/make && make installcd ..
4:安裝Memcache的PHP擴充

(1).在http://pecl.php.net/package/memcache 選擇相應想要下載的memcache版本。 (2).安裝PHP的memcache擴充

tar vxzf memcache-2.2.6.tar.gz cd memcache-2.2.6/usr/local/php/bin/phpize ./configure –enable-memcache –with-php-config=/usr/local/php/bin/php-config –with-zlib-dir make make install

(3).上述安裝完後會有類似這樣的提示:

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/

(4).把php.ini中的extension_dir = “./”修改為

extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/”

(5).添加一行來載入memcache擴充:extension=memcache.so

5.啟動並加入啟動項
/usr/local/memcached/bin/memcached -d -l 192.168.1.2 -u www -m 512 -c 10240 -p 12000 -P /tmp/memcached.pid

將以上加入到/etc/rc.local方便下次自動啟動 *註:使用者-u必須指定,在此處樣本所用的是WEB使用者www

6.使用telnet查看狀態
telnet 192.168.1.2 12000stats #查看運行狀態quit #退出
附註:
php5.4.9啟動命令:/opt/php/sbin/php-fpm檢測php運行進程 ps aux|grep php-fpmphp-fpm 關閉:kill -INT `cat /usr/local/php/var/run/php-fpm.pid`關閉後,需要 /opt/php/sbin/php-fpm啟動;沒有php-fpm.pid就用touch建立。php-fpm 重啟:kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid`Nginx 服務啟動命令:/opt/nginx/sbin/nginx文法檢測 /opt/nginx/sbin/nginx -t    檢測nginx.conf檔案文法;

php啟動報錯:

ERROR: [pool www] cannot get uid for user ‘fpm‘

需要在php-fpm上改動user=fpm group=fpm fpm改成nginx;(安裝nginx的使用者)

centos+nginx1.3.9+php5.4.9+mysql5.5.28+memcached

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.