在linux下搭建服务环境:linux+mysql+apache+php

安装 APACHE
============================================================================
tar -xzvf httpd-2.2.9.tar.gz
cd httpd-2.2.9/

./configure \
LDFLAGS="-L/usr/lib64 -L/lib64" \
--prefix=/usr/local/apache \
--enable-so \
--enable-rewrite \
--disable-authn-default \
--disable-authz-default \
--disable-include \
--disable-filter \
--disable-log-config \
--disable-env \
--disable-setenvif \
--disable-status \
--disable-asis \
--disable-cgid \
--disable-cgi \
--disable-negotiation \
--disable-actions \
--disable-userdir \
--enable-modules=most \
--enable-mods-shared=most \
--enable-vhost-alias \
--enable-proxy \
--enable-proxy-connect \
--enable-proxy-http \
--enable-headers \
--enable-deflate \



make
make install


--------------------------------------------------------------------
启动Apache和测试
--------------------------------------------------------------------
[root@diaoge /]#  /usr/local/apache/bin/apachectl start
[root@diaoge /]#  /usr/local/apache/bin/apachectl stop
[root@diaoge /]#  /usr/local/apache/bin/apachectl restart




MYSQL
============================================================================
## 源码的安装方式
./configure \
--prefix=/usr/local/mysql \
--without-debug \
--without-man \
--without-docs \
--without-bench \
--with-charset=utf8 \
--with-extra-charsets=gbk,big5,gb2312 \
--enable-thread-safe-client
--sharedstatedir=/var/lib/mysql \
--sysconfdir=/usr/local/etc \

## 已编译的安装方式
/**********************************************
查看安装目录下的文件 INSATLL-README
***********************************************/
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /root/diaoge
shell> tar -xzvf mysql-5.0.67-linux-i686-icc-glibc23.tar.gz
shell> cp -rp mysql-5.0.67-linux-i686-icc-glibc23 /usr/local/mysql
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> ./bin/mysqld_safe --user=mysql & (启动数据库)
shell> ./bin/mysqladmin -u root password 'new-password'
shell> ./bin/mysql -uroot -p'new-password'
##### (登录Mysql后设置用户表中,可供连接的IP,同时要打开3306的防火墙)
**********************************************************************************
mysql> use mysql;
mysql> select Host,User,Password from user;
mysql> update user set Host='%' where Host='localhost';
mysql> select Host,User,Password from user;
mysql> exit;
**********************************************************************************
shell> ./bin/mysqladmin -uroot -p shutdown (关闭数据库)
shell> chown -R root .
shell> chown -R mysql data


#Alternatively you can run:
#shell> ./bin/mysql_secure_installation
#which will also give you the option of removing the test
#databases and anonymous user created by default.  This is
#strongly recommended for production servers.

#To start mysqld at boot time you have to copy
#support-files/mysql.server to the right place for your system




安装libpng
===========================================================================
www.libpng.org/pub/png/libpng.html
libpng-1.2.32.tar.gz

./configure \
--prefix=/usr/local/png \

make
make install








安装FreeType2
===========================================================================
http://www.freetype.org/
freetype-2.3.7.tar.gz

./configure \
--prefix=/usr/local/freetype \

make
make install





安装jpegv6b(未能安装成功)
============================================================================
http://www.ijg.org/files/
jpegsrc.v6b.tar.gz

./configure \
--prefix=/usr/local/jpeg \
--enable-shared \
--enable-static \

make
make install

## 不知道为什么 要我自己帮他建目录的
[root@localhost local]# mkdir jpeg
[root@localhost local]# cd jpeg/
[root@localhost jpeg]# mkdir include
[root@localhost jpeg]# mkdir lib
[root@localhost jpeg]# mkdir bin
[root@localhost jpeg]# mkdir man
[root@localhost jpeg]# cd man
[root@localhost man]# mkdir man1



安装 zlib
==================================================================================
http://www.zlib.net/
zlib-1.2.3.tar.gz

./configure \
--prefix=/usr/local/zlib \

