设为首页 收藏本站
查看: 823|回复: 0

linux centos lamp环境配置

[复制链接]

尚未签到

发表于 2015-8-19 11:16:33 | 显示全部楼层 |阅读模式
yum install zlib-devel openssl-devel
一.下载Apache :http://labs.renren.com/apache-mirror//httpd/httpd-2.2.17.tar.gz
下载mysql :http://download.freelamp.com/LAMP/mysql-5.0.41.tar.gz
下载 php:http://cn.php.net/distributions/php-5.2.14.tar.gz
下载ncurses:http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
下载jpeg6:http://down1.chinaunix.net/distfiles/jpegsrc.v6b.tar.gz
下载 libpng http://down1.chinaunix.net/distfiles/libpng-1.2.10.tar.bz2
下载  freetype  http://down1.chinaunix.net/distfiles/freetype-2.3.9.tar.bz2
下载 zlib -1.2.3.tar.gz: http://download.chinaprj.cn/detail/iDssDTsO
下载gd-2.0.33.tar.gz:http://down1.chinaunix.net/distfiles/gd-2.0.33.tar.gz
下载 curl-7.18.2.tar.bz2   http://down1.chinaunix.net/distfiles/curl-7.18.2.tar.bz2
下载  libxml2-2.7.2.tar.gz  http://down1.chinaunix.net/distfiles/libxml2-2.7.2.tar.gz
下载  libxslt-1.1.23.tar.gz  http://down1.chinaunix.net/distfiles/libxslt-1.1.23.tar.gz
二. 安装Apache
1.解压:[iyunv@localhost src]# tar zxvf httpd-2.2.16.tar.gz
   2.[iyunv@localhosthttpd-2.2.16]#./configure --prefix=/usr/local/apache2 --with-included-apr --with-mpm=worker --enable-deflate --enable-cache --enable-disk-cache --enable-file-cache --enable-mem-cache --enable-rewrite --enable-so --enable-speling --enable-ssl --with-apr --with-apr-util --with-ssl --with-z --enable-modules=all --enable-mods-shared=all
编译指令的说明如下
--prefix=/usr/local/apache2
  //Apache的安装目录。
--enable-module=so
  //打开 so 模块,so 模块是用来提 DSO 支持的 apache 核心模块
--enable-deflate=shared //支持网页压缩
--enable-expires=shared //支持 HTTP 控制
--enable-rewrite=shared //支持 URL 重写
--enable-cache //支持缓存
--enable-file-cache //支持文件缓存
--enable-mem-cache //支持记忆缓存
--enable-disk-cache //支持磁盘缓存
--enable-static-support //支持静态连接(默认为动态连接)
--enable-static-htpasswd
  //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件
--enable-static-htdigest
  //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件
--enable-static-rotatelogs
  //使用静态连接编译 rotatelogs - 滚动 Apache 日志的管道日志程序
--enable-static-logresolve
  //使用静态连接编译 logresolve - 解析 Apache 日志中的IP地址为主机名
--enable-static-htdbm
  //使用静态连接编译 htdbm - 操作 DBM 密码数据库
--enable-static-ab
  //使用静态连接编译 ab - Apache HTTP 服务器性能测试工具
--enable-static-checkgid
  //使用静态连接编译 checkgid
--disable-cgid
  //禁止用一个外部 CGI 守护进程执行CGI脚本
--disable-cgi //禁止编译 CGI 版本的 PHP
--disable-userdir //禁止用户从自己的主目录中提供页面
--with-mpm=worker // 让apache以worker方式运行
--enable-authn-dbm=shared // 对动态数据库进行操作。Rewrite时需要。
按照apache官方文档的说法,--enable-mods-shared=all并不会启用
所有的额外模块,要想把所有的模块都安装,应该使用
--enable-mods-shared="all ssl ldap cache proxy authn_alias mem_cache
         file_cache authnz_ldap charset_lite dav_lock disk_cache"
