ホームページ  >  記事  >  バックエンド開発  >  centos+nginx1.3.9+php5.4.9+mysql5.5.28+memcached

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

WBOY
WBOYオリジナル
2016-06-23 13:38:53899ブラウズ

1: 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: HTTP 書き換えモジュールには PCRE ライブラリが必要です

以下のインストール方法に従ってください: 問題を解決するには、pcre-devel と openssl-devel をインストールしてください

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

MGB、インストール中に問題が発生しました make: *** 作成するルールはありませんtargetbuild'、デフォルトで必要です。停止します。

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] 必要なコンポーネントをインストールします

# 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

関連するエラー解決:

デフォルト パスの cURL を確認しています... 見つかりません

configure : エラー: libcurl ディストリビューションを再インストールしてください - easy .h は /include/curl/ にあるはずです

実際、curl の dev パッケージはインストールされていません 解決策: ターミナルの下に

# yum -y install curl-devel

その後続行できます

場合によってはCentOS で PHP5 をコンパイルすると、次のエラーが発生します。情報は基本的に、yum を介して対応するライブラリをインストールすることで解決できます。具体的な解決策をいくつか示します:

BZip2 サポートを確認しています… はい、デフォルト パスで BZip2 を確認しています… 見つかりません。configure: エラー: BZip2 ディストリビューションを再インストールしてください

修正: yum install bzip2-devel

cURL サポートをチェックしています… はい、URL ストリームに cURL を使用する必要があるかどうかをチェックしています… デフォルト パスの cURL をチェックしていません… 見つかりません 設定: エラー: libcurl ディストリビューションを再インストールしてください ? easy.h は/ include/curl/ にあるはずです

修正: yum installcurl-devel

-lcurl でcurl_multi_strerror をチェックしています…はい QDBM サポートをチェックしています… GDBM サポートをチェックしていません… NDBM サポートをチェックしていません… 設定しません: エラー: DBA: 必要なヘッダー ファイルが見つかりませんでした。

修正: yum install db4-devel

fabsf をチェックしています…はい、floorf をチェックしています… はい、configure: エラー: jpeglib.h が見つかりません

修正: yum install libjpeg-devel

fabsf をチェックしています…はい、floorf をチェックしています…はい、-ljpeg で jpeg_read_header をチェックしています…はい、configure: エラー: png.h が見つかりません

修正: yum install libpng-devel

-lpng で png_write_image をチェックしています… はいconfigure が失敗した場合は、試してみてください。 with-xpm-dir= configure : エラー: freetype.h が見つかりません。

修正: 次のオプションを使用して PHP を再構成します。 --with-xpm-dir=/usr

-lpng で png_write_image を確認しています。 はい、configure: エラー: libXpm.(a|so) が見つかりません。

修正: yum install libXpm-devel

-lc で binding_textdomain_codeset を確認しています…はい、GNU MP サポートを確認しています… はいconfigure: エラー: gmp.h が見つかりません

修正: yum install gmp -devel

utf8_mime2text 署名を確認しています… U8T_DECOMPOSE を新たに確認しています… 設定: エラー: utf8_mime2text() に新しい署名がありますが、U8T_CANONICAL がありません。

修正: yum install libc-client を確認してください。 -devel

LDAP サポートをチェックしています…はい、LDAP Cyrus SASL サポートを共有チェックしています…はいconfigure: エラー: ldap.h が見つかりません

修正: yum install openldap-devel

-lmysqlclient の mysql_set_character_set をチェックしています… はい mysql_stmt_next_result をチェックしています - lmysqlclient… Oracle Database OCI8 サポートのチェックなし… unixODBC サポートのチェックなし… 構成: エラー: ODBC ヘッダー ファイル '/usr/include/sqlext.h' が見つかりません!

修正:

yum install unixODBC-devel

PostgreSQL のチェックPDO のサポート…はい、pg_config の共有チェック…見つかりませんconfigure: エラー: libpq-fe.h が見つかりません。正しい PostgreSQL インストール パスを指定してください

修正: yum install postgresql-devel

PDO の sqlite 3 サポートを確認しています… はい、 PDO の共有チェックには次のものが含まれます… (キャッシュ) /usr/local/src/php-5.3.7/ext デフォルト パスの sqlite3 ファイルをチェック中… 見つかりません 設定: エラー: sqlite3 ディストリビューションを再インストールしてください

修正: yum install sqlite-devel

utsname.domainname をチェックしています…はい、PSPELL サポートをチェックしています…はいconfigure: エラー: pspell が見つかりません

修正: yum install aspell-devel

UCD SNMP ハックを有効にするかどうかをチェックしています…はい、default_store.h をチェックしています… kstat_read はチェックしていません-lkstat… -lsnmp で snmp_parse_oid がチェックされていません… -lsnmp で init_snmp がチェックされていません… 詳細については、config.log を確認してください

修正: yum install net-snmp-devel

チェック。 XMLWriter サポートを有効にするかどうか…はい、共有 xml2-config パスを確認しています… (キャッシュ) /usr/bin/xml2-config libxml ビルドが機能するかどうか確認しています… (キャッシュ) はい XSL サポートを確認しています…はい、共有設定: エラー: xslt -config が見つかりません。 libxslt >= 1.1.0 ディストリビューションを再インストールしてください

修正: yum install libxslt-devel

設定: エラー: xml2-config が見つかりません libxml2 のインストールを確認してください

修正: 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的用户)

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。