操作环境
操作系统:Mac Os Lion
虚拟主机:VMware Fusion
虚拟系统:Centos 5.5+
操作用户:Root
实现目的:搭建LNMP环境.
安装依赖库和开发环境
#依赖库和开发工具yum -y install gcc gcc-c++ autoconf 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 nss_ldap openldap-clients openldap-servers
#Nginxyum -y install pcre-devel zlib-devel
#Phpyum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel #Mysql yum -y install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel* mysql-devel
下载软件包
#创建目录 mkdir /web cd /web #PHP5.3.7 wget http://down1.chinaunix.net/distfiles/php-5.3.8.tar.bz2
#PHP库文件
wget http://down1.chinaunix.net/distfiles/mcrypt-2.6.4.tar.gz
wget http://down1.chinaunix.net/distfiles/mhash-0.9.3.tar.gz
wget http://down1.chinaunix.net/distfiles/libmcrypt-2.5.7.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#Nginx1.0.9wget http://www.nginx.org/download/nginx-1.0.9.tar.gz
#Nginx(pcre) wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.tar.gz #Mysql5.5.17wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz/from/http://mysql.ntu.edu.tw/
#Mysql(cmake) wget http://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz
安装Mysql
#安装cmaketar -zxvf cmake-2.8.6.tar.gz cd cmake-2.8.6/ ./configure gmake && gmake install && cd ../
#添加mysql用户/usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql mkdir -p /data/mysql chown -R mysql:mysql /data/mysql
#安装Mysqltar -zxvf mysql-5.5.17.tar.gz cd mysql-5.5.17 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/ make && make install
#设置Mysql #在support-files目录中有五个配置信息文件: #my-small.cnf (内存<=64M) #my-medium.cnf (内存 128M) #my-large.cnf (内存 512M) #my-huge.cnf (内存 1G-2G) #my-innodb-heavy-4G.cnf (内存 4GB)cd /usr/local/mysql cp ./support-files/my-medium.cnf /etc/my.cnf vi /etc/my.cnf #在 [mysqld] 段增加datadir = /data/mysql wait-timeout = 30 max_connections = 512 default-storage-engine = MyISAM #在 [mysqld] 段修改max_allowed_packet = 16M
#生成授权表 cd /usr/local/mysql ./scripts/mysql_install_db --user=mysql
#更改密码/usr/local/mysql/bin/mysqladmin -u root password 123456
#开启mysql/usr/local/mysql/bin/mysqld_safe &
#测试连接mysql/usr/local/mysql/bin/mysql -u root -p 123456 show databases; exit;
#设置开机启动vi /etc/rc.d/rc.local
#加入/usr/local/mysql/bin/mysqld_safe &
安装PHP
#1tar -zxvf libiconv-1.14.tar.gz && cd libiconv-1.14/ ./configure --prefix=/usr/local make && make install && cd ../
#2tar -zxvf libmcrypt-2.5.7.tar.gz && cd libmcrypt-2.5.7/
./configure && make && make install
/sbin/ldconfig && cd libltdl/ && ./configure --enable-ltdl-install
make && make install && cd ../
#3tar -zxvf mhash-0.9.3.tar.gz && cd mhash-0.9.3/ && ./configure
make && make install && cd ../
#4ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
#5tar -zxvf mcrypt-2.6.8.tar.gz &&cd mcrypt-2.6.8/ /sbin/ldconfig ./configure make && make install && cd ../
#6tar -xjvf php-5.3.8.tar.bz2 cd php-5.3.8
./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-iconv-dir=/usr/local/ --with-freetype-dir \ --with-mysql=/usr/local/mysql \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-jpeg-dir --with-png-dir --with-zlib \ --with-mhash --enable-sockets --enable-ftp \ --with-libxml-dir --enable-xml --disable-rpath \ --enable-safe-mode --enable-bcmath \ --enable-shmop --enable-sysvsem \ --enable-inline-optimization --with-curl \ --with-curlwrappers \ --enable-mbregex \ --enable-mbstring --with-mcrypt --with-gd \ --enable-gd-native-ttf --with-openssl --with-mhash \ --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl \ --enable-fpm \ --with-xmlrpc --enable-zip --enable-soap \ --without-pear \
make ZEND_EXTRA_LIBS='-liconv'
#注意这里容易出现 make: *** [ext/phar/phar.php] 错误 127 #出现mysql client解决方法 #ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/ #ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18 #或者chmod: 无法访问 “ext/phar/phar.phar”: 没有那个文件或目录 #make: [ext/phar/phar.phar] 错误 1 (忽略) #解决方法在编译的时候加--without-pear参数
#如果还不行,make的时候不添加 ZEND_EXTRA_LIBS='-liconv' 参数 make install
#选择PHP.ini配置文件 cp php.ini-production /usr/local/php/etc/php.ini
更改PHP-FPM
#添加WWW用户
/usr/sbin/groupadd www && /usr/sbin/useradd -g www www
mkdir -p /var/log/nginx && chmod +w /var/log/nginx &&chown -R www:www /var/log/nginx
mkdir -p /data/www && chmod +w /data/www && chown -R www:www /data/www
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
#去掉/更改 配置文件中的;pm.max_children = 64 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 1024 user = www group = www
#检查语法是否正确 /usr/local/php/sbin/php-fpm -t #出现NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful 测试成功 /usr/local/php/sbin/php-fpm & #设置开机启动 vi /etc/rc.d/rc.local #在行末加入 /usr/local/php/sbin/php-fpm &
#返回安装包目录 cd /web
安装Nginx
#安装pcre库tar -zxvf pcre-8.13.tar.gz && cd pcre-8.13/ && ./configure make && make install && cd ../
#安装Nginxtar -zxvf nginx-1.0.9.tar.gz && cd nginx-1.0.9 && ./configure --user=www --group=www \ --prefix=/usr/local/nginx \ --sbin-path=/usr/local/nginx/sbin/nginx \ --conf-path=/usr/local/nginx/conf/nginx.conf \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-pcre \ --lock-path=/var/run/nginx.lock \ --pid-path=/var/run/nginx.pid
make && make install && cd ../
#更改配置vi /usr/local/nginx/conf/nginx.conf
#修改一些参数,别直接替换文件,这只是一部分
user www
events {
use epoll;
worker_connections 1024;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#注意这里 #$document_root$fastcgi_script_name;
#检测配置文件
/usr/local/nginx/sbin/nginx -t
#提示表示成功 #nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok #nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
#开启Nginx /usr/local/nginx/sbin/nginx &
#平滑重启Nginx
/usr/local/nginx/sbin/nginx -s reload
#添加开机启动 vi /etc/rc.d/rc.local #最后移行加入 /usr/local/nginx/sbin/nginx
#测试 cd /usr/local/nginx/html/ touch index.php vi /usr/local/nginx/html/index.php <?php phpinfo(); ?>
转自:http://www.cnblogs.com/wubaiqing/archive/2011/11/08/2241195.html
Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17的更多相关文章
-
centos编译安装php5.6.20+nginx1.8.1+mysql5.6.17
LNMP 代表的就是:Linux系统下Nginx+MySQL+PHP这样的站点服务器架构. 本次实践需求: 实践centos6.5编译安装 LNMP生产环境 架构 web生产环境 使用 xcache ...
-
CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境
准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...
-
CentOS 6.6编译安装Nginx1.6.2+MySQL5.6.21+PHP5.6.3
http://www.osyunwei.com/archives/8867.html 一.配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables #编辑防火墙配置 ...
-
CentOS 6.6编译安装Nginx1.6.2+MySQL5.6.21+PHP5.6.3(转)
vi /etc/sysconfig/iptables #编辑防火墙配置文件 # Firewall configuration written by system-config-firewall # M ...
-
CentOS 7.2编译安装nginx1.10.3+MySQL5.5.38+PHP5.5.38
1.关闭firewallad 关闭防火墙 systemctl stop firewalld.service 禁止firewall开机启动 systemctl disable firewalld.ser ...
-
CentOS 7.4编译安装Nginx1.10.3+MySQL5.7.16
准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...
-
CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13
CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.132013-10-24 15:31:12标签:服务器 防火墙 file 配置文件 written 一.配置好I ...
-
CentOS 6.2编译安装Nginx1.2.0+MySQL5.5.25+PHP5.3.13+博客系统WordPress3.3.2
说明: 操作系统:CentOS 6.2 32位 系统安装教程:CentOS 6.2安装(超级详细图解教程): http://www.osyunwei.com/archives/1537.html 准备 ...
-
CentOS 7.2.1511编译安装Nginx1.10.1+MySQL5.7.14+PHP7.0.11
准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...
随机推荐
-
JS---DOM操作有哪一些
一 DOM对象有哪一些 1 windos 1.属性 opener 2.方法 open(),close() 例:<script langguage="javascript&qu ...
-
上传Text文档并转换为PDF(解决乱码)
前些日子,Insus.NET有分享一篇<上传Text文档并转换为PDF>http://www.cnblogs.com/insus/p/4313092.html 它是按最简单与默认方式来处理 ...
-
win7激活
应亲戚要求,装了次win7系统,重新删除分区,格盘,重新划分好分区.完毕.发现系统分区全自动变成动态磁盘.使用win7激活工具时,注意选择使用 小马通用版激活工具. 动态磁盘 稍后解释 小马工具
-
ActiveMQ之二--JMS消息类型
1.前言 //发送文本消息 session.createTextMessage(msg); //接受文本消息 public void onMessage(Message msg) { TextMess ...
-
pip 安装python环境及打包
0.安装虚拟环境 pip install virtualenv virtualenv env1 source env1/bin/activate 1. 将包依赖信息保存在requireme ...
-
WPF学习笔记-使用自定义资源字典(style)文件
1.添加资源字典文件style.xmal 2.在资源字典中添加自定义style等 <ResourceDictionary xmlns="http://schemas.microsoft ...
-
python 发包爬取中国移动充值页面---可判断手机号是否异常
1.用requests.Session()的方式,可以实现自动化管理cookie.session等. 2.具体流程可以抓包分析. 所有请求的参数如要搞清楚需要分析js源码.只能提示一下,一共分为三步: ...
-
c# 中 利用 CookieContainer 对 Cookie 进行序列化和反序列化校验
private void Form1_Load(object sender, EventArgs e) { var cookieStr = @".CNBlogsCookie=1BE76122 ...
-
UVa 11488 超级前缀集合(Trie的应用)
https://vjudge.net/problem/UVA-11488 题意: 给定一个字符串集合S,定义P(s)为所有字符串的公共前缀长度与S中字符串个数的乘积.比如P( {000, 001, 0 ...
-
du 统计文件夹大小
du -h --max-depth=1 |grep [TG] |sort #查找上G和T的目录并排序 du -sh #统计当前目录的大小,以直观方式展现 du -h --max-depth= ...