LAMP环境搭建手册
Linux系统: CentOS 6.5 编译软件: httpd-2.4.12.tar.gz apr-1.5.2.tar.gz apr-util-1.5.4.tar.gz mysql-5.5.13.tar.gz php-5.5.25.tar.gz jpegsrc.v9a.tar.gz libiconv-1.14.tar.gz libmcrypt-2.5.7.tar.gz #软件在我的博客资料里面。
1、安装相关的软件包 yum install gd gd-devel \ zlib zlib-devel \ libxml2 libxml2-devel \ freetype freetype-devel \ libpng libpng-devel \ make gcc gcc-c++ \ cmake ncurses ncurses-devel \ bison bison-devel \ libtool libtool-ltdl \ libtool-ltdl-devel -y
2、安装apr-1.5.2.tar.gz tar xf apr-1.5.2.tar.gz cd apr-1.5.2 ./configure --prefix=/usr/local/apr/ make && make install
错误:
解决方案:
3、安装apr-util.1.5.4.tar.gz tar xf apr-util-1.5.4.tar.gz cd apr-util-1.5.4 ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/ make && make install
4、安装httpd-2.4.12.tar.gz tar xf httpd-2.4.12.tar.gz cd httpd-2.4.12 ./configure --prefix=/usr/local/apache2 \ --sysconfdir=/etc/httpd \ --enable-cache \ --enable-file-cache \ --enable-disk-cache \ --enable-mem-cache \ --enable-so \ --enable-ssl \ --enable-cgi \ --enable-rewrite \ --enable-deflate \ --enable-expires \ --with-z= \ --with-pcre \ --with-apr=/usr/local/apr \ --with-apr-util=/usr/local/apr-util \ --enable-modules=most \ --enable-mpms-shared=all make && make install
5、安装MySQL-5.5.13.tar.gz useradd mysql tar xf mysql-5.5.13.tar.gz cd mysql-5.5.13 cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DSYSCONFDIR=/etc \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ -DMYSQL_TCP_PORT=3306 \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DEXTRA_CHARSETS=all \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci make && make install
6、修改MySQL的目录权限 chown -R root.mysql /usr/local/mysql chown -R mysql /usr/local/mysql/data
7、初始化MySQL数据库 /usr/local/mysql/scripts/mysql_install_db--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
8、生成MySQL的配置文件 cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
9、设置开机自启服务 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chkconfig mysql on
10、启动MySQL服务 /etc/init/d/mysqld start 或 service mysqld start
11、设置MySQL数据库用户密码 /usr/local/mysql/bin/mysqladmin -uroot password bvaefuvbrv23rq3!@%$
12、安装jpegsrc.v9a.tar.gz tar xf jpegsrc.v9a.tar.gz cd jpeg-9a ./configure--prefix=/usr/local/jpeg--enable-share --enable-static make && make install
13、安装libmcrypt-2.5.7.tar.gz tar xf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure --prefix=/usr/local/libmcrypt make && make install
14、安装libiconv-1.14.tar.gz tar xf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make && make install
15、安装php-5.5.25.tar.gz tar xf php-5.5.25.tar.gz cd php-5.5.25 ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-mysql=/usr/local/mysql/ \ --with-libxml-dir \ --with-iconv=/usr/local/libiconv \ --with-png-dir \ --with-jpeg-dir=/usr/local/jpeg/ \ --with-freetype-dir \ --with-gd \ --with-zlib-dir \ --with-openssl \ --with-mcrypt=/usr/local/libmcrypt/ \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --enable-soap \ --enable-short-tags \ --enable-static \ --enable-mbstring=all \ --enable-sockets make && make install
16、生成php的配置文件 cp /root/php.5.5.25/php.ini-production /usr/local/php/etc/php.ini
17、配置apache的配置文件,支持php /etc/httpd/httpd.conf中添加以下内容
18、测试php与httpd的连通 在/usr/local/apache2/htdocs/下新建index.php文件,内容如下
19、测试MySQL与PHP的连通 在/usr/local/apache2/htdocs/下新建test.php文件,内容如下