lnamp 安装(CentOS-5.10, nginx-1.6.0, httpd-2.4.9, mysql-5.6.17, php-5.5.12)

-----------------------------------------------------------
filename: lnamp.txt
version: 1.0
date: 2014-05-30 16:28
-----------------------------------------------------------
## 系统环境
Linux: CentOS-5.10
Nginx: nginx-1.6.0
Apache: httpd-2.4.9
MySQL: mysql-5.6.17
PHP: php-5.5.12
-----------------------------------------------------------
yum -y install gcc gcc-c++  make automake autoconf kernel-devel ncurses-devel libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel pcre-devel libtool-libs freetype-devel gd zlib-devel file bison patch mlocate flex diffutils readline-devel glibc-devel glib2-devel bzip2-devel gettext-devel libcap-devel libmcrypt-devel cmake bison-devel

#yum -y install make gcc-c++ cmake bison-devel ncurses-devel

[soft]
mkdir -p /lamp/src
cd /lamp/src
wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.1.tar.gz
wget http://mirrors.hust.edu.cn/apache/apr/apr-iconv-1.2.1.tar.gz
wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.3.tar.gz
wget http://apache.fayea.com/apache-mirror//httpd/httpd-2.4.9.tar.gz
wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
wget http://ftp.kaist.ac.kr/mysql/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz
wget http://nginx.org/download/nginx-1.6.0.tar.gz
wget http://ftp.exim.llorien.org/pcre/pcre-8.34.tar.gz
wget http://mirrors.sohu.com/php/php-5.5.12.tar.gz
wget http://superb-dca3.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.2.2/phpMyAdmin-4.2.2-all-languages.zip
[apr]
tar zxvf apr-1.5.1.tar.gz
cd apr-1.5.1
./configure --prefix=/usr/local/apr
make && make install

[apr-util]
tar zxvf apr-util-1.5.3.tar.gz
cd apr-util-1.5.3
./configure --prefix=/usr/local/apr-util \
	--with-apr=/usr/local/apr
make && make install

[apr-iconv]
tar zxvf apr-iconv-1.2.1.tar.gz
cd apr-iconv-1.2.1
./configure --prefix=/usr/local/apr-iconv \
	--with-apr=/usr/local/apr/bin/apr-1-config
make && make install

[pcre]
tar zxvf pcre-8.34.tar.gz
cd pcre-8.34
./configure --prefix=/usr/local/pcre
make && make install

[apache]
tar zxvf httpd-2.4.9.tar.gz
cd httpd-2.4.9
./configure --prefix=/usr/local/apache2 \
	--with-apr=/usr/local/apr \
	--with-apr-util=/usr/local/apr-util \
	--with-apr-iconv=/usr/local/apr-iconv \
	--with-pcre=/usr/local/pcre \
	--with-ssl \
	--enable-ssl \
	--enable-so \
	--enable-deflate=shared \
	--enable-expires=shared \
	--enable-headers=shared \
	--enable-rewrite=shared \
	--enable-static-support
make && make install

#将apache添加到系统服务中  
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd  
vi /etc/init.d/httpd
#在#!/bin/sh后添加下面两行(包含"#")  
# chkconfig:2345 85 15  
# description:Apache  
#添加执行权限  
chmod 755 /etc/init.d/httpd  
#添加到系统服务中  
chkconfig --add httpd  
#开启apache  
service httpd start

#如果出现下面的错误,  
#httpd: Could not reliably determine the server's fully qualified domain name,  \
#using ::1 for ServerName  
#修改配置文件  
vi /usr/local/apache2/conf/httpd.conf

#查找ServerName,将注释去掉  
ServerName www.example.com:80  

#搜索<IfModule dir_module>, 修改为
DirectoryIndex index.html index.php

#搜索 AddType application/x-gzip .gz .tgz在后面添加  
AddType application/x-httpd-php .html .php  

#搜索Options Indexes FollowSymLinks项并注释  
#Options Indexes FollowSymLinks

#重启apache  
service httpd restart

[mysql]
tar zxvf mysql-5.6.17.tar.gz
cd mysql-5.6.17
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

groupadd mysql
useradd -M -s /sbin/nologin -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

#生成配置文件
mv /usr/local/mysql/my.cnf /etc/
#添加服务,拷贝服务脚本到init.d目录,并设置开机启动
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig mysqld on
#启动MySQL
service mysqld start

