安装mysql
mysql版本 5.5.32 apache版本2.2.34 php版本5.3.27
1、解压
[root@NFS-31 ~]# tar zxf mysql-5.5.32-linux2.6-x86_64.tar.gz
2、移动
[root@NFS-31 ~]# mv mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql
3、进入目录
[root@NFS-31 ~]# cd /usr/local/mysql/ [root@NFS-31 mysql]# ls bin data include lib mysql-test scripts sql-bench COPYING docs INSTALL-BINARY man README share support-files [root@NFS-31 mysql]#
4、设置mysql数据的目录
[root@NFS-31 mysql]# mkdir /data/mysql –p
5、不创建家目录
[root@NFS-31 mysql]# useradd -s /sbin/nologin -M mysql
6、更改权限
[root@NFS-31 mysql]# chown -R mysql:mysql /data/mysql/
7、拷贝配置文件
[root@NFS-31 mysql]# cp support-files/my-large.cnf /etc/my.cnf
8、修改配置 vim /etc/my.cnf
51 #log-bin=mysql-bin 52 53 # binary logging format - mixed recommended 54 #binlog_format=mixed 55 56 # required unique id between 1 and 2^32 - 1 57 # defaults to 1 if master-host is not set 58 # but will not function as a master if omitted 59 #server-id = 1 #不用主从复制 上面51 和54和59注释掉
9、拷贝启动脚本以及更改脚本
[root@NFS-31 mysql]# cp support-files/mysql.server /etc/init.d/mysqld [root@NFS-31 mysql]# vim /etc/init.d/mysqld basedir=/usr/local/mysql #设置路径 datadir=/data/mysql #mysql的数据目录
10、初始化mysql
[root@NFS-31 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
11、检查是否生成目录
[root@NFS-31 mysql]# ls /data/mysql mysql performance_schema test
12、启动服务,并且查看是否启动成功
[root@NFS-31 mysql]# /etc/init.d/mysqld start Starting MySQL... SUCCESS! [root@NFS-31 mysql]# ps aux|grep mysql root 2286 0.1 0.1 106244 1408 pts/2 S 22:15 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/NFS-31.pid mysql 2541 4.5 8.7 746884 87480 pts/2 Sl 22:15 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/NFS-31.err --pid-file=/data/mysql/NFS-31.pid --socket=/tmp/mysql.sock --port=3306 root 2564 0.0 0.0 103336 856 pts/2 S+ 22:15 0:00 grep mysql
13、进入mysql
[root@NFS-31 mysql]# /usr/local/mysql/bin/mysql –p (123456)
14、查看错误日志是在datadir里面的err结尾的里面
ls /data/mysql
安装apache
1、解压
[root@NFS-31 ~]# tar zxf httpd-2.2.34.tar.gz
2、安装gcc
yum install gcc
3、安装,这里的prefix是安装目录
[root@NFS-31 httpd-2.2.34]# ./configure --prefix=/usr/local/apache2 --with-included-apr --with-pcre --enable-mods-shared=most
4、安装
make && make install
安装PHP
1、解压
[root@NFS-31 ~]# tar zxf php-5.3.27.tar.gz
2、定义配置文件
[root@NFS-31 php-5.3.27]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
3、安装下面的软件
yum -y install libjpeg-devel yum install libmcrypt yum install -y epel-release yum install -y libmcrypt-devel 4、make 5、检测 echo $? 6、make install 7、拷贝配置文件,生产环境中 [root@NFS-31 php-5.3.27]# cp php.ini-production /usr/local/php/etc/php.ini
8、查看php模块
[root@NFS-31 php-5.3.27]# /usr/local/php/bin/php -m |less
9、[root@NFS-31 php-5.3.27]# /usr/local/php/bin/php -i |head 查看php编译的参数
启动并且检查apache
检查
[root@NFS-31 php-5.3.27]# /usr/local/apache2/bin/apachectl -t httpd: apr_sockaddr_info_get() failed for NFS-31 httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName Syntax OK
启动
root@NFS-31 php-5.3.27]# /usr/local/apache2/bin/apachectl start httpd: apr_sockaddr_info_get() failed for NFS-31 httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [root@NFS-31 php-5.3.27]# ps aux |grep httpd root 12691 0.1 0.7 362552 7632 ? Ss 23:18 0:00 /usr/local/apache2/bin/httpd -k start daemon 12693 0.0 0.4 362552 4628 ? S 23:18 0:00 /usr/local/apache2/bin/httpd -k start daemon 12694 0.0 0.4 362552 4628 ? S 23:18 0:00 /usr/local/apache2/bin/httpd -k start daemon 12695 0.0 0.4 362552 4628 ? S 23:18 0:00 /usr/local/apache2/bin/httpd -k start daemon 12696 0.0 0.4 362552 4628 ? S 23:18 0:00 /usr/local/apache2/bin/httpd -k start daemon 12697 0.0 0.4 362552 4628 ? S 23:18 0:00 /usr/local/apache2/bin/httpd -k start root 12699 0.0 0.0 103340 864 pts/2 S+ 23:19 0:00 grep httpd
编辑php文件
root@NFS-31 php-5.3.27]# cd /usr/local/apache2/htdocs/ [root@NFS-31 htdocs]# ls index.html [root@NFS-31 htdocs]# vim index.html
2、用curl来验证
[root@NFS-31 htdocs]# curl 10.0.0.31/1.php <?php echo 1111; ?php> 看到的是上面的代码说明php不能够解析
3、编辑配置文件
Apache主配置文件为:/usr/local/apache2/conf/httpd.conf vim /usr/local/apache2/conf/httpd.conf 找到: AddType application/x-gzip .gz .tgz 在该行下面添加: AddType application/x-httpd-php .php 找到: <IfModule dir_module> DirectoryIndex index.html </IfModule> 将该行改为: <IfModule dir_module> DirectoryIndex index.html index.htm index.php </IfModule> 找到: #ServerName www.example.com:80 修改为: ServerName localhost:80 4、测试是否成功 /usr/local/apache2/bin/apachect1 start netstat –lntup|grep httpd 5、关闭防火墙 iptables -F 6、编写脚本 [root@NFS-31 htdocs]# cat 3.php <?php phpinfo(); ?> 浏览器测试