标签:lamp
(一)安装apache
1、安装apache依赖包
yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel openssl-devel libxml2-devel
2、下载并安装apache2.2.31
wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.2.31.tar.gz tar xf httpd-2.2.31.tar.gz cd httpd-2.2.31 ./configure --prefix=/application/apache2.2.31 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite make make install ln -s /application/apache2.2.31/ /application/apache ls -l /application/ 总用量 4 lrwxrwxrwx 1 root root 26 6月 27 22:37 apache -> /application/apache2.2.31/ drwxr-xr-x 15 root root 4096 6月 27 22:35 apache2.2.31
3、编写apache启动脚本
#!/bin/bash # chkconfig: 2345 85 15 . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpd fi INITLOG_ARGS="" apachectl=/application/apache/bin/apachectl (修改) httpd=/application/apache/bin/httpd (修改) pid=$httpd/logs/httpd.pid 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 $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 $pid ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|reload|status" echo $"|fullstatus|graceful|help|configtest}" exit 1 esac exit $RETVAL
4、设置apache开机启动
chkconfig --add httpd chkconfig --list httpd chmod +x /etc/init.d/httpd /etc/init.d/httpd restart
(二) 安装mysql(这里用二进制包)
1、安装mysql依赖包
yum -y install libaio*
2、下载mysql二进制安装包
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.49-linux2.6-x86_64.tar.gz
useradd mysql -s /sbin/nologin -M
4、解压并安装mysql
tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49 ln -s /application/mysql-5.5.49/ /application/mysql /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql (初始化mysql) chown -R mysql.mysql /application/mysql/ cp /application/mysql/support-files/my-small.cnf /etc/my.cnf cp /application/mysql-5.5.49/support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe /etc/init.d/mysqld (修改mysql启动脚本) /etc/init.d/mysqld start
5、配置环境变量
echo "PATH="/application/mysql/bin:$PATH"" >> /etc/profile source /etc/profile
6、创建mysql密码
mysqladmin -uroot password ‘123456‘ mysqladmin -uroot -p‘旧密码‘ password ‘新密码‘ (修改)
7、启动mysql
/etc/init.d/mysqld start
本文出自 “21种犹豫” 博客,谢绝转载!
标签:lamp
原文地址:http://wenqiangit.blog.51cto.com/8735115/1812291