-前期准备工作———————————————–
关闭防火墙以及selinux
#service iptables stop
#chkconfig iptables off
#vi /etc/selinux/config #把SELINUX=enforcing 修改为disabled
保存并退出。重新启动电脑
yum -y install gcc gcc-c++ autoconf nss_ldap 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 openldap-clients openldap-servers pcre pcre-devel make wget vim cmake gd gd-devel libevent libevent-devel zip unzip
1.安装apr
tar -zxf apr-util-1.5.3.tar.gz
cd apr-1.5.1
./configure --prefix=/usr/local/apr
[root@1010 apr-1.5.1]# make && make install
2.安装apr-util
tar xf apr-util-1.5.3.tar.gz
cd apr-util-1.5.3
[root@1010 apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@1010 apr-util-1.5.3]# make && make install
3.以上两步编译完成,现正式开始编译httpd-2.4.9
[root@1010 ~]# tar -zxf httpd-2.4.9.tar.gz
[root@1010 ~]# cd httpd-2.4.9
[root@1010 httpd-2.4.9]#
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event
--prefix=/usr/local/apache 安装路径
--sysconfdir=/etc/httpd 配置文件路径
--enable-so 允许运行时加载DSO模块
--enable-ssl 如果不加载将无法使用使用https
--enable-cgi 允许使用cgi脚本
--enable-rewrite 支持URL重写机制
--with-zlib 支持网络通用压缩库
--with-pcre 支持pcre
--with-apr=/usr/local/apr 指定apr的安装路径
--with-apr-util=/usr/local/apr-util/ 指定apr-util的安装路径
--enable-modules=most 启用大多数常用的模块
--enable-mpms-shared=all 启用MPM所有支持的模式
--with-mpm=event 默认使用enevt模式
[root@1010 httpd-2.4.9]# make
[root@1010 httpd-2.4.9]# make install
自启动脚本:
#!/bin/bash
# Startup script for the Apache2.0.X Web Server
# Fixed by Comsenz - Nanu (nanu@discuz.com)
# chkconfig: - 85 15
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
INITLOG_ARGS=""
apachectl=/usr/local/apache/bin/apachectl
httpd=${HTTPD-/usr/local/apache/bin/httpd}
prog=httpd
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}
reload() {
echo -n $"Reloading $prog: "
killproc $httpd -HUP
RETVAL=$?
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f /var/run/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog
{start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtes t}"
exit 1
esac
exit $RETVAL
修改/etc/httpd/httpd.conf
Servername
[root@1010 httpd-2.4.9]# chkconfig --add httpd
[root@1010 httpd-2.4.9]# chkconfig httpd on
[root@1010 httpd-2.4.9]# chkconfig --list httpd
httpd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
#---------------------------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------------------------
[root@1010 ~]# groupadd mysql
[root@1010 ~]# useradd -g mysql mysql -s /sbin/nologin
[root@1010 ~]# tar -zxf mysql-5.6.12.tar.gz
[root@1010 ~]# cd mysql-5.6.12
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install
启动MySQL
添加服务,拷贝服务脚本到init.d目录,并设置开机启动
cp support-files/mysql.server /etc/init.d/mysql
chkconfig mysql on
service mysql start --启动MySQL
配置用户
MySQL启动成功后,root默认没有密码,我们需要设置root密码。
设置之前,我们需要先设置PATH,要不不能直接调用mysql
修改/etc/profile文件,在文件末尾添加
PATH=/usr/local/mysql/bin:$PATH
export PATH
关闭文件,运行下面的命令,让配置立即生效
source /etc/profile
现在,我们可以在终端内直接输入mysql进入,mysql的环境了
执行下面的命令修改root密码
mysql -uroot
mysql> SET PASSWORD = PASSWORD('123456');
若要设置root用户可以远程访问,执行
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY '123456' WITH GRANT OPTION;
delete from mysql.user where user=''; ← 删除匿名用户
flush privileges;
select user,host,password from mysql.user;
#---------------------------------------------------------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------------------------------------------------------
useradd -s /sbin/nologin -M fpmuser
[root@1018 ~]# tar -zxf php-5.5.12.tar.gz
[root@1018 ~]# cd php-5.5.12
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/etc \
--with-freetype-dir --with-jpeg-dir \
--with-png-dir --enable-zip \
--with-zlib --enable-xml \
--with-gd --with-mhash \
--with-libxml-dir=/usr --enable-mbstring \
--enable-fpm --with-fpm-user=fpmuser \
--with-fpm-group=fpmuser --disable-ipv6 \
--enable-sockets --with-openssl \
--with-bz2 --with-curl --enable-dba=shared \
--with-pcre-dir --with-gd --with-jpeg-dir --with-png-dir \
--with-zlib-dir --enable-mbstring \
--with-mysql=/usr/local/mysql/ \
--with-mysql-sock=/tmp/mysql.sock \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-bcmath --with-gettext
make
make install
[root@1018 etc]# cp -a php-fpm.conf.default php-fpm.conf
[root@1018 etc]# cd ..
[root@1018 php]# sbin/php-fpm
[root@1018 php]# lsof -i :9000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 10219 root 7u IPv4 222366 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 10220 fpmuser 0u IPv4 222366 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 10221 fpmuser 0u IPv4 222366 0t0 TCP localhost:cslistener (LISTEN)
LoadModule php5_module modules/libphp5.so
此模块调用php
配置apache
找到DirectoryIndex index.html index.html.var
修改为DirectoryIndex index.html index.php
接着增加如下内容:
AddType application/x-httpd-php .php
修改完如下:
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
AddType application/x-httpd-php .php
[root@1018 htdocs]# pwd
/usr/local/apache/htdocs
[root@1018 htdocs]# ls
index.bak index.php
[root@1018 htdocs]# cat index.php
<?php
phpinfo();
?>
[root@1018 htdocs]#
打开测试机访问即可 192.168.100.18
tar -zxf nginx-1.6.0.tar.gz
cd nginx-1.6.0
./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --user=nginx --group=nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_flv_module --with-http_stub_status_module --with-pcre
make && make install
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/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/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
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
}
restart() {
configtest &> /dev/null|| return $?
stop
sleep 1
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
/etc/init.d/nginx start
192.168.100.18