make
make install








安装GD Library
================================================================================
http://www.libgd.org/Main_Page
gd-2.0.35.tar.gz

./configure \
LDFLAGS="-L/usr/lib64 -L/lib64" \
--prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg \
--with-png=/usr/local/png \
--with-zlib=/usr/local/zlib \
--with-freetype=/usr/local/freetype \

make (如果make第一次不行时,可以再次make)
make install




/*
重新编译 需要运行 make clean
*/
make clean

PHP
============================================================================
./configure  \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-curl \
--with-mysql=/usr/local/mysql \
--enable-ftp \
--enable-zip \
--enable-mbstring=cn \
--enable-mbregex \
--enable-calendar \
--disable-debug \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir=/usr/local/png \
--enable-ctype \
--with-zlib-dir=/usr/local/zlib \
--with-gd=/usr/local/gd \
--with-gettext \

make
#[make test](如果make test不通过, 则可以参考 "在PHP安装过程可能出现的异常处理".)
make install

# 在编译文件夹那里有一个 php.ini-dist
cp php.ini-dist /usr/loca/php/lib/php.ini







/****************************/
安装后对服务器的 配置
/****************************/



/usr/local/apache/conf/httpd.conf 

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
的下面加

  AddType application/x-httpd-php .php
  AddType application/x-httpd-php .php3
  AddType application/x-httpd-php-source .phps

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

改成

<IfModule dir_module>
    DirectoryIndex index.php index.html index.htm
</IfModule>

/usr/local/apache/htdoc  设置用户
chown -R daemon:daemon ./*


apache 启动和 关闭
/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl restart



mysql 启动和关闭
/usr/local/mysql/support-files/mysql.server stop
/usr/local/mysql/support-files/mysql.server start
/usr/local/mysql/support-files/mysql.server restart
注意的data 文件夹的权限

***注意:如果要让别的机器也能连接到mysql数据库,则必须让防火前允许mysql的端口********

找不到  my.cnf
mysql的安装目录下的 support-files/my-small.cnf  复制到 /etc/my.cnf
shell> cp mysql/support-files/my-small.cnf /etc/my.cnf


找不到php.ini ?
在编译文件夹那里有一个 php.ini-dist
shell> cp php.ini-dist /usr/loca/php/lib/php.ini




安装zend
=============================================================================
直接运行  ./install 就OK (要配置 php.ini 和 apachectl)

安装完毕后必须重新启动lInux操作系统









设置Linux启动时默认启动Mysql数据库和Apache服务器
==========================================================================
shell> vim /etc/rc.local
假如下的脚本:

# Start mysql server when Linux system starts
/usr/local/mysql/support-files/mysql.server start

#Start apache server when Linux system starts
/usr/local/apache/bin/apachectl start













apache 启动和 关闭
********************************************************************************
/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl restart



mysql 启动和关闭
*********************************************************************************
/usr/local/mysql/support-files/mysql.server stop
/usr/local/mysql/support-files/mysql.server start
/usr/local/mysql/support-files/mysql.server restart












/*******************************************************
在PHP安装过程可能出现的异常处理
******************************************************/
(如果Linux系统已经把Selinux关闭掉,则不会再出现该问题.建议关掉系统的SELinux)
编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing

如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。

如果你碰到其他类似提示:
cannot restore segment prot after reloc: Permission denied
哪应该是SELinux的问题,可以考虑把它关闭。
-------------------------------------------------------------------------------------
郁闷的是.我把SELinux关闭后还是不行.于是到google上search.发现这个很有用.
在你保证SElinux 被disable后.还执行下
chcon -t texrel_shlib_t
如: chcon -t texrel_shlib_t /路径/路径/名字.so (这个文件视具体执行文件.)

以上两步.已经解决了很多server的问题了.














