您的位置:首页 > 运维架构 > Apache

在CentOS6.7中编译安装 apache php mysql

2015-11-15 13:30 393 查看
安装 开发工具

yum groupinstall "Development Tools"

------------------------------

tar -jxvf apr-1.5.2.tar.bz2

cd apr-1.5.2

./configure --prefix=/usr/local/apr

make && make install

-----------------

tar -jxvf apr-util-1.5.4.tar.bz2

cd apr-util-1.5.4

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make && make install

-------------------

tar -jxvf pcre-8.37.tar.bz2

cd pcre-8.37

./configure

make && make install

-------------------

tar -jxvf httpd-2.4.17.tar.bz2

cd httpd-2.4.17

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre --enable-so --enable-rewrite

make && make install

cd /usr/local/apache2/conf

vi httpd.conf

增加

ServerName localhost:80

:wq

iptables -I INPUT -p tcp --dport 80 -j ACCEPT

service iptables save

service iptables restart

cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd

service httpd start

使用WebBrowser出现“It works”就说明Apache已经正常安装。

-------------------

tar -zxvf mysql-5.5.46.tar.gz

cd mysql-5.5.46

yum install cmake ncurses-devel bison

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFIGDIR=/usr/local/mysql/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
-DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_USER=mysql

make && make install

cp /usr/local/mysql/support-files/my-huge.cnf /etc/my.cnf

vi /etc/my.cnf

修改my.cnf配置,把innodb相关选项前面的#去掉,大概在115-130行之间。

useradd mysql

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &

chkconfig --add mysqld

chkconfig --level 345 mysqld on

service mysqld start

su - mysql

vi ~/.bash_profile

编辑为:

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

:wq

source ~/.bash_profile

mysqladmin -u root password '123456'

mysql -uroot -p123456

----------------------

php

yum -y install curl-devel bzip2-devel libxml2-devel libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel

tar -zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure --prefix=/usr/local

make && make install

tar -jxvf php-5.6.15.tar.bz2

cd php-5.6.15

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-libxml-dir=/usr/include/libxml2 --with-config-file-path=/usr/local/apache2/conf --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd --enable-gd-native-ttf
--with-zlib --with-mcrypt --with-pdo-mysql=/usr/local/mysql --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-zip --with-xmlrpc --enable-fpm --enable-mbstring --with-zlib-dir --with-bz2 --with-curl --enable-exif --enable-ftp --with-jpeg-dir=/usr/lib
--with-png-dir=/usr/lib --with-freetype-dir=/usr/lib/

make && make install

vi /usr/local/apache2/conf/httpd.conf

1. 添加php支持。

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

2. 添加默认索引页面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php”

DirectoryIndex index.html index.php

3. 不显示目录结构,找到“Options Indexes FollowSymLinks”,修改为

Options FollowSymLinks

4. 开启Apache支持伪静态,找到“AllowOverride None”,修改为

AllowOverride All

保存httpd.conf配置,然后再执行以下两行命令

chown -R nobody. /usr/local/apache2/htdocs/

chmod -R 777 /usr/local/apache2/htdocs/

cp php.ini-production /usr/local/apache2/conf/php.ini

service httpd restart

cd /usr/local/apache2/htdocs

vi phpconf.php

输入:

<?php

phpinfo();

?>

:wq

在浏览器中 http://ip/phpconf.php
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: