三、安装和配置apache

1:编译安装

tar zxvf httpd-2.2.8.tar.gz

cd httpd-2.2.8

./configure –prefix=/usr/local/apache2 –enable-so –enable-rewrite

echo $?

make && make install

/usr/local/apache2/bin/apachectl configtest

/usr/local/apache2/bin/apachectl start

/usr/local/apache2/bin/apachectl stop

2:修改默认启动页

vi /usr/local/apache2/conf/httpd.conf

DirectoryIndex index.html 改为

DirectoryIndex index.html index.htm default.htm default.html index.php index.php3 index.jsp

#ServerName www.example.com:80 改为

ServerName www.example.com:80

3:apache 开机启动的办法

(1):系统启动时服务自动启动

echo “/usr/local/apache2/bin/apachectl -k start” >>/etc/rc.local

(2):创建一个httpd启动脚本,内容如下:

cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd

(3):编辑修改启动文件

vi /etc/init.d/httpd

在第三行添加以下内容

#chkconfig:345 85 15

#description: Start and stops the Apache HTTP Server.

chmod +x /etc/rc.d/init.d/httpd

chkconfig –add httpd

4:修改乱码

步骤1:

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

在httpd.conf中将Include conf/extra/httpd-autoindex这个模块的注释去掉

步骤2:

vi /usr/local/apache/conf/extra/httpd-autoindex.conf

在httpd-autoindex.conf中加入IndexOptions Charset=UTF-8

 

四、mysql的安装和配置

1.安装编译器gcc

最小化安装,没有安装编译器

yum install gcc

安装 gcc-c++

如果不安装,在编译mysql的时候会出现【exec: g++: not found】错误

yum install gcc-c++

2.安装并配置mysql

1):安装ncurses

tar zxvf ncurses-5.6.tar.gz

cd ncurses-5.6

./configure –prefix=/usr –with-shared –without-debug

make

make install clean

2):安装mysql并设置mysql的root密码

yum -y install mysql-server

yum install mysql-devel

service mysqld start

cd /usr/bin/

mysqladmin -u root -h localhost password '123456'

3.登录mysql测试

mysql -u root -p

输入密码:123456

 

注:忘记mysql的root密码的修改方式

#service mysqld stop     //停止mysql

#cd /usr/bin

#mysqld_safe --skip-grant-tables &      //以不检查权限的方式启动mysql

#mysql -u root     //以空密码登录mysql

mysql> use mysql;    

mysql> update user set password=password('123456') where user='root';     //修改root密码为123456

mysql> flush privileges;    //刷新mysql的系统权限相关表,否则会出现拒绝访问

mysql> exit

ps –ef |grep mysql     //使用ps命令,查看mysql的pid号

kill -9 <pid>          //kill掉mysql的进程,正常情况下会有两个进程

service mysqld start     //启动mysql

现在就可以用新密码登录mysql了。