Centos7 compiles, installs and builds LAMP platform

I. compile and install mysql

Install dependency packages and tools

# yum install  -y gcc gcc-c++ ncurses-devel perl 
# yum install  -y cmake

Download mysql installation package

# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.62.tar.gz

Preparation before installation

# groupadd mysql  
# useradd  -g mysql mysql
# mkdir -p /data/mysql
# chown -R mysql:mysql /data/mysql

Compile and install mysql

# tar -zxv -f mysql-5.5.62.tar.gz
#cd mysql-5.5.62
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
#make && make install 

Modify authority

# chown -R mysql.mysql /usr/local/mysql

Initialize mysql database

# /usr/local/mysql scripts/mysql_install_db --user=mysql --datadir=/data/mysql

Copy mysql service startup profile and script

# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
# cp support-files/mysql.server /etc/init.d/mysqld
# vi /etc/rc.d/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql

service mysql start

# service mysqld start 
    perhaps 
#systemctl start mysqld (after the above configuration, reload the system manager. Systemctl daemon reload can directly use systemctl command)

Check login

# mysql -uroot -p

2. Compile and install httpd

Preparing the installation package

# wget http://mirrors.sohu.com/apache/httpd-2.4.37.tar.gz
# tar -xzf httpd-2.4.37.tar.gz
# cd httpd-2.4.37

Install dependency package

 # yum install -y pcre* apr*

Compile and install httpd

# ./configure --prefix=/usr/local/httpd     
# make && make install

Edit startup file

# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd

Reload System Manager

# systemctl daemon-reload

Startup service

# systemctl start httpd

Edit profile

# vi /usr/local/httpd/conf/httpd.conf
#  ln -s /usr/local/httpd/conf/httpd.conf /etc / (configuration file soft connection mapping to / etc)

test

# vim /usr/local/httpd/htdocs/index.html 
<html><body><h1>It works!</h1></body></html>
<html><head><h1>Good boy!</h1></head></html>
# systemctl start httpd

3. Compile and install PHP

Preparing the installation package

# wget http://mirrors.sohu.com/php/php-7.2.5.tar.gz
# tar -xzf php-7.2.5.tar.gz
# cd php-7.2.5

Install dependency package

# yum install bzip2-devel.x86_64  openssl* libxml2*

Compile and install PHP

# ./configure 
    --prefix=/usr/local/php 
    --with-mysqli=mysqlnd                   ##mysql support
    --with-pdo-mysql=mysqlnd 
    --with-openssl 
    --enable-mbstring 
    --with-freetype-dir 
    --with-jpeg-dir 
    --with-png-dir --with-zlib 
    --with-libxml-dir=/usr 
    --enable-xml  
    --enable-sockets 
    --with-apxs2=/usr/local/httpd/bin/apxs   ##httpd support
    --with-config-file-path=/etc        ##php.ini configuration file path
    --with-config-file-scan-dir=/etc/php.d 
    --with-bz2  
    --enable-maintainer-zts

Copy the configuration file (in the unzipped package)

# cp /wh_k/php-7.2.5/php.ini-production /etc/php.ini

Configuration file httpd.conf supports php

 # vim /etc/httpd.conf

After loadmodule php7 ﹣ module modules / libphp7.so, add:

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

Modify DirectoryIndex index.html to:

  DirectoryIndex index.php index.html

Add test page

# vim /usr/local/httpd/htdocs/index.php

<?php
    phpinfo();
?>

Restart httpd service test

# systemctl restart httpd
http://192.168.61.130/index.php

Test mysql support

Add mysql user

 mysql> grant all on mysql.* to 'mysql'@'localhost' identified by 'redhat';
 mysql> flush privileges;

Configure test page

    # vim /usr/local/httpd/htdocs/test.php
  <?php
         $log_in = mysqli_connect('127.0.0.1','mysql','redhat');
                if ($log_in)
                      echo "Success.You are so good!";
                else
                      echo "Failure.You are so bad!";
   ?>

Restart httpd service test

# systemctl restart httpd
http://192.168.61.130/test.php

Tags: Linux MySQL PHP yum vim

Posted on Sun, 08 Dec 2019 05:38:06 -0800 by Obadiah