2、检查libjpeg是否安装
rpm -qa | grep libjpeg
没有的话编译libjpeg 这里下载
我也没装libjpeg,下载好开始编译
jpegsrc.v6b.tar.gz
tar -xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure --prefix=/usr/local/jpeg --enable-shared
make && make install
最后一步make install 出错:
/usr/bin/install -c -m 644 jconfig.h /usr/local/jpeg/include/jconfig.h
/usr/bin/install: cannot create regular file `/usr/local/jpeg/include/jconfig.h': No such file or directory
make: *** [install-headers] Error 1
/usr/bin/install: cannot create regular file `/usr/local/jpeg/lib/libjpeg.so.62.0.0': No such file or directory
/usr/bin/install: cannot create regular file `/usr/local/jpeg/bin/cjpeg': No such file or directory
make: *** [install-lib] Error 1
难道安装程序自己新建一下目录都不行??晕,我自己去新建目录
mkdir -p /usr/local/jpeg/include
mkdir -p /usr/local/jpeg/lib
mkdir -p /usr/local/jpeg/bin
mkdir -p /usr/local/jpeg/man/man1
OK再编译就成功了








/***************注意****************/
php的源代码bbs和space必须采用二进制上传到服务器





求助,,急,数据导入后出现的问题
任意点版块连接的时候就会出现;
Discuz! info: MySQL Query Error

User: admin
Time: 2008-1-27 3:03am
Script: /forumdisplay.php

SQL: SELECT gid, groupname FROM wolf771122.supe_groupuid WHERE uid='1' AND flag>0
Error: Table 'wolf771122.supe_groupuid' doesn't exist
Errno.: 1146

Similar error report has beed dispatched to administrator before.
提示,,,请问怎么解决,,,急

解决方法:
进入论坛 ---进入后台----扩展设置----------SupeSite设置---------参数设置----------SupeSite 表前缀XXXXX.supe_改成supe_   -----------提交-----------更新缓存----------OK了

(如果原本也是supe_,只要重新提交就行了)













/*****************************************************
* Linux 的一些常用操作
******************************************************/

修改Linux的IP地址
=======================================================
[root@diaoge ~]#  ifconfig eth0 192.168.0.20 netmask 255.255.255.0


删除文件和文件夹
========================================================
[root@diaoge ~]# rm -rf 文件名(文件夹名)


查找rpm安装过的包
========================================================
rpm -qa | grep  文件名


Linux下对防火墙的一些基础操作
========================================================
在此说一下关于启动和关闭防火墙的命令:
1) 重启后生效
开启: chkconfig iptables on
关闭: chkconfig iptables off 网管朋友网www_bitscn_net
2) 即时生效,重启后失效
开启: service iptables start
关闭: service iptables stop 网管网www.bitscn.com
需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。
在开启了防火墙时,做如下设置,开启相关端口,修改/etc/sysconfig/iptables 文件,添加以下内容:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT


一台Linux远程传文件到另一台Linux
================================================================================
[root@ci com.hotye]# scp -r /home/images root@131.1.2.16:/home


通过安装JDK实例设置 Linux环境变量
=================================================================================
#./jdk-1_5_0_04-linux-i586-rpm.bin
#rpm -ivh jdk-1_5_0_04-linux-i586.rpm
选择“yes”,直到安装完毕;
完成后安装在/usr/java/jdk1.5.0_04下,打开/etc/profile文件,在最后增加如下内容
JAVA_HOME=/usr/java/jdk1.5.0_04
export JAVA_HOME
CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export CLASSPATH
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH
保存,OK,成功,重新启动系统后,可以开始linux下的java程序开发了。



设置Linux启动时默认启动Mysql数据库和Apache服务器
==========================================================================
shell> vim /etc/rc.local
假如下的脚本:

# Start mysql server when Linux system starts
/usr/local/mysql/support-files/mysql.server start

#Start apache server when Linux system starts
/usr/local/apache/bin/apachectl start



创建文件
====================================================================================
touch 文件名


创建目录
====================================================================================
mkdir



重命名或移动文件和目录
====================================================================================
mv


设置目录和文件的权限
====================================================================================
chmod



设置目录或文件的所有者
=====================================================================================
chown -R user:group /home/hotye


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值