修改/etc/profile文件,在文件末尾添加
vi /etc/profile
PATH=/usr/local/mysql/bin:$PATH
export PATH

source /etc/profile

#修改密码
mysql -uroot
mysql> SET PASSWORD = PASSWORD('123456');
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

#删除匿名用户
mysql -uroot -p123456
USE mysql
DELETE FROM user WHERE user = '';

[libmcrypt]
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make && make install

[php]
tar zxvf php-5.5.12.tar.gz
cd php-5.5.12
./configure \
--prefix=/usr/local/php5 \
--with-config-file-path=/usr/local/php5/etc \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-mysql-sock=/usr/local/mysql/tmp/mysql.sock \
--with-pdo-mysql=/usr/local/mysql \
--with-mcrypt=/usr/local/libmcrypt \
--with-gd \
--with-iconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-libxml-dir \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curlwrappers \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--enable-fpm \
--with-fpm-user=nobody \
--with-fpm-group=nobody

make && make install

cp php.ini-production /usr/local/php5/etc/php.ini
cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf

## 修改配置文件
vi /usr/local/php5/etc/php-fpm.conf
## 指定pid位置
# 去掉注释
pid=run/php-fpm.pid

# 添加到服务
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
service php-fpm start

-------------------------------------------------------

## php-fpm 关闭
kill -QUIT `cat /usr/local/php5/var/run/php-fpm.pid`
## php-fpm 重启
kill -USR2 `cat /usr/local/php5/var/run/php-fpm.pid`
## 查看php-fpm进程数
ps -ef | grep php-fpm
## 如果找不到php-fpm.pid文件, 也可用ps查出pid直接使用

[nginx]
#useradd -M -s /sbin/nologin www
groupadd www
useradd -g www www

tar zxvf nginx-1.6.0.tar.gz
cd nginx-1.6.0

./configure \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/conf/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--user=www \
--group=www \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_gzip_static_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_stub_status_module \
--without-http_charset_module \
--with-pcre=../pcre-8.34

make && make install

# 添加到服务, 将下面的代码添加到
vi /etc/init.d/nginx

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
#  
# chkconfig: - 85 15 
# description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/nginx.pid
 
RETVAL=0
prog="nginx"

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.  
[ ${NETWORKING} = "no" ] && exit 0
 
[ -x $nginxd ] || exit 0

# Start nginx daemons functions.
start() {
 
if [ -e $nginx_pid ];then
   echo "nginx already running...."
   exit 1
fi
 
  echo -n $"Starting $prog: "
  daemon $nginxd -c ${nginx_config}
  RETVAL=$?
  echo
  [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
  return $RETVAL
}  

# Stop nginx daemons functions.
stop() {
	echo -n $"Stopping $prog: "
	killproc $nginxd
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}

# reload nginx service functions.
reload() {
    echo -n $"Reloading $prog: "
$nginxd -s reload
    #if your nginx version is below 0.8, please use this command: "kill -HUP `cat ${nginx_pid}`"
    RETVAL=$?
    echo
}  
 
# See how we were called.
case "$1" in
start)
	start
	;;

stop)
	stop
	;;

reload)
	reload
	;;

restart)
	stop
	start
	;;

status)
	status $prog
        RETVAL=$?
        ;;
*)
	echo $"Usage: $prog {start|stop|restart|reload|status|help}"
	exit 1
esac

exit $RETVAL

# 添加执行权限
chmod +x /etc/init.d/nginx
# 增加到系统服务中
chkconfig --level 345 nginx on

#虚拟主机配置
server {
	listen 80;
	server_name test.dev;
	access_log logs/test_dev.access.log;

	root /var/www/html/test;

	server_name_in_redirect off;

	location / {
		index index.html index.php;
	}

	location ~ \.php$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
		include        fastcgi_params;
	}
}

[phpMyAdmin]
cp phpMyAdmin-4.2.2-all-languages.zip /usr/local/apache2/htdocs/
cd /usr/local/apache2/htdocs/
unzip phpMyAdmin-4.2.2-all-languages.zip
mv phpMyAdmin-4.2.2-all-languages.zip phpMyAdmin
cd phpMyAdmin
cp config.sample.inc.php config.inc.php
vi config.inc.php
#搜索localhost改为
$cfg['Servers'][$i]['host'] = '127.0.0.1';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值