Build a LAMP environment by compiling CentOS7 source code

Source: Internet
Author: User
Tags install perl

Build a LAMP environment by compiling CentOS7 source code

1. to facilitate file exchange with the host, click "option" at the top of the dialog box and select "shared folder ", click "always enable" on the right and click "add" to add the desired directory as prompted. Then, click "OK" to complete virtual machine settings.

2. Press Enter and select installCentOS7 ". Select "Chinese", "simplified Chinese (China)", and click "continue (C )"

3. Select "minimize", click "installation location", select "I want to configure partitions", and click "finish (D)" to go to the partition page.
4. click "+" to create a new partition, and select "SWAP" as the mount point (Note: equivalent to Windows virtual memory, generally 2 times the memory size) to fill in the capacity (2 GB ), click "add mount point (A)" 5. click "+" to create A new partition, select "/boot" as the mount point, enter the capacity (200 MB), and then click "add mount point ()", select "ext4" 6 for "File System" on the right. click "+" to create A new partition, select "/" as the mount point, enter the capacity (8 GB), and then click "add mount point ()", side "File System" and select "ext4" 7. click "+" to create a new partition, select "/usr" for the mount point (note: the software is installed), and enter the capacity (20 GB ), click "add mount point (A)", and select "ext4" 8 for "File System" on the right. click "+" to create A new partition, and select "/home" as the mount point. The remaining capacity is allocated to/home, and then click "add mount point () ", select" ext4 "for" File System "on the right, as shown in

9. Click "finish (D)" in the upper left corner and "accept changes" to create the disk.

10. Click "network and host name" and enter the host name. Enable the Ethernet connection. Then click "finish (D )"

11. Click "Start installation (B )"

12. Set the ROOT password

13. Click "restart", and an error message is displayed when the system is started. If this problem persists, press "Enter" to Enter the ROOT account for logon.

14. Install net-tools so that you can use the "ifconfig" command to view the IP Address:

Enter the command yuminstallnet-tools-y

View the IP address and write down it.

14. Here we will solve the NIC naming problem. It will be annoying to see eno16777736.

Enter the following command to enter the corresponding directory and edit the file:

Vi/etc/sysconfig/grub

Add "net. ifnames = 0 biosdevname = 0" to the file, as shown in:

In, the red box is the content I added (pay attention to its location ). Then run the following command:

Grub2-mkconfig-o/boot/grub2/grub. cfg

Then restart the VM, And the NIC name will be normal. Whether it is wrong or not. Enter and ROOT Login

15. Fixed boot problem dm-0: WRITESAMEfailed. Manuallyzeroing

Cause: hardware. Generally, raid cards do not support the WRITESAME feature.

Solution: Avoid WRITESAME and enable putty to log on to the system.

1. Create a disable-write-same script (which can be stored in/usr/local/sbin ),

#!/bin/sh #DisableSCSIWRITE_SAME,whichisnotsupportedbyunderlyingdisk #emulation.Runonbootfrom,eg,/etc/rc.local # #Seehttp://www.it3.be/2013/10/16/write-same-failed/ # #WrittenbyEwenMcNeill<ewen@naos.co.nz>,2014-07-17 #--------------------------------------------------------------------------- find /sys/devices -namemax_write_same_blocks| while read DISK; do echo 0> "${DISK}" done

2. Modify the script to execute

Chmoda + xdisable-write-same

3. Put the script in/etc/rc. local and run it at startup: <You can directly write it here if you start it at any later time!>

Add vi/etc/rc. local

Sudo/usr/local/sbin/disable-write-same

19. Right-click the Virtual Machine label and install "VMwareTools ".

(1) mount the VMwaretools Disc

Mount-tiso9660-oloop/dev/cdrom/media

