yum 安装 gcc 编译环境,为编译 lnmp 做准备
yum install gcc automake autoconf libtool gcc-c++
14.1 编译 nginx
1: 下载 http://nginx.org/en/download.html
选择 stable 版本下载
2: 解压
# tar zxf nginx.xxxx.tar.gz
3: 配置
#./configure --prefix=/usr/local/nginx
如果提示缺少 pcre 库,
则从 http://www.pcre.org/
假设解压在/usr/local/src/pcre-source
假设安装在/usr/local//pcre
4: 再次配置
1.6.X 版本,要求指定 pcre 的源码目录,即:
#./configure --prefix=/usr/local/nginx \
--with-pcre=/usr/local/src/pcre-source
之前的版本, 指定 pcre 的安装目录,即:
#./configure --prefix=/usr/local/nginx \
--with-pcre=/usr/local/pcre
5: make && make install
6: 启动 nginx
./sbin/nginx
14.5 编译安装 PHP
#yum install gd zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng
libpng-devel
解压,cd 到 php-5.x
# ./configure --prefix=/usr/local/php \
--with-gd \
--enable-gd-native-ttf \
--enable-mysqlnd \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--enable-mbstring \
--enable-fpm
--enable-fpm 是让 PHP 作为独立的进程来运行(默认占据 9000 端口)
# cd /usr/local/php
# cp etc/php-fpm.conf.default etc/php-fpm.conf
#cp /usr/local/src/php-5.5.13/php.ini-development ./lib/php.ini
#./sbin/php-fpm
让 nginx 的最新配置文件生效
# ./sbin/nginx -s reload
14.2 编译 MySQL
http://ftp.nchu.edu.tw/Unix/Database/MySQL/Downloads/MySQL-5.5/
mysql-5.5.30-linux2.6-x86_64.tar.gz
MySQL 的安装稍复杂一些(主要是编译后的配置及初始化),大家注意,碰到开源软件
1:官网的安装介绍
2: 下载源码后,一般有 README/INSTALL
3: ./configure --help
我们可以下载 2 进制版本来安装:
官方示例:
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql # 安装初始化数据
shell> chown -R root .
shell> chown -R mysql data
具体安装流程:
# groupadd mysql
[root@bogon mysql5.5]# useradd -g mysql mysql
[root@bogon mysql5.5]# cd /usr/local/mysql5.5/
#chown -R mysql .
# chgrp -R mysql .
# ./scripts/mysql_install_db --user=mysql
如果提示如下错误:
/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or
directory
则# yum install libaioso.1 libaio
然后再次执行
# chown -R root .
# chown -R mysql data
# mkdir /var/run/mysqld
# chown mysql /var/run/mysqld
# chgrp mysql /var/run/mysqld
# ./bin/mysqld_safe --user=mysql &