Lamp running environment Build and deploy PHP program software

Source: Internet
Author: User
Tags mysql host knowledge base phpmyadmin wordpress database

Objective

Linux+apache+mysql+php is the operating environment of most Web servers, the ability to skillfully configure this operating environment is essential for each operation, this article to install MySQL management tools phpMyAdmin and blog software WordPress as an example, Demonstrates the process of compiling and installing lamp running environment.

First, the experimental topological diagram

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/76/60/wKiom1ZRsCaCT5GjAABG3Nwf-_E620.png "title=" 1.png " alt= "Wkiom1zrscact5gjaabg3nwf-_e620.png"/>

Second, installation steps

2.1 Compile and install Apache httpd 2.4.10.

httpd2.4 version relies on Apr, apr-util these two packages, and the version requirement is higher than the system comes with the package, need to compile the installation

Compile and install Apr and Apr-util

# Tar XF apr-1.5.1.tar.bz2# cd apr-1.5.1#./configure--prefix=/usr/local/apr# make && make install
# Tar XF apr-util-1.5.3.tar.bz2# cd apr-util-1.5.3#./configure--prefix=/usr/local/apr-util--WITH-APR=/USR/LOCAL/APR # Make && make install

Compiling and installing httpd

# Tar XF httpd-2.4.10.tar.bz2# cd httpd-2.4.10#./configure--prefix=/usr/local/apache--sysconfdir=/etc/httpd24-- Enable-so--enable-ssl--enable-cgi--enable-rewrite--with-zlib--with-pcre--with-apr=/usr/local/apr-- With-apr-util=/usr/local/apr-util--enable-modules=most--enable-mpms-shared=all--with-mpm=event# make && Make install# vim/etc/profile.d/httpd24.shexport path=/usr/local/apache/bin: $PATH # source/etc/profile.d/httpd24.sh

Provide SYSV service script/etc/init.d/httpd24, can be copied from httpd rpm package, modify it

# cp/etc/init.d/httpd/etc/init.d/httpd24# Vim/etc/init.d/httpd24 ... apachectl=/usr/local/apache/bin/apachectlhttpd =${httpd-/usr/local/apache/bin/httpd}pidfile=${pidfile-/usr/local/apache/logs/httpd.pid} ... # chkconfig--add httpd24# Chkconfig httpd24 on


2.2 Installing PHP in FPM mode

# Tar XF php-5.4.26.tar.bz2# cd php-5.4.26#./configure--prefix=/usr/local/php5--with-mysql=mysqlnd--with-openssl-- With-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--enable-mbstring--with-freetype-dir--with-jpeg-dir--with-png-dir-- With-zlib--with-libxml-dir=/usr--enable-xml--enable-sockets--enable-fpm--with-mcrypt--with-config-file-path=/ etc--with-config-file-scan-dir=/etc/php.d--with-bz2# make && make Intall

Configure PHP-FPM

# CP sapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm# chmod +x/etc/rc.d/init.d/php-fpm# chkconfig--add php-fpm# CHKCO Nfig php-fpm on# cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf# vim/usr/local/php/etc/ Php-fpm.confpm.max_children = 50pm.start_servers = 5pm.min_spare_servers = 2pm.max_spare_servers = 8pid =/usr/local/php /var/run/php-fpm.pid

Installing XCache, Accelerating for PHP

# Tar XF xcache-3.2.0.tar.gz# cd xcache-3.2.0#/usr/local/php5/bin/phpize#/configure--enable-xcache-- with-php-config=/usr/local/php5/bin/php-config# make && make install# mkdir/etc/php.d# CP xcache.ini/etc/ php.d# vim/etc/php.d/xcache.iniextension =/usr/local/php5/lib/php/extensions/no-debug-non-zts-20121212/xcache.so #如果有多条extension, make sure that the article is in the first place

Simply install MySQL on the Apache server and test for phpMyAdmin connectivity.

# yum-y Install mysql-server# mysql-uroot-p-E "Grant all on * * to [email protected] '% ' identified by ' 123456 ';" # Mysql-uroot-p-E "drop user" @localhost; " # Mysql-uroot-p-E "Drop user" @localhost. Localdomain; " # service Mysqld Start

2.3 Install MySQL in Universal binary mode.

# useradd-r-m-s/sbin/nologin mysql# mkdir-p/mydata/data# tar xf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz-c/usr/lo cal/# cd/usr/local/# ln-sv mysql-5.6.26-linux-glibc2.5-x86_64/mysql# cd mysql # chown-r mysql:mysql./# scripts/mysql _install_db--user=mysql--datadir=/mydata/data# chown-r root/# cd/usr/local/mysql# CP support-files/mysql.server/e tc/rc.d/init.d/mysqld# chmod +x/etc/rc.d/init.d/mysqld

Modifying the master configuration file

# mkdir/etc/mysql# Vim/etc/mysql/my.cnf[mysqld]datadir =/mydata/datathread_concurrency = 4#cpu number *2port = 3306server_ id = 2socket =/tmp/mysql.sockcharacter_set_server = Utf8innodb_buffer_pool_size = 3gmax_allowed_packet = 64M

Write a test page to start the service access test environment is successfully deployed

