Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
2014-03-04 09:12
351 查看
算不上经验,只能说是个人总结.
在搭建过程中遇到的问题.并记录下来.
刚开学习始搭建环境的朋友少走一些弯路.
这没有过多的参数,并不是什么高性能网站的部署.
本人经验有限,在此分享一些遇到的问题.
操作环境
操作系统:MacOsLion
虚拟主机:VMwareFusion
虚拟系统:Centos5.5+
操作用户:Root
实现目的:搭建LNMP环境.
安装依赖库和开发环境
下载软件包
安装Mysql
http://downloads.skysql.com/archive/signature/p/mysql/f/mysql-5.5.17.tar.gz/v/5.5.17
安装PHP
安装Nginx
允许任何人转载,帮助更多的人,解决遇到的问题:
原文链接地址:/article/5268594.html
在搭建过程中遇到的问题.并记录下来.
刚开学习始搭建环境的朋友少走一些弯路.
这没有过多的参数,并不是什么高性能网站的部署.
本人经验有限,在此分享一些遇到的问题.
操作环境
操作系统:MacOsLion
虚拟主机:VMwareFusion
虚拟系统:Centos5.5+
操作用户:Root
实现目的:搭建LNMP环境.
安装依赖库和开发环境
#依赖库和开发工具 yum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-servers #Nginx yum-yinstallpcre-develzlib-devel #Php yum-yinstallgd-devellibjpeg-devellibpng-develfreetype-devellibxml2-develcurl-develfreetype-devel #Mysql yum-yinstallbisongccgcc-c++autoconfautomakezlib*libxml*ncurses-devellibtool-ltdl-devel*mysql-devel
下载软件包
#创建目录
mkdir/web
cd/web
#PHP5.3.7
wgethttp://cn.php.net/distributions/php-5.3.8.tar.bz2
#PHP库文件
wgethttp://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gzwget http://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gzwget http://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gzwget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#Nginx1.0.9
wgethttp://www.nginx.org/download/nginx-1.0.9.tar.gz
#Nginx(pcre)
wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.tar.gz
#Mysql5.5.17
wgethttp://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz/from/http://mysql.ntu.edu.tw/
#Mysql(cmake)
wgethttp://www.cmake.org/files/v2.8/cmake-2.8.6.tar.gz
安装Mysql
#安装cmake
tar-zxvfcmake-2.8.6.tar.gz
cdcmake-2.8.6/
./configure
gmake&&gmakeinstall&&cd../
#添加mysql用户
/usr/sbin/groupaddmysql
/usr/sbin/useradd-gmysqlmysql
mkdir-p/data/mysql
chown-Rmysql:mysql/data/mysql
#安装Mysql
tar-zxvfmysql-5.5.17.tar.gz
cdmysql-5.5.17
cmake.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql-DSYSCONFDIR=/etc/
make&&makeinstall
#设置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-urootpassword123456
#开启mysql
/usr/local/mysql/bin/mysqld_safe&
#测试连接mysql
/usr/local/mysql/bin/mysql-uroot-p123456
showdatabases;
exit;
#设置开机启动
vi/etc/rc.d/rc.local
#加入
/usr/local/mysql/bin/mysqld_safe&
安装PHP
#1
tar-zxvflibiconv-1.14.tar.gz&&cdlibiconv-1.14/
./configure--prefix=/usr/local
make&&makeinstall&&cd../
#2
tar-zxvflibmcrypt-2.5.8.tar.gz&&cdlibmcrypt-2.5.8/
./configure&&make&&makeinstall
/sbin/ldconfig&&cdlibltdl/&&./configure--enable-ltdl-install
make&&makeinstall&&cd../
#3
tar-zxvfmhash-0.9.9.9.tar.gz&&cdmhash-0.9.9.9/&&./configure
make&&makeinstall&&cd../
#4
ln-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
#5
tar-zxvfmcrypt-2.6.8.tar.gz&&cdmcrypt-2.6.8/
/sbin/ldconfig
./configure
make&&makeinstall&&cd../
#6
在这之前先执行以下操作,不然会提示Cannotfindldaplibrariesin/usr/lib错误
cp-frp/usr/lib64/libldap*/usr/lib/
tar-xjvfphp-5.3.8.tar.bz2
cdphp-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\
makeZEND_EXTRA_LIBS='-liconv'
#注意这里容易出现make:***[ext/phar/phar.php]错误127
#出现mysqlclient解决方法
#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(忽略)
#参考:(http://blog.sina.com.cn/s/blog_8701ca0201016g7m.html)
#解决方法在编译的时候加--without-pear参数
#或者执行以下命令
#wgethttp://pear.php.net/go-pear.phar#/usr/local/php/bin/phpgo-pear.phar然后再重新配置。
#如果还不行,make的时候不添加ZEND_EXTRA_LIBS='-liconv'参数
makeinstall
#选择PHP.ini配置文件
cpphp.ini-production/usr/local/php/etc/php.ini
更改PHP-FPM
#添加WWW用户
/usr/sbin/groupaddwww&&/usr/sbin/useradd-gwwwwww
mkdir-p/var/log/nginx&&chmod+w/var/log/nginx&&chown-Rwww:www/var/log/nginx
mkdir-p/data/www&&chmod+w/data/www&&chown-Rwww: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:configurationfile/usr/local/php/etc/php-fpm.conftestissuccessful测试成功
/usr/local/php/sbin/php-fpm&
#设置开机启动
vi/etc/rc.d/rc.local
#在行末加入
/usr/local/php/sbin/php-fpm&
#返回安装包目录
cd/web
安装Nginx
#安装pcre库
tar-zxvfpcre-8.13.tar.gz&&cdpcre-8.13/&&./configure
make&&makeinstall&&cd../
#安装Nginx
tar-zxvfnginx-1.0.9.tar.gz&&cdnginx-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&&makeinstall&&cd../
#更改配置
vi/usr/local/nginx/conf/nginx.conf
#修改一些参数,别直接替换文件,这只是一部分
userwww
events{
useepoll;
worker_connections1024;
}
location~\.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
#注意这里
#$document_root$fastcgi_script_name;
#检测配置文件
/usr/local/nginx/sbin/nginx-t
#提示表示成功
#nginx:theconfigurationfile/usr/local/nginx/conf/nginx.confsyntaxisok
#nginx:configurationfile/usr/local/nginx/conf/nginx.conftestissuccessful
#开启Nginx
/usr/local/nginx/sbin/nginx&
#平滑重启Nginx
/usr/local/nginx/sbin/nginx-sreload
#添加开机启动
vi/etc/rc.d/rc.local
#最后移行加入
/usr/local/nginx/sbin/nginx
#测试
cd/usr/local/nginx/html/
touchindex.php
vi/usr/local/nginx/html/index.php
<?php
phpinfo();
?>
允许任何人转载,帮助更多的人,解决遇到的问题:
原文链接地址:
相关文章推荐
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17详细配置
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.5.17
- Centos搭建PHP5.3.8+Nginx1.0.9+Mysql5.6.10
- [macOS] macOS下,VirtualBox安装CentOS7.4, 搭建nginx, mysql, PHP5.6&PHP7.1
- 阿里云服务器CentOS系统搭建php开发环境(apache+php+mysql)
- centos 搭建php运行环境
- 基于阿里云centOS服务器,LAMP环境搭建(linux+apache+mysql+php)
- CentOS PHP与memcache快速搭建
- centos6.3-64位搭建LAMP环境之安装php5.5.7
- CentOS源码安装搭建LNMP全过程(包括nginx,mysql,php,svn)
- centos7搭建lnmp编译安装php【一】
- 测试环境搭建之centos系统给php安装php-memcached模块
- CentOS 7 yum nginx MySQL PHP 简易环境搭建