yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel curl curl-devel
libjpeg libjpeg-devel libpng libpng-devel freetype-devel gmp-devel ncurses ncurses-devel
unixODBC-devel openldap openldap-devel -y
yum install cmake make -y
yum install gcc gcc-c++ autoconf bison automake zlib* fiex* libxml* ncurses-devel
libmcrypt* libtool-ltdl-devel* -y
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql/ \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
make && make install
groupadd mysql #添加mysql用户组
useradd mysql -g mysql -s /sbin/nologin #
cd /usr/local/mysql
chown mysql.mysql -R .
chown mysql.mysql -R /data/mysql
//cp support-files/my-default.cnf /etc/my.cnf
[mysqld]
#emove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
# server_id = .....
socket = /data/mysql/mysql.sock
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
chmod 755 scripts/mysql_install_db
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --list|grep mysqld
chkconfig mysqld on
[root@localhost ~]# /usr/local/mysql/bin/mysqladmin -u root password 'yourpassword'
[root@localhost ~]# /usr/local/mysql//mysql -u root -p #敲入该命令后,屏幕会提示输入密码,输入上一步设置的yourpassword
删除root密码为空的记录
mysql> use mysql;
mysql> delete from user where password='';
mysql> flush privileges;
yum -y install pcre*
#1
tar -zxvf libiconv-1.14.tar.gz && cd libiconv-1.14 /
./configure --prefix=/usr/local
make && make install && cd ..
#2
tar -zxvf libmcrypt-2.5.8.tar.gz && cd libmcrypt-2.5.8
./configure && make && make install
/sbin/ldconfig && cd libltdl
./configure --enable-ltdl-install
make && make install && cd /data/softwares
#3
tar -zxvf mhash-0.9.9.9.tar.gz && cd mhash-0.9.9.9
./configure && make && make install && cd ..
#4
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
#5
tar -zxvf mcrypt-2.6.8.tar.gz && cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make && make install && cd ../
tar jxvf php-5.4.22.tar.bz2 && cd php-5.4.22
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-iconv-dir=/usr/local \
--with-freetype-dir --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-jpeg-dir --with-png-dir --with-zlib --with-mhash --enable-sockets --enable-ftp --with-libxml-dir --enable-xml \
--enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl \
--with-curlwrappers --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf \
--with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap \
--with-ldap-sasl --enable-fpm --with-xmlrpc --enable-zip --enable-soap --without-pear \
--enable-pdo --with-pdo-mysql \
Cannot find ldap libraries in /usr/lib
cp -frp /usr/lib64/libldap* /usr/lib/
--disable-fileinfo 内存小于1g
编译完后,没问题再继续执行以下脚本
make ZEND_EXTRA_LIBS='-liconv'
#执行完后后出现 make: *** [ext/phar/phar.php] 错误 127
解决办法:
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/(32位系统)
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/(64位系统)
执行以上软连接后,再重复上面的 ./configure ........
make ZEND_EXTRA_LIBS='-liconv'
没问题后再执行 make install
#选择PHP.ini配置文件
cp php.ini-production /usr/local/php/etc/php.ini
#添加WWW用户
/usr/sbin/groupadd www && /usr/sbin/useradd -g www www
mkdir -p /var/log/nginx &&
chmod +w /var/log/nginx && chown -R www:www /var/log/nginx
mkdir -p /data/www && chmod +w /data/www && chown -R www:www /data/www
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
#去掉/更改 配置文件中的;
pm.max_children = 64
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 1024
user = www
group = www
#检查语法是否正确
/usr/local/php/sbin/php-fpm -t
#出现NOTICE: configuration file /usr/local/webserver/php/etc/php-fpm.conf test is successful 测试成功
/usr/local/php/sbin/php-fpm &
#设置开机启动
vi /etc/rc.d/rc.local
#在行末加入
/usr/local/php/sbin/php-fpm &至此,php编译安装完
需要去下载PCRE以支持重写,正则以及网页压缩等等
(The PCRE library is a set of functions that implement regular expression pattern matching
using the same syntax and semantics as Perl 5)
#wget http://sourceforge.net/projects/pcre/files/pcre/8.31/pcre-8.31.tar.gz/download
#tar xzvf pcre-8.31.tar.gz
#cd pcre-8.31
#./configure
#make && make install
groupadd www
useradd www -g www -s /sbin/nologin
mkdir /home/nginx
wget http://nginx.org/download/nginx-1.4.1.tar.gz
tar zxvf nginx-1.4.4.tar.gz && cd nginx-1.4.4
./configure --user=www --group=www \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--lock-path=/data/nginx/nginx.lock \
--pid-path=/data/nginx/nginx.pid