对 --enable-modules也是一样的。呵呵,好强大。
3.启动Apache
[iyunv@localhost ]# cd  /usr/local/apache2/bin
[iyunv@localhost bin]# ./apachectl start
[iyunv@localhost bin]# netstat -an | grep 80
tcp        0      0 :::80                 :::*                     LISTEN      
4.访问:http://ip 显示 It works!
5.编辑httpd.conf 支持php
找到index.html 在后面添加index.php
找到“AddType application/x-gzip .tgz”这一行,在下面添加
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
找到“DirectoryIndex index.html”,改为:  DirectoryIndex index.php index.html找到“#ServerName”,去掉注释的#号。
将所有“AllowOverride None”,改为:  AllowOverride All
6.设置开机启动:
[iyunv@localhost apache2]# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
[iyunv@localhost apache2]# chmod 755 /etc/rc.d/init.d/httpd

三.安装Mysql
1.[iyunv@localhost src]# tar zxvf ncurses-5.6.tar.gz
2[iyunv@localhost ncurses-5.6]#./configure
3.[iyunv@localhost ncurses-5.6]#make && make install
4.解压:tar zxvf mysql-5.0.41.tar.gz
5.[iyunv@localhostmysql-5.0.41]# ./configure --prefix=/usr/local/mysql --enable-assembler  --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --with-charset=utf8  --with-collation=utf8_general_ci --with-extra-charsets=complex --enable-local-infile  --disable-shared --with-plugins=all --with-mysqld-user=mysql --with-pthread   --enable-thread-safe-client
6.[iyunv@localhostmysql-5.0.41]#make && make install
编译配置指令的意思是,
--enable-assembler  
  # 启用寄存器模式
--with-client-ldflags=-all-static
  #为客户端编译静态程序
--with-mysqld-ldflags=-all-static
  #为服务器端编译静态程序
--with-charset=utf8
  #数据库编码使用utf8,默认的是latin1,可以设置的是
  #binary armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257
  #cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8
  #greek hebrew hp8 keybcs2 koi8r koi8u
  #latin1 latin2 latin5 latin7 macce macroman
  #sjis swe7 tis620 ucs2 ujis utf8
--with-collation =
  #数据库校验规则,--with-carset要和withc-collation一起使用才有效。
  #要想更改字符集和校对规则,要同时使用--with-charset和--with-collation选项。
  #校对规则必须是字符集的合法校对规则。参见下面的链接
--with-extra-charsets=complex  
  #增加对复杂编码的支持(可选,none, complex, all)
--with-plugins=all
  #安装所有插件,默认不安装,可以使用一系列逗号分隔符来描述要安装的内容。
  #可用的配置为 none max max-no-ndb all
  #可用的插件为 partition daemon_example
  #ftexample archive blackhole csv example federated
  #heap ibmdb2i innobase innodb_plugin myisam myisammrg
  #ndbcluster.
--with-mysqld-user=mysql  
  #指定mysql守护进程的启动用户
--disable-shared
  # 禁用共享库
--with-pthread  
  #强制使用pthread库
--enable-thread-safe-client  
  #如果客户端使用多线程,那么应该使用此选项以编译线程安全的客户端
还有一些编译指令是,
--prefix=/usr/local/mysql  # 不说了
--with-tcp-port=3306
  #mysqld守护进程使用的端口,默认就是3306
--with-unix-socket-path=/tmp/mysql.sock
  #unix套接字库路径,默认是/tmp/mysql.sock
--with-debug 和 --with-debug=full  
  #生成调试代码和库 witout-debug关闭调试
7.初始化授权表
cd /usr/local/mysql/bin/
   ./mysql_install_db --user=mysql
