How to build LAMP Architecture in Centos 6
Centos-6 builds LAMP architecture
Compile and install apache
1. Build a network YUM source
Wget http://mirrors.aliyun.com/repo/Centos-6.repo
Yum-y install epel-release
2. Delete dependent library programs, installation environment and compilation tools that come with httpd programs and install httpd
Yum-y remove httpd
Yum-y install pcre-devel openssl-devel perl gcc gcc-c++
3, compile apr apr-util (first get the three packages ready and put the httpd script in)
And decompress the three packages needed at present to the specified path in turn.
Cd / usr/src/apr-1.5.2
. / configure-- prefix=/usr/local/apr & & make & & make install # compiling apr
Cd / usr/src/apr-util-1.5.3
. / configure-- prefix=/usr/local/apr-util-- with-apr=/usr/local/apr & & make & & make install
# compiling apr-util
4, create a program user and edit httpd
Useradd-r httpd
Tail-1 / etc/passwd # can see whether the user has created it successfully.
Cd / usr/src/httpd-2.4.10
Rm-rf / etc/httpd # Delete the previous httpd configuration file
. / configure-- prefix=/usr/local/apache-- sysconf=/etc/httpd-- enable-so-- enable-ssl-- enable-cgi-- enable-rewrite-- with-zlib-- with-pcre-- with-arp=/usr/local/apr-- with-apr-util=/usr/local/apr-util-- enable-modules=most-- enable-mpms-shared=all-- with-mpm=event & & make & & make install # compile httpd
5. Optimize the execution path (PATH path) and reread the configuration path
Cd / usr/local/apache/bin # entry
Vim / etc/profile.d/httpd.sh # configure environment variables
. / etc/profile.d/httpd.sh # execute script
Httpd-t # checks the syntax to test whether the environment variable of httpd is valid
Vim / etc/httpd/httpd.conf # start the central host and modify the httpd domain name
6. Copy the service startup and stop script and modify it
Cd ~
Vim httpd
Mv httpd / etc/init.d/
Service httpd start # start the httpd service
Ss-tnl # to see if port 80 is listening
7, enable the deflate and rewrite modules, and change the owner and group
Vim / etc/httpd/httpd.conf
Ps aux # check to see if the change was successful
8, check the syntax and start the service, and verify whether the service is enabled in the browser
Httpd-t
Service httpd restart
Compile and install mariadb
1. Install dependent libraries
Yum-y install ncurses-devel libevent-devel
2, install the compilation tool, and then clear the compilation cache file
Cd / usr/src/cmake-2.8.12.2
. / bootstrap & & gmake & & gmake install
Rm-rf CMakeCache.txt
3. Create the data directory of mysql program users and databases, and start compiling mariadb
Mkdir-pv / mydata/data
Useradd-r mysql
Cd / usr/src/mariadb-5.5.44
Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/mydata/data-DSYSCONFDIR=/etc-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_READLINE=1-DWITH_SSL=system-DWITH_ZLIB=system-DWITH_LIBWRAP=0-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci & & make & & make install
4. Modify the master group of the mysql configuration directory and the data directory
Chown-R root.mysql / mydata
Chown-R root.mysql / usr/local/mysql
5. Copy and configure the mysql master configuration file, and then copy the service startup and shutdown script
Cat / usr/local/mysql/support-files/my-medium.cnf > / etc/my.cnf
Vim / etc/my.cnf
Cp-p / usr/local/mysql/support-files/mysql.server / etc/init.d/mysqld
6. Initialize mysql (under / etc/local/mysql path)
Scripts/mysql_install_db-user=mysql-datadir=/mydata/data
7, boot httpd and mysql automatically
Chkconfig-add httpd
Chkconfig-add mysqld
Chkconfig httpd on
Chkconfig mysqld on
8, optimize the path path, then start the service, verify the effect and change the root user password
Vim / etc/profile.d/mysql.sh
. / etc/profile.d/mysql.sh # startup script
Service mysqld start
Ss-tnl # to see if port 3306 is listening
Mysql # enter the mysql command line interface
Use mysql # access to mysql database
Delete from mysql.user where user=''
Set a password for root users
Update user set password=password ('666666')
Flush privileges
Mysql-u root-p # password is required to enter mysql
Install PHP5.5.7
1. Install dependent libraries and corresponding environment
Yum-y install bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel jemalloc jemalloc-devel
2, start compiling php5.5.7
Cd ~
Tar xf php-5.5.7.tar.gz-C / usr/src
Cd / usr/src/php-5.5.7
/ configure-- prefix=/usr/local/php-- with-mysql=/usr/local/mysql-- with-openssl-- with-mysqli=/usr/local/mysql/bin/mysql_config-- 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/apache/bin/apxs-- with-mcrypt-- with-config -file-path=/etc-with-config-file-scan-dir=/etc/php.d-with-bz2-enable-maintainer-zts & & make & & make install
3. Open the httpd main configuration file, determine whether the php module is added, and modify the configuration information to support php connection.
Vim / etc/httpd/httpd.conf
Httpd-t
Service httpd restart
4. Copy the main configuration file of php
Cp-p / usr/src/php-5.5.7/php.ini-production / etc/php.ini
5. Restart the apache service, write a test page, and verify the connection of the LAMAP architecture
Service httpd restart
Cd / usr/local/apache/htdocs
Mv index.html index.php
Vim index.php
Just verify it on the browser.
Deploy phpmyadmin
1, extract the phpmyadmin and move the file into the apache
Tar xf phpMyAdmin-4.0.10.17-all-languages.tar.gz
Mv phpMyAdmin-4.0.10.17-all-languages phpmyadmin
Cp-rf phpmyadmin/ / usr/local/apache/htdocs/
2, copy the master configuration file
Cp config.sample.inc.php config.inc.php
Vim config.inc.php
3, just verify it on the browser