您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 销售管理 > Linux下web服务器环境搭建
RedHatLinuxAS4下整合安装mysql-5.1.37、apache-2.2.13、php-5.3.0与zendoptions并支持GD库以下所有操作请注意是在root账号权限下执行。一、准备工作:首先查看系统中是否已经安装了GD环境:[root@localhost~]#rpm-qa|grepzlib[root@localhost~]#rpm-qa|greplibpng[root@localhost~]#rpm-qa|grepfreetype[root@localhost~]#rpm-qa|grepjpeg[root@localhost~]#rpm-qa|grepgd如果没有安装的话,可以按照下面的步骤手动安装:1.1安装zlib[root@localhost~]#tarzxvfzlib-1.2.2.tar.gz[root@localhost~]#cdzlib-1.2.2[root@localhost~]#./configure[root@localhost~]#make[root@localhost~]#makeinstall1.2安装libpng[root@localhost~]#tarzxvflibpng-1.2.7.tar.tar[root@localhost~]#cdlibpng-1.2.7[root@localhost~]#cdscripts/[root@localhost~]#mvmakefile.linux../makefile[root@localhost~]#cd..[root@localhost~]#make[root@localhost~]#makeinstall注意,这里的makefile不是用./configure生成,而是直接从scripts/里复制一个。1.3安装freetype[root@localhost~]#tarzxvffreetype-2.1.9.tar.gz[root@localhost~]#cdfreetype-2.1.9[root@localhost~]#./configure[root@localhost~]#make[root@localhost~]#makeinstall[/quote]1.4安装Jpeg[root@localhost~]#tarzxvfjpegsrc.v6b.tar.gz[root@localhost~]#cdjpeg-6b/[root@localhost~]#./configure--enable-shared[root@localhost~]#make[root@localhost~]#maketest[root@localhost~]#makeinstall注意:这里configure一定要带--enable-shared参数,不然,不会生成共享库1.5安装GD[root@localhost~]#tarzxvfgd-2.0.33.tar.gz[root@localhost~]#cdgd-2.0.33[root@localhost~]#./configure--with-png--with-freetype--with-jpeg[root@localhost~]#makeinstall二、安装mysql2.1解压缩[root@localhost~]#unzipmysql-5.1.37.zip[root@localhost~]#cdmysql-5.1.372.2创建MYSQL用户和组[root@localhostmysql-5.1.37]#groupaddmysql[root@localhostmysql-5.1.37]#useradd-gmysqlmysql2.3编译前配置mysql安装路径为/usr/local/mysql[root@localhostmysql-5.1.37]#./configure--prefix=/usr/local/mysql2.4开始编译[root@localhostmysql-5.1.37]#make2.5安装[root@localhostmysql-5.1.37]#makeinstall2.6数据库初始化相关操作[root@localhostmysql-5.1.37]#cdscripts/[root@localhostscripts]#./mysql_install_db--user=mysql[root@localhostscripts]#cp../support-files/my-medium.cnf/etc/my.cnf编辑/etc/my.cnf,加入下面一行内容:user=mysql更改部分目录权限,增强安全性。[root@localhostscripts]#chown-Rroot/usr/local/mysql/[root@localhostscripts]#chown-Rmysql/usr/local/mysql/var[root@localhostscripts]#chgrp-Rmysql/usr/local/mysql/编辑/etc/ld.so.conf并加入以下两行:[root@localhostscripts]#vi/etc/ld.so.conf/usr/local/mysql/lib/mysql/usr/local/lib编辑完后载入库[root@localhostscripts]#ldconfig-v2.7启动数据库[root@localhostscripts]#cd/usr/local/mysql/bin/[root@localhostbin]#./mysqld_safe--user=mysql&2.8设置数据库root密码[root@localhostbin]#mysqladmin-urootpassword'newpassword'注意“password”和’newpassword’之间必须有空格。2.9测试安装结果,可有可无的一步******************************************************[root@localhostbin]#mysql-uroot-pEnterpassword:WelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis5toserverversion:5.1.37-logType'help;'or'\h'forhelp.Type'\c'toclearthebuffer.mysqlusemysqlDatabasechanged******************************************************当你看到以上内容的时候,恭喜你,数据库已经安装成功了。三、安装apache3.1解压缩[root@localhost~]#tar-zxvfhttpd-2.2.13.tar.gz[root@localhost~]#cdhttpd-2.2.133.2配置安装路径和加载方式,在此选择动态加载方式,以便节约系统资源。[root@localhosthttpd-2.2.13]#./configure--prefix=/usr/local/apache--enable-module=so3.3编译[root@localhosthttpd-2.2.13]#make3.4安装[root@localhosthttpd-2.2.13]#makeinstall3.5测试apache[root@localhosthttpd-2.2.13]#/usr/local/apache/bin/apachectlstart&[root@localhostbin]#ps-A|grephttpd********************************************************17971?00:00:00httpd17972?00:00:00httpd17973?00:00:00httpd17974?00:00:00httpd17975?00:00:00httpd17976?00:00:00httpd*******************************************************安装apache是整个过程中最简单的,当你看到以上内容的时候表明你的apache已经安装成功了,。下面继续安装PHP,安装完php后再配置apache。四、安装PHP4.1解压缩[root@localhost~]#tar-zxvfphp-5.3.0.tar.gz4.2配置PHP安装路径apache路径和mysql路径,其他内容为支持GD库的配置,如果还需要扩展其他功能的话可以继续添加,不是必要的功能尽量不要安装,减少出现安全漏洞的机会。[root@localhost~]#cdphp-5.3.0[root@localhostphp-5.3.0]#./configure--prefix=/usr/local/php--with-mysql=/usr/local/mysql--with-apxs2=/usr/local/apache/bin/apxs–with-gd--enable-gd-native-ttf--enable-gd-jis-conv--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--enable-xml--enable-mbstring注意:一行写不开时,请在行尾加上”\”换行,不想一点点敲入,复制粘贴时请先粘贴到记事本中去掉格式。如果没错误的话,你将会看到以下内容。******************************************************+--------------------------------------------------------------------+|License:||ThissoftwareissubjecttothePHPLicense,availableinthis||distributioninthefileLICENSE.Bycontinuingthisinstallation||process,youareboundbythetermsofthislicenseagreement.||Ifyoudonotagreewiththetermsofthislicense,youmustabort||theinstallationprocessatthispoint.|+--------------------------------------------------------------------+ThankyouforusingPHP.********************************************************4.3编译[root@localhostphp-5.3.0]#make编译完成后可以运行一下maketest看看是否有被忽略的错误。[root@localhostphp-5.3.0]#maketest4.4安装[root@localhostphp-5.3.0]#makeinstall五、安装完php后开始配置apache编辑apache的配置文件httpd.conf[root@localhostphp-5.3.0]vi/usr/local/apahe/conf/httpd.conf5.1加上AddTypeapplication/x-httpd-php.php//让apache将后缀为.php的文件交给PHP处理。5.2找到DirectoryIndex一行修改为:DirectoryIndexindex.htmindex.phpindex.html5.3找到OptionsIndexFollowSymLinks
本文标题:Linux下web服务器环境搭建
链接地址:https://www.777doc.com/doc-1579593 .html