8.启动 mysql
[iyunv@localhost bin]# ./mysqld_safe --user=mysql &
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld (添加守护进程)
chmod +x /etc/init.d/mysql (添加执行权限)
chkconfig --level 345 mysql on (chkconfig设置守护进程自动启动)
9.mysql配置文件
[iyunv@localhost mysql]# cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
10.修改密码
修改root用户密码
[iyunv@tigertall local]# mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpwd');
mysql> SET PASSWORD FOR 'root'@'host_name' = PASSWORD('newpwd');
用服务器主机名替换第二个SET PASSWORD语句中的host_name。这是你指定匿名账户密码的主机名。
要想使用mysqladmin为root账户指定密码,执行下面的命令:
[iyunv@tigertall local]# mysqladmin -u root password "newpwd"
[iyunv@tigertall local]# mysqladmin -u root -h host_name password "newpwd"
四:安装GD库(让PHP支持GIF,PNG,JPEG)
a.安装 jpeg6建立目录:
# mkdir -p /usr/local/jpeg6
# mkdir -p /usr/local/jpeg6/bin
# mkdir -p /usr/local/jpeg6/lib
# mkdir -p /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man
# mkdir -p /usr/local/jpeg6/man1
# mkdir -p /usr/local/jpeg6/man/man1
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make && make install
b.安装libpng
# tar -zvxf libpng-1.2.10.tar.gz
# cd libpng-1.2.10
# cp scripts/makefile.std makefile
# make && make install
c.安装 freetype
# tar -jvxf freetype-2.3.9.tar.bz2
# cd freetype-2.3.9# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype
# make && make install
d.:安装zlib
#tar -zxvf zlib-1.2.3.tar.gz
#cd zlib.1.2.3
# ./configure
# make && make install
e.安装GD库
# tar -zvxf gd-2.0.33.tar.gz
# mkdir -p /usr/local/gd2
# cd gd-2.0.33
#./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ --with-png=/usr/local/lib/  --with-zlib=/usr/local/lib/ --with-freetype=/usr/local/freetype/
# make && make install
e.安装Curl库# tar -jxf curl-7.18.2.tar.bz2
# mkdir -p /usr/local/curl
# ./configure --prefix=/usr/local/curl
# make &&  make install
五:安装php5,php5必须有libxml2支持!
a.安装libxml2
b.# tar -zxf libxml2-2.6.19.tar.gz
c.# cd libxml2-2.6.19
d.# mkdir -p /usr/local/libxml2
e.# ./configure --prefix=/usr/local/libxml2
f.# make && make install
b.安装 libxslt(可选安装,你可以不安装)
# tar -zxf libxslt-1.1.15.tar.gz
# mkdir -p /usr/local/libxslt# cd libxslt-1.1.15
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make &&  make install

五.安装PHP
1.编译./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs  --with-mysql=/usr/local/mysql --with-curl=/usr/local/curl --enable-ftp  --with-libxml-dir=/usr/local/libxml2 --with-expat-dir=/usr/lib --enable-soap  --with-xsl=/usr/local/libxslt --enable-xslt --with-gd=/usr/local/gd2/  - -with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/lib/ --with-png=/usr/local/lib/  - -with-freetype-dir=/usr/local/freetype/
2. make && make install
3.php.ini
cp php.ini-dist /usr/local/php/lib/php.ini
3.编译说明:
其中./configure 后的
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql/
--with-libxml-dir=/usr/local/libxml2
是必要的选项
--with-gd=/usr/local/gd2/
--with-jpeg-dir=/usr/local/jpeg6/
--with-png=/usr/local/lib
--with-zlib-dir=/usr/lib
--with-freetype-dir=/usr/local/freetype
这是让PHP支持GD库的配置选项
--with-curl=/usr/local/curl 支持CURL库
--enable-ftp 打开FTP库函数支持
--enable-soap --with-xsl=/usr/local/libxslt --enable-xslt
让PHP支持SOAP, 上面这些一般用得少, 可以去掉
4.进行php.ini文件的配置工作
查找safe_mode=Off,更改为safe_mode=On
1)查找max_execution_time = 30,更改为max_execution_time = 600
(2)查找max_input_time = 60,更改为max_input_time = 600
(3)查找memory_limit = 128M ,更改为memory_limit = 512M
(4)查找display_errors = On,更改为display_errors = Off
(5)查找register_globals = Off,更改为register_globals = On

六.最后阶段
在Apache目录下添加index.php 测试
[iyunv@localhost apache2]# cat htdocs/index.php
<?
phpinfo();
?>

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-101073-1-1.html 上篇帖子: centos 安装lamp环境 下篇帖子: [转]在ubuntu linux下以编译方式安装LAMP(apache mysql php)环境
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表