Lamp platform Deployment and application
What is lamp
One of the most mature Enterprise website application Mode, can provide dynamic Web site application and development environment
constituent components
Linux, Apache, MySQL, Php/perl/python
The advantages of lamp
Low cost
Customizable and easy to develop
Easy to use, safe and stable
First, install Apache
1. Preparatory work
Server ip:192.168.3.10
[[Email protected] ~]# service iptables stop//firewall off
[[email protected] ~]# Setenforce 0//Turn off SELinux
2. Check whether the software is installed by RPM to prevent conflicts
RPM-E httpd httpd-manual webalizer subversion mod_python mod_ssl mod_perl system-config-
httpd php php-cli php-ldap php-common php-mysql mysql-server MySQL Dovecot
3. Source code installation Apache
[Email protected] ~]# tar XF httpd-2.2.17.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/httpd-2.2.17/
[Email protected] httpd-2.2.17]#/configure--prefix=/usr/local/httpd--enable-so--enable-
Rewrite--enable-charset-lite--enable-cgi
[[email protected] httpd-2.2.17]# make && make install
--prefix: Specifies which directory to install the HTTPD service to
--ENABLE-SO: Enable dynamic load module support
--enable-rewrite: Enable Web address rewriting feature
--enable-charset: Enable character Set support
--ENABLE-CGI: Enable CGI scripting support
4. Optimizing the Path
[Email protected] httpd-2.2.17]# ln-s/usr/local/httpd/bin/*/usr/local/bin/
[Email protected] httpd-2.2.17]# cd/usr/local/
[Email protected] local]# CP/USR/LOCAL/HTTPD/BIN/APACHECTL/ETC/INIT.D/HTTPD
[Email protected] ~]# VIM/ETC/INIT.D/HTTPD
#!/bin/sh
#chkconfig: 345 61 61
#description: Apache HTTPS
[Email protected] ~]# chmod +x/etc/init.d/httpd
[Email protected] ~]# chkconfig--add httpd
[Email protected] ~]# chkconfig--list httpd
[Email protected] ~]# service httpd restart
Question 1:
Httpd:apr_sockaddr_info_get () failed for localhost.com
Httpd:could not reliably determine the server ' s fully qualified domain name, using 127.0.0.1
For ServerName
HTTPd not running, trying to start
[Email protected] ~]# cd/usr/local/httpd/conf/
[Email protected] conf]# VI httpd.conf
#ServerName crushlinux.example.com:80
98 ServerName localhost:80
[[Email protected] conf]# service httpd start
[Email protected] conf]# Ps-aux |grep httpd
[Email protected] conf]# NETSTAT-ANPT | Grep:80
TCP 0 0::: +:::* LISTEN
22238/httpd
Question 2:
/usr/local/apache/bin/httpd:error while loading shared libraries:libiconv.so.2:cannot open
Shared object File:no such file or directory
There are many so modules in the/usr/local/lib directory, so add/usr/local/lib in the/etc/ld.so.conf line
[[email protected] conf] #vi/etc/ld.so.conf
/usr/local/lib
[Email protected] conf]#/sbin/ldconfig-v
You have now installed the Apach source code in/USR/LOCAL/HTTPD. Source code installation supports loadable modules
And the standard MPM prefork. You can then start the Apache server with the following command:
/usr/local/httpd/bin/apachectl start
Second, install MySQL
1. Source code installation MySQL
[[email protected] ~]# useradd-m-u 49-s/sbin/nologin mysql
[Email protected] ~]# tar XF mysql-5.1.55.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/mysql-5.1.55/
[Email protected] mysql-5.1.55]#/configure--prefix=/usr/local/mysql--with-charset=utf8--
With-collation=utf8_general_ci--with-extra-charsets=gbk,gb2312
[[email protected] mysql-5.1.55]# make && make install
[email protected] mysql-5.1.55]# CP support-files/my-medium.cnf/etc/my.cnf
[Email protected] mysql-5.1.55]# cd/usr/local/mysql/bin/
[Email protected] bin]#/mysql_install_db--user=mysql
[Email protected] bin]# chown-r root:mysql/usr/local/mysql/
[Email protected] bin]# chown-r mysql/usr/local/mysql/var/
[Email protected] bin]# ln-s/usr/local/mysql/bin/*/usr/local/bin/
[Email protected] bin]# ln-s/usr/local/mysql/lib/mysql/*/usr/lib/
[Email protected] bin]# ln-s/usr/local/mysql/include/mysql/*/usr/include/
[Email protected] bin]# cd/usr/src/mysql-5.1.55/
[email protected] mysql-5.1.55]# CP support-files/mysql.server/etc/rc.d/init.d/mysqld
[Email protected] mysql-5.1.55]# chmod a+x/etc/rc.d/init.d/mysqld
[Email protected] mysql-5.1.55]# chkconfig--add mysqld
[Email protected] mysql-5.1.55]# chkconfig--list mysqld
Mysqld 0: Off 1: Off 2: Enable 3: Enable 4: Enable 5: Enable 6: Off
[Email protected] mysql-5.1.55]# service mysqld restart
Shutting down MySQL. Determine
Starting MySQL. Determine
If error: (not skipped)
[Email protected] mysql-5.1.55]# service mysqld restart
MySQL Manager or server PID file could not being found! Failed
Starting mysql.manager of Pid-file quit without updating fi[failed]
Problem:
Start MySQL Error starting mysql.manager of Pid-file quit without updating fi[failed]
Rm-rf/var/lib/mysql
/usr/local/mysql/bin/mysql_install_db--user=mysql
[Email protected] ~]# NETSTAT-ANPT | grep:3306
TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
3089/mysqld
Third, install other software packages (PHP)
1. Source Code Installation Libmcrypt
[Email protected] ~]# tar XF libmcrypt-2.5.8.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/libmcrypt-2.5.8/
[[email protected] libmcrypt-2.5.8]#./configure && make && make install
[Email protected] libmcrypt-2.5.8]# ln-s/usr/local/lib/libmcrypt.*/usr/lib/
2. Source code Installation Mhash
[Email protected] ~]# tar XF mhash-0.9.9.9.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/mhash-0.9.9.9/
[[email protected] mhash-0.9.9.9]#./configure && make && make install
[Email protected] mhash-0.9.9.9]# ln-s/usr/local/lib/libmhash*/usr/lib/
3. Source code Installation MCrypt
[Email protected] ~]# tar XF mcrypt-2.6.8.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/mcrypt-2.6.8/
[[email protected] mcrypt-2.6.8]#./configure && make && make install
Compile and install MCrypt error:
Configure:error: * * * Libmcrypt was not found
Environment variable problem: When GCC compiles, it looks for the relevant function library and other files according to its own defined variables.
Libmcrypt is not defined in the environment variable: so it needs to be added manually:
Export ld_library_path=/usr/local/lib:$ Ld_library_path
Continue compiling the installation!
4. Source Code installation PHP
[Email protected] ~]# tar XF php-5.3.6.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/php-5.3.6/
[Email protected] php-5.3.6]#/configure--prefix=/usr/local/php5--with-mcrypt--with-
Apxs2=/usr/local/httpd/bin/apxs--with-mysql=/usr/local/mysql--with-config-file-
PATH=/USR/LOCAL/PHP5--enable-mbstring
[[email protected] php-5.3.6]# && make && make install
--PREFIX=/USR/LOCAL/PHP5 //Specify installation directory
--with-mcrypt //Load Extension tool support
--WITH-APXS2=/USR/LOCAL/HTTPD/BIN/APXS//Set APXS module program file location provided by Apache
--with-mysql=/usr/local/mysql //Specify the installation path for the MySQL service
--WITH-CONFIG-FILE-PATH=/USR/LOCAL/PHP5//Specify the storage path for the PHP configuration file "PHP.ini"
--enable-mbstring//Enable multi-byte string function
Problem:
The Make && make install error message is as follows:
/usr/bin/ld:cannot Find-lltdl Collect2:ld returned 1 exit status
Make:* **[libphp5.la] Error 1
Solution:
mount/dev/cdrom/mnt/
rpm-ivh/mnt/server/libtool-1.5.22-7.el5_4.i386.rpm
rpm-ivh/mnt/server/libtool-ltdl-1.5.22-7.el5_4.i386.rpm
rpm-ivh/mnt/server/libtool-ltdl-devel-1.5.22-7.el5_4.i386.rpm
Four, set lamp components
1. Set Lamp components
[Email protected] php-5.3.6]# ls/usr/src/php-5.3.6/php.ini-*
2. Copy the sample file
[Email protected] php-5.3.6]# Cp/usr/src/php-5.3.6/php.ini-development/usr/local/php5/php.ini
3.php.ini Configuration Adjustment
[Email protected] ~]# Vim/usr/local/php5/php.ini
773 Default_charset = "Utf-8"//Set the default character set to Utf-8
871 file_uploads = on//Allow uploading of files via PHP Web page
880 upload_max_filesize = 2M//allowable file size limit for uploads
883 max_file_uploads =//per HTTP request maximum number of files allowed to upload
728 post_max_size = 8M//Data volume limit per submission via form Post
226 Short_open_tag = on//Allow to recognize PHP short grammar tags, i.e. < ... ? >
4. Add Zendguardloader module (to optimize page loading speed)
[Email protected] ~]# tar XF zendguardloader-php-5.3-linux-glibc23-i386.tar.gz-c/usr/src/
[Email protected] ~]# cd/usr/src/zendguardloader-php-5.3-linux-glibc23-i386/php-5.3.x/
[email protected] php-5.3.x]# CP zendguardloader.so/usr/local/php5/lib/php/
[Email protected] ~]# Vim/usr/local/php5/php.ini
Zend_extension=/usr/local/php5/lib/php/zendguardloader.so
Zend_loader.enable=1
5. Adjust Apache configuration
[Email protected] ~]# vim/usr/local/httpd/conf/httpd.conf
LoadModule php5_module modules/libphp5.so Configuring module files for loading PHP programs
AddType application/x-httpd-php. php. phtml Add support for ". PHP" type Web page
169 DirectoryIndex index.php index.html identify common PHP home files
[Email protected] ~]# service httpd restart
6. Functional Testing
1) test PHP for normal service delivery
[Email protected] ~]# vim/usr/local/httpd/htdocs/test1.php
<?php
Phpinfo (); built-in functions for displaying PHP environment information
?>
Service httpd Restart
Browser input: http://192.168.200.128/test1.php
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/58/FA/wKiom1TCY86xVzV4AAIjsiZIsH8127.jpg "title=" QQ picture 20150123230812.jpg "alt=" Wkiom1tcy86xvzv4aaijsizish8127.jpg "/>
2) test whether PHP can access MySQL database properly
[Email protected] ~]# vi/usr/local/httpd/htdocs/test2.php
<?php
$link =mysql_connect (' localhost ', ' root ', ');
if ($link) echo "Connect successfully!";
else echo "Connect faild!";
Mysql_close ();
?>
Service httpd Restart
Browser input: http://192.168.200.128/test2.php
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/58/F7/wKioL1TCZHiT7mJPAAE1Q_rwVTY840.jpg "title=" QQ picture 20150123230600.png "alt=" Wkiol1tczhit7mjpaae1q_rwvty840.jpg "/>
11. Deploy the Application case
Tar XF phpmyadmin-3.3.10-all-languages.tar.gz
MV Phpmyadmin-3.3.10-all-languages/usr/local/httpd/htdocs/phpmyadmin
cd/usr/local/httpd/htdocs/phpmyadmin/
CP config.sample.inc.php config.inc.php
VI config.inc.php
$cfg [' blowfish_secret '] = ' [email protected] '; /* Must FILL in the this for COOKIE auth! */
mysqladmin-u root password ' 123.com '
12.
Browser input: http://192.168.3.10/phpMyAdmin/
User name: Root
Password: 123.com
Complete deployment
This article from "Konghuai Sense" blog, reproduced please contact the author!
Lamp Platform Build Deployment