centos nginx php mysql 环境安装

系统运维,centos 2017-11-03

如果系统是 CentOS 5.8

yum -y install gcc gcc-c++ cmake ncurses-devel
yum install -y autoconf automake zlib libxml2 libgcrypt libtool bison

如果系统是 centos 6 首先执行:

    yum install cmake  bison pcre* libxml2-devel libxml2-static  zlib-devel openssl* libcurl*  libjpeg-devel libpng-devel  gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers cmake bison ncurses-devel gcc gcc-c++ ncurses-devel

下载软软包:

wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36.tar.gz
wget http://cn2.php.net/distributions/php-5.6.31.tar.bz2
wget https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2

Install MySQL

mkdir -p /usr/local/webserver/mysql
tar -zxvf mysql-5.5.24.tar.gz
cd mysql-5.5.24
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql -DMYSQL_UNIX_ADDR=/tmp/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_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/var/mysql/data -DWITH_EXTRA_CHARSETS:STRING=all
make
make install
ln -s  /usr/local/webserver/mysql/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16

设置libmysqlclient的软链,防止编译其它依赖Mysql软件时出现libmysqlclient.so.18: cannot open shared object file 的错误
  32位系统下的MYSQL客户端软链接

ln -s  /usr/local/webserver/mysql/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

  64位系统下的MYSQL客户端软链接

ln -s /usr/local/webserver/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18

参考:http://hi.baidu.com/mucunzhishu/blog/item/d05574636268e2ca8cb10d59.html

Install  libmcrypt
tar -jxvf libmcrypt-2.5.8.tar.bz2
cd libmcrypt-2.5.8
./configure
make
make install
ln -s /usr/local/lib/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

Install PHP

tar -jxvf  php-5.3.13.tar.bz2
cd php-5.3.13
cp -frp /usr/lib64/libldap* /usr/lib/
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath  --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex  --enable-fpm  --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear
#ln -s /usr/lib64/libldap.so  /usr/lib/libldap.so
export LD_LIBRARY_PATH="/usr/local/webserver/mysql/lib:$LD_LIBRARY_PATH"
make

注:如报错 /usr/bin/ld: cannot find -lltdl
解决办法:yum install libtool-ltdl-devel
如报错 collect2: ld returned 1 exit status
解决方法:

make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-production /usr/local/webserver/php/etc/php.ini

修改php的配置文件,设置时间

vi   /usr/local/webserver/php/etc/php.ini
#改更: date.timezone =  Asia/Shanghai

参考:http://hi.baidu.com/mucunzhishu/blog/item/206c4605c530b46b0308817a.html
php-fpm 自动启动:

vi /etc/init.d/php-fpm
#写入以下内容:http://itboren.com/?p=5
chmod +x /etc/init.d/php-fpm
/sbin/chkconfig php-fpm on
/sbin/chkconfig --list php-fpm

打开慢日志:
slowlog = log/$pool.log.slow
request_slowlog_timeout = 10s
Install Nginx

wget http://nginx.org/download/nginx-1.3.0.tar.gz
tar -zxvf nginx-1.3.0.tar.gz
cd nginx-1.3.0
mkdir -p /usr/local/webserver/nginx
./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
make  & make install

Ngnix 作为系统服务:

vi /etc/init.d/nginx
#输也以下内容:http://itboren.com/?p=9
chmod +x /etc/init.d/nginx
/sbin/chkconfig nginx on
/sbin/chkconfig --list nginx

本文由 伯仁 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

还不快抢沙发

添加新评论