linux下搭建LAMP环境
linux下LAMP环境搭建
需要的源代码
httpd-2.2.15.tar.gz mysql-5.1.44.tar.gz php-5.3.2.tar.gz
Discuz_7.2_FULL_SC_UTF8.zip
2,将需要的源代码准备好,复制到/usr/local/src/目录中
3,开始安装
[root@zhaoyun ~]# cd /usr/local/src/
[root@zhaoyun src]# ll
-r-xr-xr-x 1 root root 6593633 Aug 21 07:45 httpd-2.2.15.tar.gz
-r-xr-xr-x 1 root root 23400457 Aug 21 07:45 mysql-5.1.44.tar.gz
-r-xr-xr-x 1 root root 13734462 Aug 21 07:45 php-5.3.2.tar.gz
-r-xr-xr-x 1 root root 4704098 Sep 9 06:49 Discuz_7.2_FULL_SC_UTF8.zip
[root@zhaoyun src]# tar xzvf httpd-2.2.15.tar.gz 解压文件
[root@zhaoyun src]# cd httpd-2.2.15
[root@zhaoyun httpd-2.2.15]# ./configure —prefix=/usr/local/apache --enable-so; make ; make install
编译前要确定gcc已经安装
安装mysql
安装前配置
[root@zhaoyun ~]# useradd -s /sbin/nologin mysql 建一个mysql的用户
[root@zhaoyun ~]# mkdir /var/lib/mysql/ 建mysql的工作目录
[root@zhaoyun ~]# chown mysql.mysql /var/lib/mysql/ 修改目录的属主组为mysql
[root@zhaoyun ~]# cd /usr/local/src/
[root@zhaoyun src]# tar xzvf mysql-5.1.44.tar.gz
[root@zhaoyun mysql-5.1.44]# ./configure --prefix=/usr/local/mysql/ --sysconfdir=/etc --localstatedir=/var/lib/mysql/ ; make ; make install
将mysql安装到/usr/local/mysql 指定主配置文件目录到/etc目录 指定工作目录是/var/lib/mysql
安装完成后复制一下配置文件
[root@zhaoyun ~]#cd /usr/local/mysql/share/mysql
[root@zhaoyun mysql]# cp my-medium.cnf /etc/my.cnf
运行mysql初始化
[root@zhaoyun mysql]# cd /usr/local/mysql/bin/
[root@zhaoyun bin]# ./mysql_install_db
然后在/var/lib/mysql/目录中生成好多文件 将他们的属主和属组更改为mysql
[root@zhaoyun bin]## chown -R mysql.mysql /var/lib/mysql/
[root@zhaoyun bin]# ./mysqld_safe & 后台运行mysql的支持程序
[root@zhaoyun bin]# ./mysql 试着运行一下看行不行
安装PHP
[root@zhaoyun src]# tar xzvf php-5.3.2.tar.gz
[root@zhaoyun src]# cd php-5.3.2
[root@zhaoyun php-5.3.2]# ./configure --prefix=/usr/local/php5 --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs : make ; make install
[root@zhaoyun ~]# cd /usr/local/src/php-5.3.2
[root@zhaoyun php-5.3.2]# cp php.ini-development /usr/local/php5/lib/php.ini
[root@zhaoyun php-5.3.2]# vi /usr/local/apache/conf/httpd.conf
修改apache的配置文件
修改ServerName 192.168.0.205:80
在有AddType附近添加AddType application/x-httpd-php .php
查找 DirectoryIndex index.html 添加index.php中间加,号
重启apache程序
[root@zhaoyun ~]# cd /usr/local/apache/bin/
[root@zhaoyun bin]# ./apachectl restart
测试支持PHP
[root@zhaoyun php-5.3.2]# cd /usr/local/apache/htdocs/
[root@zhaoyun htdocs]# vi test.php
添加 <? php
phpinfo( );
?>
打开浏览器输入http://192.168.0.205/test.php 测试是否支持php
安装论坛程序
设置mysql
[root@zhaoyun bin]# ./mysqladmin -u root -p password 123456 给mysql设密码
[root@zhaoyun bin]# ./mysql -u root -p
Enter password: 输入密码123456
mysql> create database bbsdb; 创建一个数据库
Query OK, 1 row affected (0.00 sec)
mysql> grant all on bbsdb.* to zhaoyun@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql>quit
安装论坛 解压
[root@zhaoyun src]# unzip Discuz_7.2_FULL_SC_UTF8.zip
[root@zhaoyun src]# mv upload/ /usr/local/apache/htdocs/ 解压后