又要重新装一台阿里云服务器。开始想用脚本,但发现脚本的程序版本都比较低 还是手动编译最新版本
开始前
更新服务器到最新版本
#yum makecache
#yum update
//分区挂数据盘
#df -h //查是否分区
#fdisk -l //查硬盘
#fdisk /dev/xvdb1 (n,p ...w,q)
#mkfs.ext4 /dev/xvdb1 //格式化 ext4
#echo '/dev/xvdb1 /server etx4 defaults 0 0' >> /etc/fstab
#mount -a
#cd /root/soft //新建一个下载软件目录
nginx 1.8 稳定版
#wget http://nginx.org/download/nginx-1.8.0.tar.gz
#tar zxvf nginx-1.8.0.tar.gz
#cd nginx-1.8.0
#wget http://zlib.net/zlib-1.2.8.tar.gz
#tar zxvf zlib-1.2.8.tar.gz
#cd zlib-1.2.8
#./configure
#make && make
#wget http://ncu.dl.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz
#tar zxvf pcre-8.37.tar.gz
#cd pcre-8.37
#./configure
#make && make
#wget http://www.openssl.org/source/openssl-1.0.2b.tar.gz
#tar zxvf openssl-1.0.2b.tar.gz
#./configure
#make && make
#./configure --user==nobody --group=nobody --prefix=/server/nginx --with-http_stub_status_module --without-http-cache --with-openssl=../openssl-1.0.2b --with-http_ssl_module --with-http_gzip_static_module --conf-path=/server/nginx/nginx.conf --error-log-path=/server/log/nginx/error.log --http-log-path=/server/log/nginx/access.log
#make
#make install
#cd /server/nginx/sbin
#ln -s /sbin/nginx /server/nginx/sbin/nginx
#nginx //运行nginx
如果报错{
(error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory)
#ldd $(which /server/nginx/sbin/nginx) //查看缺少的库文件位置
#ln -s /lib64/libpcre.so.1 /lib64/libpcre.so.0.0.1
}
#nginx -t //检查通过.
#nginx -s stop //停止NGINX
PHP5.6.10
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#tar zxvf libiconv-1.14.tar.gz
# cd libiconv-1.14
# ./configure --prefix=/usr/local
#make -j 2
#make install
#wget http://download.savannah.gnu.org/releases/freetype/freetype-2.6.tar.gz
#tar zxvf freetype-2.6.tar.gz
#cd freetype-2.6
#./configure --prefix=/usr/local/freetype.2.6
#make && make install
#wget http://download.sourceforge.net/libpng/libpng-1.6.17.tar.gz
#tar zxvf libpng-1.6.17.tar.gz
#cd libpng-1.6.17
#./configure
#make
报错{
/root/soft/libpng-1.6./contrib/tools/pngfix.c:: undefined reference to `inflateReset2'
collect2: ld returned exit status
make[]: *** [pngfix] Error
make[]: *** Waiting for unfinished jobs....
make[]: Leaving directory `/root/soft/libpng-1.6.'
make: *** [all] Error
#find / -name "libz.so"
删除查找出的libz.so
重新编泽zlib(nginx那一节)
}
#wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
#wget http://cn2.php.net/distributions/php-5.6.10.tar.xz
#xz -d php-5.6.10.tar.xz
#tar xvf php-5.6.10.tar
#cd php-5.6.10
#./configure --prefix=/server/php --with-config-file-path=/server/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-static --enable-inline-optimization --enable-sockets --enable-wddx --enable-zip --without-pear --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-iconv --with-gd --with-xmlrpc --enable-mbstring --with-curl --enable-ftp --with-mcrypt --with-freetype-dir=/usr/local/freetype.2.6 --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --disable-ipv6 --disable-debug --with-openssl --disable-maintainer-zts --disable-fileinfo --disable-short-tags
报错{
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
#yum install libxml2-devel.x86_64
checking for RAND_egd... no
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>
将装NGINX时的OPENSSL再编译安装一次。
checking for cURL support... yes
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
#wget http://curl.haxx.se/download/curl-7.42.1.tar.gz
#tar zxvf curl-7.42.1.tar.gz
#cd curl-7.42.1
#./configure
#make && make install
checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
#yum install libmcrypt.x86_64 libmcrypt-devel.x86_64
make: *** [sapi/fpm/php-fpm] 错误
进入上面的libiconv-1.14目录
#cd ../libiconv-1.14
#make uninstall
删除libiconv
参考:http://blog.fbbin.com/archives/1258
}
#make ZEND_EXTRA_LIBS='-liconv' -j 2 //最后的2是指CPU的核数,自已修改。 编译php 出错,请BAIDU PS:最好*用GOOGLE
#make install
#cp php.ini-production /server/php/etc/php.ini
#vi /server/php/etc/php.ini
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
extension_dir = "/server/php/lib/php/extensions/no-debug-non-zts-20121212/
upload_max_filesize = 64M
date.timezone = PRC
max_execution_time = 300
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#cp /server/etc/php-fpm.conf.default /server/etc/php-fpm.conf
#vi /server/etc/php-fpm.conf
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_children = 100
pm.start_servers = 20
opcache.enable=1
pid = run/php-fpm.pid
error_log = /log/php/php-fpm.log
slowlog = /log/php/\$pool.log.slow
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#install -v -m755 ./php-5.6.10/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#/etc/init.d/php-fpm start
[mysql]
#wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
#tar -xzvf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
#mv mysql-5.6.21-linux-glibc2.5-x86_64/* /server/mysql
#groupadd mysql
#useradd -g mysql -s /sbin/nologin mysql
#/server/mysql/scripts/mysql_install_db --datadir=/server/mysql/data/ --basedir=/server/mysql --user=mysql
#chown -R mysql:mysql /server/mysql/
#chown -R mysql:mysql /server/mysql/data/
#chown -R mysql:mysql /alidata/log/mysql
#cp -f /server/mysql/support-files/mysql.server /etc/init.d/mysqld
#sed -i 's#^basedir=$#basedir=/server/mysql#' /etc/init.d/mysqld
#sed -i 's#^datadir=$#datadir=/server/mysql/data#' /etc/init.d/mysqld
#cat > /etc/my.cnf <<END
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
log-error=/log/mysql/error.log
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
END
#chmod 755 /etc/init.d/mysqld
#/etc/init.d/mysqld start
//mysql 用户名:root 密码:默认为空。
配置
#vi /server/nginx/nginx.conf
user nobody nobody;
worker_processes ; error_log logs/error.log; pid logs/nginx.pid; events {
worker_connections ;
} http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
server_tokens off;
keepalive_timeout ;
gzip on;
include /server/nginx/conf/vhosts/*.conf;
}
#vi /server/nginx/confi/vhost/test.conf
server {
listen ;
server_name test;
include /server/nginx/conf/rewrite/test.conf; //手动创新文件
access_log /log/nginx/test.access.log; root /www/test/web;
index index.html index.htm index.php; error_page /.html; error_page /50x.html;
location = /50x.html {
root 50x;
} location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm-test.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /web$fastcgi_script_name;
include fastcgi_params;
} }
#cp /server/php/etc/php-fpm.conf /server/php/etc/php-fpm-test.conf
#vi /server/php/etc/php-fpm-test.conf
修改
25 pid = run/php-fpm-test.pid
error_log =/log/php/php-fpm-test.log
listen = /var/run/php-fpm-test.sock
listen.owner = nobody
listen.group = nobody
chroot = /www/test/web
#cp /etc/init.d/php-fpm /etc/init.d/php-fpm-test
#vi /etc/init.d/php-fpm-test
php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm-test.conf
php_fpm_PID=${prefix}/var/run/php-fpm-test.pid
设置启动..
#chkconfig --level 235 php-fpm-test on
#chkconfig --level 235 mysqld on
#cat nginx >> /etc/rc.local
参考https://gir.me.uk/nginx-php-fpm-with-chroot/