操作系统 : [CentOS7.0]
服务器 : [httpd-2.4.17]
PHP : [php-5.5.19]
数据库 : [mysql-5.5.41]
++++++++++++++++++++++++++++++++++++++++++++++
1>【卸载系统自带的apache】
2>【安装gcc, gcc-c++】
3>【开放80、3306、22端口】
4>【安装libxml2】
5>【安装libmcrypt】
6>【安装zlib】
7>【安装libpng】
10>【安装freetype】
11>【安装autoconf】
12>【安装gd】
14>【安装ncurses】
15>【安装mysql】
16>【安装php】
17>【apache配置】
18>【添加PDO_MYSQL扩展】
19>【apache虚拟主机配置】
- #查看apache是否己安装
- rpm -qa httpd
- #卸载
- rpm -e httpd --nodeps
- yum install gcc
- yum install gcc-c++
- #关闭防火墙
- service iptables stop
- vi /etc/sysconfig/iptables
- #添加
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
- #重启防火墙
- service iptables restart
- tar -zxvf libxml2-2.6.30.tar.gz
- cd libxml2-2.6.30
- ./configure --prefix=/usr/local/libxml2/
- make
- make install
- tar -zxvf libmcrypt-2.5.8.tar.gz
- cd libmcrypt-2.5.8
- ./configure --enable-ltdl-install
- make
- make install
- tar -zxvf zlib-1.2.3.tar.gz
- cd zlib-1.2.3
- ./configure
- make
- make install
- tar -zxvf libpng-1.2.31.tar.gz
- cd libpng-1.2.31
- ./configure --prefix=/usr/local/libpng/
- make
- make install
8>【安装libtool】
9>【安装jpegsrc.v6b】
- mkdir /usr/local/jpeg6
- mkdir /usr/local/jpeg6/bin
- mkdir /usr/local/jpeg6/lib
- mkdir /usr/local/jpeg6/include
- mkdir -p /usr/local/jpeg6/man/man1
- tar -zxvf jpegsrc.v6b.tar.gz
- cd jpeg-6b
- ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
- make
- make install
- tar -zxvf freetype-2.3.5.tar.gz
- cd freetype-2.3.5
- ./configure --prefix=/usr/local/freetype/
- make
- make install
- tar -zxvf autoconf-2.61.tar.gz
- cd autoconf-2.61
- ./configure
- make
- make install
- tar -zxvf gd-2.0.35.tar.gz
- cd gd-2.0.35
- ./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/
- make
- make install
13>【安装apache】
- tar -zxvf httpd-2.4.17.tar.gz
- cd httpd-2.4.17
- ./configure --prefix=/usr/local/apache2/ --sysconfdir=/etc/httpd/ --with-included-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support
- make
- make install
- #启动apache
- /usr/local/apache2/bin/apachectl start
- #如果出现下面的错误,
- #httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
- #修改配置文件
- vi /etc/httpd/httpd.conf
- #查找ServerName,将注释去掉
- ServerName www.example.com:80
- #添加到自启动
- echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit
- #将apache添加到系统服务中
- cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
- vi /etc/rc.d/init.d/httpd
- #在#!/bin/sh后添加下面两行(包含"#")
- # chkconfig:2345 85 15
- # description:Apache
- #添加执行权限
- chmod 755 /etc/init.d/httpd
- #添加到系统服务中
- chkconfig --add httpd
- #开启apache
- service httpd start
- tar -zxvf ncurses-5.6.tar.gz
- cd ncurses-5.6
- ./configure --with-shared --without-debug --without-ada --enable-overwrite
- make
- make install
- groupadd mysql
- useradd -g mysql mysql
- tar -zxvf mysql-5.5.41.tar.gz
- cd mysql-5.5.41
- # 创建安装目录
mkdir /usr/local/ mysql
# 创建数据库目录
mkdir /usr/local/ mysql/data - # cmake编译:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0
- make
- make install
- cp support-files/my-medium.cnf /etc/my.cnf
- /usr/local/mysql/bin/mysql_install_db --user=mysql
- chown -R root /usr/local/mysql
- chown -R mysql /usr/local/mysql/var
- chgrp -R mysql /usr/local/mysql
- /usr/local/mysql/bin/mysqld_safe --user=mysql &
- cp /lamp/src/mysql-5.1.59/support-files/mysql.server /etc/rc.d/init.d/mysqld
- chown root.root /etc/rc.d/init.d/mysqld
- chmod 755 /etc/rc.d/init.d/mysqld
- chkconfig --add mysqld
- chkconfig --list mysqld
- chkconfig --levels 245 mysqld off
- #配置mysql
- cd /usr/local/mysql
- bin/mysqladmin version //简单的测试
- bin/mysqladmin Variables //查看所有mysql参数
- bin/mysql -uroot //没有密码可以直接登录本机服务器
- DELETE FROM mysql.user WHERE Host='localhost' AND User='';
- FLUSH PRIVILEGES;
- #设置root密码为123456
- SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');
- #配置可远程连接mysql
- use mysql
- SELECT user,password,host FROM user;
- DELETE FROM user WHERE host='localhsot.localdomain'
- DELETE FROM user WHERE host='127.0.0.1';
- UPDATE user SET host='%' WHERE user='root';
- #重启mysql
- service mysqld restart
- tar -zxvf php-5.5.19.tar.gz
- cd php-5.5.19
- ./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=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
- make
- make install
- cp php.ini-dist /usr/local/php/etc/php.ini
- #建立工作目录
- mkdir -p /var/www/html
- #修改httpd.conf
- vi /etc/httpd/httpd.conf
- #功能: 设置工作目录
- #说明: 搜索DocumentRoot, 修改为
- DocumentRoot "/var/www/html"
- #功能: 设置目录选项
- #说明: 搜索<Directory "/usr/local/apache2//htdocs">, 修改为
- <Directory "/var/www/html">
- #功能: 设置默认文档
- #说明: 搜索<IfModule dir_module>, 修改为
- DirectoryIndex index.html index.php
- #功能: 增加php类型
- #说明: 搜索 AddType application/x-gzip .gz .tgz在后面添加
- AddType application/x-httpd-php .html .php
- 功能: 不允许访问目录
- 说明: 搜索Options Indexes FollowSymLinks项并注释
- #Options Indexes FollowSymLinks
- #注意: 修改配置文件后, 重启apache才能生效
- #重启apache
- service httpd restart
- cd /lamp/src/php-5.2.6/ext/pdo_mysql
- /usr/local/php/bin/phpize
- ./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
- make
- make install
- #执行完make install后会生成
- #Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
- #修改php.ini
- vi /usr/local/php/etc/php.ini
- #查找extension_dir,修改为
- extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
- #添加pdo_mysql
- extension = pdo_mysql.so
- #重启apache
- service httpd restart
- #建立dev目录
- mkdir -p /var/www/html/dev
- cd /var/www/html/dev
- vi index.php
- #添加
- <?php
- phpinfo();
- ?>
- #保存,退出
- #打开httpd.conf
- vi /etc/httpd/httpd.conf
- #查找Include /etc/httpd//extra/httpd-vhosts.conf并取消注释
- Include /etc/httpd//extra/httpd-vhosts.conf
- #打开httpd-vhosts.conf
- vi /etc/httpd//extra/httpd-vhosts.conf
- #将下面几行注释
- #<VirtualHost *:80>
- # ServerAdmin webmaster@dummy-host.example.com
- # DocumentRoot "/usr/local/apache2//docs/dummy-host.example.com"
- # ServerName dummy-host.example.com
- # ServerAlias www.dummy-host.example.com
- # ErrorLog "logs/dummy-host.example.com-error_log"
- # CustomLog "logs/dummy-host.example.com-access_log" common
- #</VirtualHost>
- #<VirtualHost *:80>
- # ServerAdmin webmaster@dummy-host2.example.com
- # DocumentRoot "/usr/local/apache2//docs/dummy-host2.example.com"
- # ServerName dummy-host2.example.com
- # ErrorLog "logs/dummy-host2.example.com-error_log"
- # CustomLog "logs/dummy-host2.example.com-access_log" common
- #</VirtualHost>
- #添加
- <VirtualHost *:80>
- ServerName dev.dev
- DocumentRoot "/var/www/html/dev"
- <Directory "/var/www/html/dev/">
- AllowOverride All
- </Directory>
- </VirtualHost>
- #保存, 退出
- #重启apache
- service httpd restart
- #修改hosts文件
- vi /etc/hosts
- #添加
- 127.0.0.1 dev.dev localhost
- #保存, 退出
- #在浏览器输入http://dev.dev访问,查看能否输出php信息