共计 4852 个字符,预计需要花费 13 分钟才能阅读完成。
环境:
CentOS 7.0
Apache 2.2.27
MySQL 5.1.72
libiconv 1.14
##Apache 请自行使用编译安装. 内容从我自己的 word 复制过来的,wold 里面是好的,有的地方复制过来就重叠了,看的时候注意下
1 解压 mysql
tar zxvf mysql-5.1.72.tar.gz
cd mysql-5.1.72/
[root@linuxidc support-files]# useradd-M -s /sbin/nologin mysql
2 新建一个文件填入如下参数,可以直接复制,参数看个人所需求吧,不一定要这些,还有很多参数。
vim 1.txt
./configure \
–prefix=/application/mysql5.1.72 \
–with-unix-socket-path=/application/mysql5.1.72/tmp/mysql.sock\
–localstatedir=/application/mysql5.1.72/data\
–enable-assembler \
–enable-thread-safe-client \
–with-mysqld-user=mysql \
–with-big-tables \
–without-debug \
–with-pthread \
–enable-assembler \
–with-extra-charsets=complex \
–with-readline \
–with-ssl \
–with-embedded-server \
–enable-local-infile \
–with-plugins=partition,innobase \
–with-mysqld-ldflags=-all-static \
–with-client-ldflags=-all-static
3 开始编译 mysql
cat 1.txt | bash
提示:
checkingfor termcap functions library… configure: error: No curses/termcap libraryfound
解决:yum install ncurses-static.x86_64 -y
[root@linuxidc mysql-5.1.72]# echo $?
0
## 查看是否有错误,如果非零说明有错误
[root@linuxidc mysql-5.1.72]# make
[root@linuxidc mysql-5.1.72]# echo $?
[root@linuxidc mysql-5.1.72]#make install
[root@linuxidc mysql-5.1.72]# echo $?
[root@linuxidc mysql-5.1.72]# cd support-files/
[root@linuxidc support-files]# cp my-medium.cnf /etc/my.cnf
[root@linuxidc support-files]# cd /application/
[root@linuxidc application]# ln -s /application/mysql5.1.72/ mysql
## 调优去版本号
[root@linuxidc bin]# cd /application/mysql/bin/
[root@linuxidc bin]# mkdir /application/mysql/data -p
提示:这里的路径一定要和上面编译的路劲一样否则会出错
[root@linuxidcbin]#./mysql_install_db –basedir=/application/mysql –datadir=/application/mysql/data –user=mysql
提示:mysql_install_db 里还有其他参数可以通过”./mysql_install_db –help”,一定不能忘记”./”
[root@linuxidcbin]# cd /application/
[root@linuxidcapplication]# chown -R mysql mysql5.1.72/
[root@linuxidcbin]# echo “export PATH=/application/mysql5.1.72/bin/:$PATH” >>/etc/profile
[root@linuxidcbin]# source /etc/profile
[root@linuxidc support-files]# cd /home/tools/LAMP/mysql-5.1.72/support-files/
[root@linuxidcsupport-files]# cp mysql.server /etc/init.d/mysqld
[root@linuxidc support-files]# chmod +x /etc/init.d/mysqld
[root@linuxidc support-files]#/etc/init.d/mysqld start
[root@linuxidc support-files]# chkconfig –add mysqld
[root@linuxidc support-files]# chkconfig mysqld on
[root@linuxidc support-files]#mysql_secure_installation
提示:出现的问题看情况和需求而定
出现两个 OK,而且没有其他问题就是好了,安全初始化成功
[root@linuxidc support-files]# mysql -uroot -p
## 输入前面设置的密码就可以进入 mysql 了
下面开始安装 PHP
1 解压
[root@linuxidc LAMP]# tar zxvf php-5.3.27.tar.gz
[root@linuxidc LAMP]# tar zxvf libiconv-1.14.tar.gz
[root@linuxidc LAMP]# cd libiconv-1.14/
[root@linuxidc libiconv-1.14]#./configure –prefix=/usr/local/libiconv
[root@linuxidc libiconv-1.14]#make
提示:错误./stdio.h:1010:1: error:‘gets’undeclared here (not in a function)
_GL_WARN_ON_USE (gets, “gets is asecurity hole – use fgets instead”);
解决:
[root@linuxidc libiconv-1.14]# vim srclib/stdio.in.h
将 698 行的代码:_GL_WARN_ON_USE (gets, "gets is a security hole - use fgetsinstead");
替换 为:
#if defined(__GLIBC__)&& !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, “gets is asecurity hole – use fgets instead”);
#endif
##这个问题 centos6.8 里没有遇到过
[root@linuxidc LAMP]# cd php-5.3.27/
[root@linuxidc php-5.3.27]# yum install libxml2-devel.x86_64 libxml2.x86_64 openssl-devel.x86_64 libcurl-devel.x86_64 libjpeg-turbo.x86_64 libjpeg-turbo-devel.x86_64 png* libpng-devel.x86_64 freetype.x86_64 freetype-devel.x86_64 libxslt-devel.x86_64 libxslt.x86_64
## 以上是安装 PHP 所必须的包,一个不能落下
2 新建一个文件填入如下参数,可以直接复制,参数看个人所需求吧,不一定要这些,还有很多参数。
[root@linuxidc php-5.3.27]# vim 1.txt
./configure \
–prefix=/application/php5.3.27 \
–with-apxs2=/application/apache/bin/apxs \
–with-mysql=/application/mysql \
–with-xmlrpc \
–with-openssl \
–with-zlib \
–with-freetype-dir \
–with-gd \
–with-jpeg-dir \
–with-png-dir \
–with-iconv=/usr/local/libiconv \
–enable-short-tags \
–enable-sockets \
–enable-zend-multibyte \
–enable-soap \
–enable-mbstring \
–enable-static \
–enable-gd-native-ttf \
–with-curl \
–with-xsl \
–enable-ftp \
–with-libxml-dir
## 上面 apache 的路劲和 mysql 路径必须正确。
[root@linuxidcphp-5.3.27]# make && make installmake
[root@linuxidcphp-5.3.27]# cd /application/
[root@linuxidc application]# ln -s php5.3.27/ php
[root@linuxidc application]# cd –
/home/tools/LAMP/php-5.3.27
[root@linuxidc php-5.3.27]# cp php.ini-production /application/php/lib/php.ini
4 编辑 httpd 配置文件
[root@linuxidc php-5.3.27]# cd /application/apache/conf/
[root@linuxidc conf]# vim httpd.conf
DirectoryIndex index.html index.php
## 在 169 行添加 index.php
AddTypeapplication/x-httpd-php .php .phtml(注意.php 和.phtml 的空格)
AddTypeapplication/x-httpd-php-source .phps(注意.phps 前的空格)
## 在 311 行添加上面两个配置
去站点下添加一个 index.php 页面, 测试 PHP 和 mysql 的工作状态是否 OK
vim index.php
<?php
//$link_id=mysql_connect(‘ 主机名 ’,’ 用户 ’,’ 密码 ’);
$link_id=mysql_connect(‘localhost’,’root’,’*******’) or mysql_error();
if($link_id){
echo “mysqlsuccessful by linuxidcde lake !”;
}else{
echo mysql_error();
}
?>
[root@linuxidc num1]# /application/apache/bin/apachectl graceful
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-04/142641.htm