Cp/media /*~

TarzxfVMwareTools-9.9.0-2304977.tar.gz

Cdvmware-tools-distrib/

/Vmware-install.pl

If the prompt is that the perl compiler is not installed, install perl:

Yuminstallperl-y

/Vmware-install.pl

Enter all the way...

(2) then you will find that the shared directory between the VM and the host you set up will appear in the/mnt/hgfs/directory. You can also
Create a soft connection to your shared directory under your root/directory

Ln-s/mnt/hgfs/shared_file /~ /Shared


Apache compilation and Installation

I. software required:

1.apr-1.5.1.tar.gz

2.apr-util-1.5.4.tar.gz

3.pcre-8.20.tar.zip

4.httpd-2.4.10.tar.gz

2. Install apr yum install gcclibtools-y tar zxfapache /apr-1 .5.1. tar .gz cd . /apache/apr-1 .5.1 . /configure --prefix= /usr/local/apr make && make install3. Install apr-util tar zxfapr-util-1.5.4. tar .gz cd apr-util-1.5.4 . /configure --prefix= /usr/local/apr-util --with-apr= /usr/local/apr make && make install4. Install the pcre Library yum install gcc-c++-y tar zxfpcre-8.20. tar .gz cd pcre-8.20 . /configure --prefix= /usr/local/pcre make && make install5. Install the Apache server tar zxfhttpd-2.4.10. tar .gz cd httpd-2.4.10 . /configure--prefix = /usr/local/apache --with-apr= /usr/local/apr --with-apr-util= /usr/local/apr-util --with-pcre= /usr/local/pcre make && make install6. Configure Apache

Cd/usr/local/usr/apache/conf/

Modify the entry as follows:

1. Search ServerName www.example.com: 80 and remove the preceding comment.

2. Modify DocumentRoot to/home/htdocs, And the <Directory to/home/htdocs

Error: the vm ip address entered on the host cannot be accessed.

Cause: the firewall intercepts port 80.

Solution: firewall-cmd -- permanent -- add-port = 80/tcp

Set Apache as a Linux service and enable Automatic startup

Add Apache to Linux

Cp/usr/local/apache/bin/apachectl/etc/rc. d/init. d/

Mv/etc/rc. d/init. d/apachectl/etc/rc. d/init. d/httpd

# Vihttpd

Add the following two lines of text under the first line

# CommentstosupportchkconfigonRedHatLinux

# Chkconfig: 23459090

# Description: httpserver

Register this service

Chkconfig -- addhttpd # auto-start in all boot Modes

Chkconfig httpdon #345 Automatic startup in Boot Mode

Then enter the address to find out:

Use./apachectl-kstart in the Apache/bin directory to enable it later, and use./apachectl-kstop to stop it.

Of course, you can also add/usr/local/apahce/bin to the PATH so that it can be used in any directory.

MySQL compilation and Installation

I. Software Packages

MySQL-5.6.22-1.el7.src.rpm

2. Compile and install MySQL (refer to mysql official: http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html)

rpm-iMySQL-5.6.22-1.el7.src.rpm mv . /rpmbuild/SOURCES/mysql-5 .6.22. tar .gz./ \ rm -rMySQL-5.6.22-1.el7.src.rpmrpmbuild/ tar zxfmysql-5.6.22. tar .gz cd mysql-5.6.22 mkdir /home/data

2. Install the auxiliary function library

Yuminstall ncurses-develcmake-y

3. Added mysql user groups and users.

Groupaddmysql

Useradd-r-gmysqlmysql

4. Compile and install (Note: Since the new MySQL5.6 is compiled using CMake to compile parameters see mysql source code installation manual: http://dev.mysql.com/doc/refman/5.6/en/mysql-install-db.html)

For example:

cmake\ -DCMAKE_INSTALL_PREFIX= /usr/local/mysql \ -DMYSQL_UNIX_ADDR= /usr/local/mysql/mysql .sock\ -DDEFAULT_CHARSET=utf8\ -DDEFAULT_COLLATION=utf8_general_ci\ -DWITH_INNOBASE_STORAGE_ENGINE=1\ -DWITH_ARCHIVE_STORAGE_ENGINE=1\ -DWITH_BLACKHOLE_STORAGE_ENGINE=1\ -DMYSQL_DATADIR= /home/data/ \ -DMYSQL_TCP_PORT=3306\ -DENABLE_DOWNLOADS=1 make make install

Delete the cmakecache.txt file.

RmCMakeCache.txt

5. Configure and modify the mysql installation directory

Cd/usr/local/mysql

Chown-Rmysql: mysql.

Modify the mysql database file directory

Cd/data/mysqldb

Chown-Rmysql: mysql.

Initialize the MySQL database

Cd/usr/local/mysql

Scripts/mysql_install_db -- user = mysql -- datadir =/home/data

Copy the mysql service startup configuration file

Cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf

(Note: If the/etc/my. cnf file exists, overwrite it .)

Copy the mysql Service Startup Script and add the PATH

Cpsupport-files/mysql. server/etc/init. d/mysqld

vi /etc/profile # Add at the end of the file PATH= /usr/local/mysql/bin : /usr/local/mysql/lib :$PATH export PATH # Save and exit and run source /etc/profile # Reload the fileStart the mysql service and add it to auto-start

Servicemysqldstart

Chkconfig mysqldon

Check whether the mysql service starts netstat-tulnp | grep3306

Set the root initial password

Mysqladmin-urootpassword 'your password'

PHP compilation and Installation

One Software Package

#Libmcrypt-2.5.7.tar.gz

Export curl-7.40.0.tar.gz

#Libpng-1.6.15.tar.gz

#Freetype-2.5.4.tar.gz

#Libxml2-2.9.2.tar.gz

#Gdbm-1.11.tar.gz

#Gettext-0.19.4.tar.gz

#Mhash-0.9.3.tar.gz

#Jpegsrc.v9a.gz

When libgd-2.1.0.tar.bz2 .bz2 .gz is compiled, an error occurs.

#Zlib-1.2.8.tar.gz

#Libiconv-1.14.tar.gz

#Php-5.6.4.tar.gz

2. Compile and install zlib

Tarzxfzlib-1.2.8.tar.gz

Cdzlib-1.2.8

./Configure # do not specify the installation path for zlib.

Make & makeinstall

3. Compile and install libjpeg

Tarzxfw.src.v9a.gz

Cdjpeg-9a/

./Configure -- prefix =/usr/local/libjpeg -- enable-shared -- enable-static

Make & makeinstall

4. Compile and install libpng

Tarzxflibpng-1.6.15.tar.gz

Cdlibpng-1.6.15

../Configure -- prefix =/usr/local/libpng-1

Make & make install

5. Compile and install freetype

Tarzxffreetype-2.5.4.tar.gz

Cdfreetype-2.5.4

./Configure =/usr/local/freetype

Make & makeinstall

6. Compile and install libgd

Yuminstallbzip2-y

Tarjxflibgd-2.1.0.tar.bz2

Cdlibgd-2.1.0

# Do not specify a prefix When configuring configure. errors may occur during PHP compilation.

./Configure -- with-jpeg =/usr/local/libjpeg -- with-png =/usr/local/libpng -- with-freetype =/usr/local/freetype -- with-zlib

Make & makeinstall

7. Compile and install curl

Tarzxfcurl-7.40.0.tar.gz

Cdcurl-7.40.0

./Configure -- prefix =/usr/local/curl

Make & make install

8. Compile and install gdbm

Tarzxfgdbm-1.11.tar.gz

Cdgdbm-1.11

./Configure -- prefix =/usr/local/gdbm

Make & makeinstall

9. Compile and install libcrympt

Tarzxflibmcrypt-2.5.7.tar.gz

Cdlibmcrypt-2.5.7

./Configure -- prefix =/usr/local/libmcrypt

Make & makeinstall

10. Compile and install gettext

Tarzxfgettext-0.19.4.tar.gz

Cdgettext-0.19.4

./Configure -- prefix =/usr/local/gettext

Make & makeinstall

11. Compile and install iconv

Tarzxflibiconv-1.14.tar.gz

Cdlibiconv-1.14

./Iconv -- prefix =/usr/local/libiconv

Make & make install

The following error is reported during make:

./Stdio. h: 1010: 1: Error: 'gets' is not declared (not in the function)
Make [2]: *** [progname. o] Error 1
Make [2]: Leaving directory '/home/lmos/libiconv-1.14/srclib'
Make [1]: *** [all] Error 2
Make [1]: Leaving directory '/home/lmos/libiconv-1.14/srclib'

Make: *** [all] Error 2

Solution: Go to the srclib directory and run sed-I-e '/gets is a security/D'./stdio. in. h.

12. Compile and install libxml2

Yuminstallpython-devel-y

Tarzxflibxml2-2.9.2.tar.gz

Cdlibxml2-2.9.2

./Configure -- prefix =/usr/local/libxml2

Make & makeinstall

13. Compile and install mhash

Tarzxfmhash-0.9.3.tar.gz

Cdmhash-0.9.3

./Configure -- prefix =/usr/local/mhash

Make & makeinstall

14. Compile and install php

Tarzxfphp-5.6.4.tar.gz

Cdphp-5.6.4

# For the default installation, that is, if the./configure does not contain the prefix parameter, you can simply write -- with-XXX without assigning a value.

# You can use./configure -- help to query specific parameters.

. /configure \ --prefix= /usr/local/php \ --with-apxs2= /usr/local/apache/bin/apxs \ -- enable -calendar\ --with-mysql= /usr/local/mysql \ --with-pdo-mysql= /usr/local/mysql/bin/mysql_config \ --with-iconv= /usr/local/libiconv \ -- enable -mbstring\ --with-curl= /usr/local/curl \ -- enable -exif\ --with-gd\ --with-zlib\ --with-jpeg- dir = /usr/local/libjpeg \ --with-png- dir = /usr/local/libpng \ --with-freetype- dir = /usr/local/freetype \ --with-gdbm= /usr/local/gdbm \ --with-libxml- dir = /usr/local/libxml2 \ -- enable -gd-native-ttf\ -- enable -sockets\ --with-mcrypt= /usr/local/libmcrypt \ --with-gettext= /usr/local/gettext \ --with-mhash= /usr/local/mhash \ -- enable -shmop make && make install

# The position of php. ini can also be specified at Compilation: ---- with-config-file-path = YOURPATH

15th, configure Apachehttpd. conf

You need to modify the following items:

1. # vi/usr/local/apache/conf/httpd. conf

Find AddTypeapplication/x-gzip.gz.tgz

Add under

AddTypeapplication/x-tar.tgz

AddTypeapplication/x-httpd-php.php

AddTypeimage/x-icon.ico

2. Modify the DirectoryIndex row and add index. php

Changed to directoryindexindex.phpindex.html.

16. Modify php. ini

Locate timezone and change it to timezone = Asia/Shanghai.

17th, test

# Create an index. php file in the root path of the Apache server as follows:

Cd/home/htdocs/

Viindex. php

<? Php

Phpinfo ();

?>

Enter the IP address of the virtual machine on the host to check whether the module is loaded.

This article from the "from the Heart" blog, please be sure to keep this source http://hao360.blog.51cto.com/5820068/1621329

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.