# vim/usr/local/apache/htdocs/index.php<?php phpinfo ();  $link = mysql_connect (' 192.168.5.11 ', ' testuser ', ' 123456 ');  if ($link) echo "Success ...";  else echo "Failure ..."; Mysql_close ();? >

Third, build CA Certificate Server

# (Umask 077;openssl GENRSA-OUT/ETC/PKI/CA/PRIVATE/CAKEY.PEM 2048) # OpenSSL Req-new-x509-key/etc/pki/ca/private/cake Y.pem-out/etc/pki/ca/cacert.pem-days 3650# touch/etc/pki/ca/{index.txt,serial}# echo >/etc/pki/CA/serial

Four, configure httpd, install phpMyAdmin and WordPress.

4.1 Generate the certificate request file and send it to the CA for signing

# OpenSSL Genrsa-out/etc/httpd24/httpd.key 2048# OpenSSL Req-new-key/etc/httpd24/httpd.key-out/etc/httpd24/httpd.cs r# # SCP/ETC/HTTPD24/HTTPD.CSR [email protected]:/tmp

Sign in to the CA server, sign the certificate, and back to Apache server

# OpenSSL ca-in/tmp/httpd.csr-out/tmp/httpd.crt# scp/tmp/httpd.crt [email protected]:/etc/httpd24/

4.2 Modify the master configuration file to provide a virtual host.

# vim/etc/httpd24/httpd.conf#documentroot "/usr/local/apache/htdocs" #Listen 80#<directory/># AllowOverride none# Require all Denied#</directory>addtype application/x-httpd-php. Phpaddtype application/ X-httpd-php-source. Phpsdirectoryindex index.php Index.htmlinclude/etc/httpd24/extra/httpd-vhosts.confloadmodule Ssl_module modules/mod_ssl.soloadmodule proxy_module modules/mod_proxy.soloadmodule proxy_fcgi_module modules/mod_ Proxy_fcgi.so
# vim /etc/httpd24/extra/httpd-vhosts.conflisten 80listen 443<virtualhost *:443 >    ServerName test.phpmyadmin.com    DocumentRoot  "/www /pma "    ErrorLog " Logs/pma-error_log "    CustomLog " logs/ Pma-access_log " common    ProxyRequests Off     proxypassmatch ^/(. *\.php) $ fcgi://127.0.0.1:9000/www/pma/$1    sslengine  on    sslcertificatefile  "/ETC/HTTPD24/HTTPD.CRT"      sslcertificatekeyfile  "/etc/httpd24/httpd.key" </VirtualHost><VirtualHost *:80>     ServerName test.wordpress.com    DocumentRoot  "/www/wordpress"     ErrorLog  "Logs/wordpress-error_log"     CustomLog  "logs/ Wordpress-access_log " common    proxyrequests off    proxypassmatch ^/(. *\.php) $ fcgi:// 127.0.0.1:9000/www/wordpress/$1</virtualhost>

4.3 Extract the phpMyAdmin and WordPress packages to the specified directory

# mkdir/www# cd/www# unzip/tmp/phpmyadmin-4.0.5-all-languages.zip# mv phpmyadmin-4.0.5-all-languages/pma# Tar xf/tmp/ Wordpress-4.3.1-zh_cn.tar.gz

To modify a program master configuration file

# cp pma/config.sample.inc.php pma/config.inc.php$cfg[' Servers ' [$i] [' host '] = ' 192.168.5.10 '; #把主机改成IP即可 # CP wordpress/wp-config-sample.php wordpress/wp-config.php # Vim wordpress/wp-config.php//* * MySQL Settings-specific information from the host you are using * *// /** WordPress database name */define (' db_name ', ' WordPress ');/** MySQL database user name */define (' Db_user ', ' testuser ');/** mysql Database password */ Define (' Db_password ', ' 123456 ');/** MySQL host */define (' Db_host ', ' 192.168.5.11 ');

Database configuration

# Mysql-uroot-p-E "CREATE database WordPress;" # Mysql-uroot-p-E "Grant all on * * to [email protected] '% ' identified by ' 123456 ';" # Mysql-uroot-p-E "drop user" @localhost; " # Mysql-uroot-p-E "Drop user" @localhost. Localdomain; "

Restart Service, Access test

# service PHP-FPM restart# service httpd24 restart

Visit WordPress

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/76/60/wKioL1ZR0QmAqnXPAACte8oODw8987.png "title=" 2.png " alt= "Wkiol1zr0qmaqnxpaacte8oodw8987.png"/>

Visit phpMyAdmin

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/76/60/wKioL1ZR0VHTvu8mAACNgJAzI1Q298.png "style=" float: none; "title=" 3.png "alt=" Wkiol1zr0vhtvu8maacngjazi1q298.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/76/61/wKiom1ZR0Przw9tpAAFsu93arfI499.png "style=" float: none; "title=" 4.png "alt=" Wkiom1zr0przw9tpaafsu93arfi499.png "/>

So far, the experiment is complete


This article is from the "Knowledge Base" blog, so be sure to keep this source http://liang178.blog.51cto.com/2137205/1715772

Lamp running environment Build and deploy PHP program software

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.