《2022年centos下源码编译方式安装lamp手记 .pdf》由会员分享,可在线阅读,更多相关《2022年centos下源码编译方式安装lamp手记 .pdf(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、centos下源码编译方式安装lamp 手记Author: Date:2012/4/6 前提:安装gcc 等可以编译c 源码的工具sudo-s LANG=C 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 cur
2、l-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers 首先到各自官方下载好源码:一、MySQL 的安装tar zxvf mysql-5.1.62.tar.gz cd mysql-5.1.62./configure-with-mysqld-user=mysql-prefix=/usr/local/mysql5-with-extra-ch
3、arset=all-without-isam-with-plugins=innobase-exec-prefix=/usr/local/mysql5 出现以下提示后就可以编译安装了Thank you for choosing MySQL!Remember to check the platform specific part of the reference manual for hints about installing MySQL on your platform.Also have a look at the files in the Docs directory.make&make
4、install groupadd mysql useradd-g mysql mysql scripts/mysql_install_db cp/usr/local/mysql5/share/mysql/my-f/usr/local/mysql5/var/f cp/usr/local/mysql5/share/mysql/mysql.server/etc/init.d/mysqld chkconfig-add mysqld 名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 9 页 -chkconfig-level 2345 mysqld on chown mysql:mysql-R
5、/usr/local/mysql5/service mysqld start ln-s/usr/local/mysql5/bin/mysql/sbin/mysql ln-s/usr/local/mysql5/bin/mysqladmin/sbin/mysqladmin 设定 mysql 密码mysqladmin-uroot password 123456 测试:netstat-nplt|grep mysql ps aux|grep mysql 二、Apache 的安装tar zxvf httpd-2.2.22.tar.gz cd httpd-2.2.22./configure-prefix=/
6、usr/local/apache2-enable-so-enable-rewrite make&make install /usr/local/apache2/bin/apachectl configtest /usr/local/apache2/bin/apachectl start /usr/local/apache2/bin/apachectl stop 修改默认启动页vi/usr/local/apache2/conf/httpd.conf DirectoryIndex index.html 改为DirectoryIndex index.html index.htm default.ht
7、m default.html index.phpdefault.php 三、安装 PHP模块在编译 php 的时候,出现如下错误php 安装出错:configure:error:mcrypt.h not found.Please reinstall libmcrypt.,意思是,没有查找到mcrytp.h,需要安装libcrytp,在下面的地址下载名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 9 页 -libmarypt:wget ftp:/mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.ta
8、r.gz 安装:tar-zxvf libmcrypt-2.5.7.tar.gz67 cd libmcrypt-2.5.768 mkdir-p/usr/local/libmcrytp ./configure prefix=/usr/local/libmcrytp/Make make install 然后再安装PHP tar zxvf php-5.3.10.tar.gz cd php-5.3.10 注意:-with-mcrypt=/usr/local/libmcrypt/,要不然会报错提示reinstall libmcrypt./configure-prefix=/usr/local/php5-w
9、ith-mysql=/usr/local/mysql5-with-mysqli=/usr/local/mysql5/bin/mysql_config-with-pdo_mysql=/usr/local/mysql5-with-apxs2=/usr/local/apache2/bin/apxs-with-iconv-dir-with-freetype-dir-with-jpeg-dir-with-png-dir-with-zlib-with-libxml-dir-enable-xml-disable-rpath-enable-bcmath-enable-shmop-enable-sysvsem-
10、enable-inline-optimization-with-curl-with-curlwrappers -enable-mbstring-with-mcrypt=/usr/local/libmcrypt/-with-gd-enable-gd-native-ttf-with-openssl-with-mhash-enable-pcntl-enable-sockets-with-ldap-with-ldap-sasl-with-xmlrpc-enable-zip-enable-soap 以下安装方式【】内可以跳过,此方法基本没有安装任何扩展,只是说明后续缺哪个模块的时候再怎样安装。【未安装任
11、何扩展方式,需要手动安装扩展./configure-prefix=/usr/local/php5-with-mysql=/usr/local/mysql5-with-apxs2=/usr/local/apache2/bin/apxs-with-gd-enable-ftp-enable-sockets cd/ext cd mysqli/usr/local/php5/bin/phpize./configure-prefix=/usr/local/mysqli-with-php-config=/usr/local/php5/bin/php-config-with-mysqli=/usr/local/
12、mysql5/bin/mysql_config make&make install 名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 9 页 -cd curl/usr/local/php5/bin/phpize./configure-with-php-config=/usr/local/php5/bin/php-config-enable-curl make&make install cd mbstring/usr/local/php5/bin/phpize./configure-with-php-con cd pdo_mysql/usr/local/php5/bin/phpize
13、./configure-with-php-config=/usr/local/php5/bin/php-config-with-pdo_mysql=/usr/local/mysql5/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/mysqli.so/usr/local/apache2/bin/apachectl restart Vi/usr/local/php5/lib/php.ini extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-200906
14、26/mysqli.so extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/mbstring.so extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/curl.so extension=/usr/local/php5/lib/php/extensions
15、/no-debug-non-zts-20090626/gd.so extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/iconv.so extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/pdo_mysql.so;extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/mysqli.so】/make ZEND_EXTRA_LIBS=
16、-liconv make make install 3:配置cp php.ini-production/usr/local/php5/lib/php.ini 编辑 httpd.conf 名师资料总结-精品资料欢迎下载-名师精心整理-第 4 页,共 9 页 -/usr/local/apache2/conf/httpd.conf 加载 php 模块,去掉注释,编译时指定apache 的路径会自动去掉注释LoadModule php5_module modules/libphp5.so 加上下面两行AddType application/x-httpd-php.php.phtml AddType a
17、pplication/x-httpd-php-source.phps rootlocalhost#/usr/local/apache2/bin/apachectl start httpd:Syntax error on line 62 of/usr/local/apache2/conf/httpd.conf:Cannot load/usr/local/apache2/modules/libphp5.so into server:/usr/local/apache2/modules/libphp5.so:cannot restore segment prot after reloc:Permis
18、sion denied php 安装好以后apache2 无法启动最后一步重新启动apache报如下错误原因是 Linux有一个 SELinux保护模式引起的。Syntax error on line 268 of/usr/local/apache2/conf/httpd.conf:Cannot load/usr/local/apache2/modules/libphp5.so into server:/usr/local/apache2/modules/libphp5.so:cannot restore segment prot after reloc:Permission denied 解
19、决办法原因是 Linux 有一个 SELinux 保护模式引起的。1.关闭 SELINUX 的方法:vi/etc linux/config 将 SELINUX=enforcing 改成 SELINUX=disabled 需要重启2.不关闭 SELINUX 的方法:#setenforce 0#chcon-c-v-R-u system_u-r object_r-t textrel_shlib_t/usr/local/apache2/modules/libphp5.so#/usr/local/apache2/bin/apachectl start#setenforce 1 名师资料总结-精品资料欢迎
20、下载-名师精心整理-第 5 页,共 9 页 -四、安装phpmyadmin tar-zxvf phpMyAdmin-3.5.0-rc2-all-languages.tar.gz cp-rf phpMyAdmin-3.5.0-rc2-all-languages/usr/local/apache2/htdocs/phpmyadmin 试试浏览器访问:http:/localhost/phpmyadmin 五、Apache 开启虚拟主机功能:vim/usr/local/apache2/conf/httpd.conf:400(找到大概 400行)#Include conf/extra/httpd-vho
21、sts.conf 去掉#vim/usr/local/apache2/conf/extra/httpd-vhosts.conf 注释掉默认的虚拟主机命令:28,43s/#/g 28#29#ServerAdmin webmasterdummy- 30#DocumentRoot/usr/local/apache2/docs/dummy- 31#ServerName dummy- 32#ServerAlias www.dummy- 33#ErrorLog logs/dummy-error_log 34#CustomLog logs/dummy-access_log common 35#名师资料总结-精
22、品资料欢迎下载-名师精心整理-第 6 页,共 9 页 -36 37#38#ServerAdmin webmasterdummy- 39#DocumentRoot/usr/local/apache2/docs/dummy- 40#ServerName dummy- 41#ErrorLog logs/dummy-error_log 42#CustomLog logs/dummy-access_log common 43#拷贝 37到43行内容到 46行:37,43 co 46 接着去掉 46行到 52行注释:46,52s/#/g 修改文件为:46 47 ServerAdmin 48 Documen
23、tRoot/home/wwwroot/ 49 ServerName 50 ErrorLog logs/-error_log 51 CustomLog logs/-access_log common 52 重启 apache/usr/local/apache2/bin/apachectl start 名师资料总结-精品资料欢迎下载-名师精心整理-第 7 页,共 9 页 -浏览器提示apache You dont have permission to access/on this server.愿意是网站根目录设置为:DocumentRoot/home/wwwroot/ 解决办法:vim/usr/
24、local/apache2/conf/httpd.conf:/Directory 搜索 Directory 118 119 Options FollowSymLinks 120 AllowOverride None 121 Order deny,allow 122#Deny from all 123 allow from all 124 把Deny from all修改为 allow from all 即可六、安装zend【5.3.X 可以跳过】wget http:/ tar-zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz cd ZendO
25、ptimizer-3.3.9-linux-glibc23-i386 mkdir/usr/local/php5/lib/extensions cp./data/5_2_x_comp/ZendOptimizer.so/usr/local/php5/lib/extensions/ZendOptimizer.so vim/usr/local/php5/lib/php.ini Shift+g到最后一行添加:zend_optimizer.optimization_level=15 zend_extension=/usr/local/php5/lib/extensions/ZendOptimizer.so名师资料总结-精品资料欢迎下载-名师精心整理-第 8 页,共 9 页 -以上就是CentOS下安装 LAMP 的方法,回头试着写一个一键安装shell脚本。名师资料总结-精品资料欢迎下载-名师精心整理-第 9 页,共 9 页 -