centos7 安装apache+mysql+php环境
admin
2023-05-20 08:02:41
0次

环境:

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@fangshaoxia 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@fangshaoxia mysql-5.1.72]# echo $?

0

##查看是否有错误,如果非零说明有错误

 

[root@fangshaoxia mysql-5.1.72]# make  

[root@fangshaoxia mysql-5.1.72]# echo $?

[root@fangshaoxia mysql-5.1.72]#make    install

[root@fangshaoxia mysql-5.1.72]# echo $?

[root@fangshaoxia mysql-5.1.72]# cd   support-files/

[root@fangshaoxia support-files]# cp   my-medium.cnf /etc/my.cnf

[root@fangshaoxia support-files]# cd      /application/

[root@fangshaoxia application]# ln -s   /application/mysql5.1.72/ mysql

##调优去版本号

[root@fangshaoxia bin]# cd      /application/mysql/bin/

[root@fangshaoxia bin]# mkdir    /application/mysql/data     -p

提示:这里的路径一定要和上面编译的路劲一样否则会出错

[root@fangshaoxiabin]#./mysql_install_db     --basedir=/application/mysql     --datadir=/application/mysql/data     --user=mysql

提示:mysql_install_db里还有其他参数可以通过”./mysql_install_db  --help”,一定不能忘记”./”

[root@fangshaoxiabin]# cd /application/

[root@fangshaoxiaapplication]# chown -R mysql mysql5.1.72/

[root@fangshaoxiabin]# echo "export PATH=/application/mysql5.1.72/bin/:$PATH" >>/etc/profile

[root@fangshaoxiabin]# source     /etc/profile

[root@fangshaoxia support-files]# cd   /home/tools/LAMP/mysql-5.1.72/support-files/

[root@fangshaoxiasupport-files]# cp   mysql.server /etc/init.d/mysqld

[root@fangshaoxia support-files]# chmod +x   /etc/init.d/mysqld

[root@fangshaoxia support-files]#/etc/init.d/mysqld start

[root@fangshaoxia support-files]# chkconfig   --add mysqld

[root@fangshaoxia support-files]# chkconfig    mysqld     on

[root@fangshaoxia support-files]#mysql_secure_installation

提示:出现的问题看情况和需求而定

出现两个OK,而且没有其他问题就是好了,安全初始化成功

[root@fangshaoxia support-files]# mysql  -uroot   -p

##输入前面设置的密码就可以进入mysql了

 

 

下面开始安装PHP

1 解压

[root@fangshaoxia LAMP]# tar zxvf php-5.3.27.tar.gz

[root@fangshaoxia LAMP]# tar zxvf  libiconv-1.14.tar.gz

[root@fangshaoxia LAMP]# cd libiconv-1.14/

[root@fangshaoxia libiconv-1.14]#./configure  --prefix=/usr/local/libiconv

[root@fangshaoxia 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@fangshaoxia 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@fangshaoxia LAMP]# cd     php-5.3.27/

[root@fangshaoxia 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@fangshaoxia 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@fangshaoxiaphp-5.3.27]# make && make installmake

 

[root@fangshaoxiaphp-5.3.27]# cd   /application/

[root@fangshaoxia application]# ln -s   php5.3.27/ php

[root@fangshaoxia application]# cd -

/home/tools/LAMP/php-5.3.27

[root@fangshaoxia php-5.3.27]# cp  php.ini-production /application/php/lib/php.ini


4编辑httpd配置文件

[root@fangshaoxia php-5.3.27]# cd  /application/apache/conf/

[root@fangshaoxia 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前的空格)

centos7 安装apache+mysql+php环境

##在311行添加上面两个配置

 

去站点下添加一个index.php页面,测试PHP和mysql的工作状态是否OK

vim index.php

       //$link_id=mysql_connect('主机名','用户','密码');

       $link_id=mysql_connect('localhost','root','*******') or mysql_error();

 

       if($link_id){

               echo "mysqlsuccessful by fangshaoxiade lake !";

       }else{

                echo mysql_error();

       }

?>

[root@fangshaoxia num1]# /application/apache/bin/apachectl graceful



相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...