溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

centos7 安裝apache+mysql+php環(huán)境

發(fā)布時(shí)間:2020-06-30 13:53:52 來(lái)源:網(wǎng)絡(luò) 閱讀:2123 作者:vperson 欄目:MySQL數(shù)據(jù)庫(kù)

環(huán)境:

Centos 7.0

Apache 2.2.27

Mysql 5.1.72

libiconv 1.14

 

##Apache 請(qǐng)自行使用編譯安裝.內(nèi)容從我自己的word復(fù)制過(guò)來(lái)的,wold里面是好的,有的地方復(fù)制過(guò)來(lái)就重疊了,看的時(shí)候注意下

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 新建一個(gè)文件填入如下參數(shù),可以直接復(fù)制,參數(shù)看個(gè)人所需求吧,不一定要這些,還有很多參數(shù)。

 

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 開(kāi)始編譯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

##查看是否有錯(cuò)誤,如果非零說(shuō)明有錯(cuò)誤

 

[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

##調(diào)優(yōu)去版本號(hào)

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

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

提示:這里的路徑一定要和上面編譯的路勁一樣否則會(huì)出錯(cuò)

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

提示:mysql_install_db里還有其他參數(shù)可以通過(guò)”./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

提示:出現(xiàn)的問(wèn)題看情況和需求而定

出現(xiàn)兩個(gè)OK,而且沒(méi)有其他問(wèn)題就是好了,安全初始化成功

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

##輸入前面設(shè)置的密碼就可以進(jìn)入mysql了

 

 

下面開(kāi)始安裝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         

提示:錯(cuò)誤./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

 

##這個(gè)問(wèn)題centos6.8里沒(méi)有遇到過(guò)


[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所必須的包,一個(gè)不能落下

 

2 新建一個(gè)文件填入如下參數(shù),可以直接復(fù)制,參數(shù)看個(gè)人所需求吧,不一定要這些,還有很多參數(shù)。

[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環(huán)境

##在311行添加上面兩個(gè)配置

 

去站點(diǎn)下添加一個(gè)index.php頁(yè)面,測(cè)試PHP和mysql的工作狀態(tài)是否OK

vim index.php

<?php

       //$link_id=mysql_connect('主機(jī)名','用戶','密碼');

       $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



向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI