一、Nginx 编译安装
下载:wget http://nginx.org/download/nginx-1.8.1.tar.gz
解压:tar -zxvf nginx-1.8.1.tar.gz
yum在线安装软件:
yum install XXXXX
查看软件安装路径
rpm -qa XXXX
rpm -ql XXXX
相关库
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel
编译:
./configure --prefix=/usr/local/nginx --with-http_ssl_module
安装:
make && make install
启动:/usr/local/nginx/sbin/nginx
重启:kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
停止nginx:pkill -9 nginx
测试配置文件:nginx -t
nginx加入服务的脚本:
假定你源码安装Nginx:
安装路径是/usr/local/nginx
否则变更下面路径的文件:
########################
nginx="/usr/local/nginx/sbin/nginx"
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
################################
则将下面文件copy:
#cd /etc/init.d/
#vi nginx
粘贴刚才的内容。检查是不是完整
#chmod +x nginx
#chkconfig add nginx
#chkconfig nginx on
在Centos下是这样。其他类同。
#!/bin/sh
#
#nginx - this script starts and stops the nginx daemin
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
二、mysql 编译安装
下载:wget http://mirror.bit.edu.cn/mysql/Downloads/MySQL-5.6/mysql-5.6.28-linux-glibc2.5-x86_64.tar.gz
解压:tar -zxvf mysql-5.6.28-linux-glibc2.5-x86_64.tar.gz
移动到目标安装目录:mv mysql-5.6.28-linux-glibc2.5-x86_64 /usr/local/mysql
安装:
cd scripts
查看参数:./mysql_install_db --help
查看安装说明: vim INSTALL-BINARY
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
shell> chown -R root .
shell> chown -R mysql data
添加环境变量:1.shell> echo 'export PATH=$PATH:/usr/local/mysql/bin' >>/etc/profile
2.shell> source /etc/profile
shell> bin/mysqld_safe --user=mysql &
#如果出错需修改配置文件my.cnf
设置账号密码:shell> /usr/local/mysql/bin/mysql_secure_installation
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
shell> chkconfig add mysql
shell> chkconfig mysql on
#my.cnf如下:
[mysqld]
explicit_defaults_for_timestamp=true
tmpdir=/tmp/
performance_schema_max_table_instances=600
table_definition_cache=400
table_open_cache=256
thread_cache_size=8
# Remove 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 = 12M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
三.PHP编译安装
官网下载
解压:tar -jxvf php-7.0.2.tar.bz2
查看yum包:yum list | grep libxml
安装libxml :yum install libxml2-devel.x86_64
安装openssl:yum install openssl-devel.x86_64
yum install curl.x86_64
yum install libmcrypt-devel.x86_64
yum install libpng-devel.x86_64
编译: ./configure --prefix=/usr/local/php7 --enable-debug --with-bz2 --with-curl --enable-dba --with-pdo-mysql --with-gd --with-curl --enable-fpm --enable-cgi --with-openssl --enable-mbstring --with-mcrypt --with-mhash --with-pdo-mysql --with-mysqli --with-mysql-sock=/usr/local/mysql/data/mysql.sock
安装结果提示:
/bin/sh /usr/local/src/php-7.0.2/libtool --silent --preserve-dup-deps --mode=install cp ext/opcache/opcache.la /usr/local/src/php-7.0.2/modules
Installing shared extensions: /usr/local/php7/lib/php/extensions/debug-non-zts-20151012/
Installing PHP CLI binary: /usr/local/php7/bin/
Installing PHP CLI man page: /usr/local/php7/php/man/man1/
Installing PHP FPM binary: /usr/local/php7/sbin/
Installing PHP FPM config: /usr/local/php7/etc/
Installing PHP FPM man page: /usr/local/php7/php/man/man8/
Installing PHP FPM status page: /usr/local/php7/php/php/fpm/
Installing phpdbg binary: /usr/local/php7/bin/
Installing phpdbg man page: /usr/local/php7/php/man/man1/
Installing PHP CGI binary: /usr/local/php7/bin/
Installing PHP CGI man page: /usr/local/php7/php/man/man1/
Installing build environment: /usr/local/php7/lib/php/build/
Installing header files: /usr/local/php7/include/php/
Installing helper programs: /usr/local/php7/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php7/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php7/lib/php/
[PEAR] Archive_Tar - already installed: 1.4.0
[PEAR] Console_Getopt - already installed: 1.4.1
[PEAR] Structures_Graph- already installed: 1.1.1
[PEAR] XML_Util - already installed: 1.3.0
[PEAR] PEAR - already installed: 1.10.1
Wrote PEAR system config file at: /usr/local/php7/etc/pear.conf
You may want to add: /usr/local/php7/lib/php to your php.ini include_path
/usr/local/src/php-7.0.2/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers: /usr/local/php7/include/php/ext/pdo/
添加环境变量:1.shell> echo 'export PATH=$PATH:/usr/local/php7/bin' >>/etc/profile
2.shell> source /etc/profile
添加用户:shell> groupadd www
shell> useradd -r -g www -s /bin/false www
添加启动服务脚本:
cd php-7.0.2/sapi/fpm/
cp init.d.php-fpm /etc/init.d/php7.fpm
chmod +x php7-fpm
chkconfig add php7-fpm
chkconfig php7-fpm on
service php7-fpm start
最后:
设置nginx.cnf : fastcgi_pass 127.0.0.1:9000
浙公网安备 33010602011771号