CentOS LAMP环境搭建和测试php与mysql的连接
来源:互联网 发布:阿里云服务器压力测试 编辑:程序博客网 时间:2024/05/24 00:01
* 摘要:CentOS LAMP作为服务器,不安装不需要的组件,所以在选择组件的时候,不要选web服务器,因为我们后面要手动编译安装。CentOS LAMP系统约定RPM包和源码包存放位置
* 标签:CentOS LAMP
*
Oracle帮您准确洞察各个物流环节
特别值得一提的是CentOS LAMP有很多值得学习的地方,这里我们主要介绍CentOS LAMP环境搭建,包括介绍CentOS LAMP配置等方面。系统安装安装RHEL 5 / CentOS 5。
CentOS LAMP作为服务器,不安装不需要的组件,所以在选择组件的时候,不要选web服务器,因为我们后面要手动编译安装。CentOS LAMP系统约定RPM包和源码包存放位置:
1. RPM包和源码包存放位置 /usr/local/src
2. 源码包编译安装位置(prefix) /usr/local/XXX
3. MySQL 数据库位置 /usr/local/mysql/var
4. 网站根目录 /usr/local/apache/htdocs
CentOS LAMP环境搭建
搭建的工作包括APACHE、MYSQL、PHP。可以按照这个顺序来搭建环境。
1、获取软件包
1. Httpd: http://www.apache.org/dist/httpd/httpd-2.2.11.tar.gz
2. mysql: http://mirror.provenscaling.com/mysql/enterprise/source/5.0/mysql-5.0.70.tar.gz
3. php: http://museum.php.net/php5/php-5.2.2.tar.gz
把它们全部放到 /usr/local/src 下面.>cd /usr/local/src (定位到安装包目录)
2、安装 mysql
1. >tar -zxvf mysql-5.0.70.tar.gz
2. >cd mysql-5.0.70
3. >./configure --prefix=/usr/local/mysql
4. >make
5. >make install
6. >useradd mysql //添加 mysql 用户
7. >cd /usr/local/mysql
8. >bin/mysql_install_db --user=mysql
9. >chown -R mysql . //设置权限,注意后面有一个点 "."
10. >chgrp -R mysql .
11. >chown -R mysql var
12. >cp share/mysql/my-medium.cnf /etc/my.cnf
13. >cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //开机启动
14. >chmod 755 /etc/rc.d/init.d/mysqld
15. >chkconfig --add mysqld
运行以下命令即可启动 MySQL 服务器:>/etc/rc.d/init.d/mysqld start //启动 MySQL(mysql安装完毕)
3、安装Apache
1. >tar -zxvf httpd-2.2.11.tar.gz
2. >cd httpd-2.2.11
3. >./configure --prefix=/usr/local/apache --enable-module=so --enable-module=rewrite --enable-shared=max
4. >make
5. >make install
启动apache服务 >/usr/local/apache/bin/apachectl -k start用浏览器打开 http://127.0.0.1/ 如果可以访问则说明apache安装成功。
4、安装PHP
>tar -zxvf php-5.2.2.tar.gz
>cd php-5.2.2
>./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache/bin/apxs
>make
>make install
>cp php.ini-dist /usr/local/php/lib/php.ini
>vi /usr/local/php/lib/php.ini
5、CentOS LAMP配置httpd
.conf >vi /usr/local/apache/conf/httpd.conf找到"AddType application/x-gzip .tgz"在它的下面添加AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps找到"DirectoryIndex index.html在index.html 前添加 index.php
启动apache服务>/usr/local/apache/bin/apachectl -k start将apache设置成开机自启动:在/etc/rc.d/rc.local文件中加入一行并保存: /usr/local/apache /bin/apachectl start (apache+php配置完毕)
6、查看确认 L.A.M.P 环境信息:>vi /usr/local/apache/htdocs/phpinfo.php新增加下面一行,并保存。 <?php phpinfo(); ?>>chmod 755 /usr/local/apache/htdocs/phpinfo.php用浏览器打开 http://127.0.0.1/phpinfo.php检查 phpinfo中的各项信息是否正确。如果可以访问则环境搭建成功
测试php与mysql的连接
1. >vi /usr/local/apache/htdocs/testdb.php增加下面几行,并保存。
2. <?php
3. $link=mysql_connect('localhost','root','yourpassword');
4. if(!$link) echo "fail";
5. else echo "success";
6. mysql_close();
7. ?>
8. >chmod 755 /usr/local/apache/htdocs/testdb.php
9. >service mysqld start
用浏览器打开 http://127.0.0.1/testdb.php如果输出success表明php与mysql连接成功CentOS LAMP环境搭建完毕
- CentOS LAMP环境搭建和测试php与mysql的连接
- CentOS、Linux搭建LAMP(Apache、MySQL、PHP)环境
- 在CentOS下搭建LAMP(Apache、MySQL、PHP)环境
- 【php】Centos系统下Lamp环境的快速搭建
- centos 6.4 lamp 环境搭建 php 5.4
- centos搭建lamp php运行环境
- 搭建LAMP环境_mac使用php和mysql通信
- linux的ubuntu和centos下快速搭建LAMP环境
- CentOS7下的LAMP(Linux+Apache+Mysql+PHP)环境搭建
- CentOS 7.3搭建LAMP环境和Wordpress
- CentOS搭建LAMP环境
- CentOS搭建LAMP环境
- centos 搭建lamp环境
- CentOS 搭建 LAMP环境
- CentOS搭建LAMP环境
- CentOS搭建LAMP环境
- ubuntu 搭建 lamp 环境php mysql apache
- LAMP:Linux+Apache+Mysql+Php 搭建环境
- Section 4.2 jobs
- 世界各个国家及其国家代码
- 如果不用MFC,直接使用API写一个Windows程序,需哪些步骤?MFC是怎么做到菜单点击后,响应对应的代码的?
- Section 4.1 Beef McNuggets
- Postfix+Amavisd+Clam+Spamd
- CentOS LAMP环境搭建和测试php与mysql的连接
- 线程
- 最简单的glut opengl程序
- 线程2
- hadoop 文件夹嵌套赋权限
- sqlserver2005使用convert转换日期[资料]
- 链表
- 影响Lucene索引速度原因以及提高索引速度技巧(收集)
- 如何在java中调用js方法