CentOS Build Install Lamp

Source: Internet
Author: User
Tags mcrypt

LAMPEnvironment Building (compilation and Installationcentos+httpd2.2+mysql5.5+php5.4)First, prepare the following compression packages


<ignore_js_op>

(1) Compile and installApache

1, configure the firewall, open 80 ports, 3306 ports
Execute the following command:
#vi/etc/sysconfig/iptables
Add the following two rules to port 22 below this rule
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT #允许80端口通过防火墙
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT #允许3306端口通过防火墙

2, determineIP[email protected] ~]# Ifconfig eth03, determine host name[email protected] ~]#Hostnamewww.htu.com

4Uninstallhttpd, and unzip the source packageRPM-E httpd httpd-manual webalizersubversion mod_python mod_ssl mod_perl php php-common mysql dovecot–nodepstar xzf http D-2.2.17.tar.gz-c/usr/src///The source package is extracted to the/usr/src




5, compiling and installingApache[Email protected]]#/configure--prefix=/usr/local/httpd--enable-so--enable-rewrite-- Enable-charset-lite && make &&make install6, view the results of the installation [email protected] ~]#ls/usr/local/httpd/Bin build Cgi-bin conf error htdocs icons include lib logs man manual modulessohttpdThe execution directory is in/usr/local/httpd/bin/this directory, but I would feel very redundant, so I used to talk about theLNto connect[[email protected] httpd] #ln-S/usr/local/httpd/bin/*/usr/local/bin/[email protected] ~]#httpd-v 7, adding services, adding service recognition configuration[email protected] ~]# cp/usr/local/httpd/bin/apachectl/etc/init.d/httpdVi/et c/init.d/httpd#chkconfig: 8515#description: httpd start Server[email protected] ~]#Chkconfig--add httpd[email protected] ~]#chkconfig--list httpdhttpd 0:Close1:Close2:Close3:enabled4:Close5:enabled6:Close[email protected] ~]#chkconfig--level httpd on8Edithttpdto add a domain name to the main configuration file vi/usr/local/httpd/conf/httpd.confServerName www.htu.com:80CheckhttpdThe syntax error[email protected] ~]#/usr/local/httpd/bin/apachectl-tSyntax OK9 Starting the HTTPD service/etc/init.d/httpdstartVerify that the service is turned on[email protected] ~]#NETSTAT-NATP | grep httpdTCP 0 0::: +:::* LISTEN 29040/httpd10 Test Time Success <ignore_js_op>

(2) Compile and install MYSQL1 preparation: Uninstall RPM Mysql-server
[Email protected]/]# rpm-e mysql-server–nodeps
[[email protected]/] #useradd-M-u 49-s/sbin/nologin mysql//create MySQL run user MySQL
Starting from 5.5 instead of using CMake to compile the source code instead./configure,
Before compiling and installing mysql5.5.x, the packages that require minimal installation are:
gcc4.4.6, gcc-c++, CMake, Ncurses-devel, bison
Just install CMake, ncurses-devel, bison on your Linux system,
[email protected] ~]# Yum install gcc gcc-c++
[[Email protected] ~] #yum Install Ncurses-devel
First of all, first go to the Internet to download a cmake software, install CMake-premise software.
[Email protected]~]# tar zxvf cmake-2.8.5.tar.gz-c/usr/src(unzip)
[Email protected] ~]# CD cmake-2.8.5(enter directory)
[Email protected] cmake-2.8.5]#./configure–prefix=/usr/local/cmaked(pre-compilation configuration-prefix= path to/usr/local/cmaked/)
[[email protected] cmake-2.8.5]# gmake && gmake Install(compile and install)
CMake Installation Completecmake-d< variables >=< values>
2.Installing mysql5.5.20

[Email protected] ~]# tar zxvf mysql-5.5.20.tar.gz-c/usr/src(unzip)
[Email protected] ~]# CD mysql-5.5.20(enter directory)
[Email protected] mysql-5.5.20]# Cmake-dcmake_install_prefix=/usr/local/mysqld-dmysql_unix_addr=/tmp/mysql.sock
-ddefault_charset=utf8-ddefault_collation=utf8_general_ci-dwith_extra_charsets=all-dwith_innobase_storage_ Engine=1
-dwith_archive_storage_engine=1-dwith_blackhole_storage_engine=1-dwith_perfschema_storage_engine=1
-dwith_ssl=yes-denabled_local_infile=1(pre-compilation configuration) 
[[email protected] mysql-5.5.20] #make && make install (compile and install)

Note: If you are prompted for a compile-time error Cmake:command not foundEnter the commandexport Path=/usr/local/cmake/binpath #PATH =of yourCamkecompile the specified path
#这里编译cmake的时候没有指定路径 Execute the above command if you have a path
3post-Installation debugging  Set up the configuration file, here we copy the existing template
[[email protected] mysql-5.5.20] #cp support-files/my-medium.cnf/etc/my.cnf
withMySQLUser Initialization Database(/usr/local/mysqld/scripts)




4. Initializing the database
[Email protected] ~]# /usr/local/mysqld/scripts mysql_install_db--user=mysql
FATAL error:could not find./bin/my_print_defaults
If you compiled from source, you need to run ' make install ' to
Copy the software into the correct location ready for operation.
If you is using a binary release, you must either is at the top
Level of the extracted archive, or pass the--BASEDIR option
Pointing to the location.
# initialization encountered this error because there is no directory specified for the installation directory and the data is stored.
[email protected] ~]#./mysql_install_db--user=mysql--basedir=/usr/local/mysqld/--datadir=/usr/local/mysqld/ data/5. Modify the owner of the database file
[Email protected]/]# chown-r root:mysql/usr/local/mysqld/
[Email protected]/]# chown-r mysql/usr/local/mysqld/data/
6. Optimize the path of the MySQL program directory
[Email protected]]# ln-s/usr/local/mysqld/bin/*/usr/local/bin/
[Email protected] bin]# ln-s/usr/local/mysql/lib/*/usr/lib
[Email protected] bin]# ln-s/usr/local/mysql/include/mysql/*/usr/include/
And then to do is add the system service, so it is convenient for us to open and close the
[Email protected] bin]# cp/usr/src/mysql-5.5.20/support-files/mysql.server/etc/rc.d/init.d/// Copy the service startup script from the source bundle to the auto-start path
[[email protected] bin] #chmod A+x/etc/rc.d/init.d/mysql.server (to perform service run permissions)
[[email protected] bin] #chkconfig –add mysql.server (plus service)
Now it is convenient to open and close, but also can see the port number of mysqld 3306 then by default we can log in with root, no password
[[Email protected]/]# path= $PATH:/usr/bin/Specify the path to the command search, so you can find the Mysqladmin command.
[Email protected]/] #mysqladmin –u–p "HTUIDC"

<ignore_js_op> (3) Compile and install PHP preparation and Installation 1 first, you need to uninstall the PHP-related RPM package to avoid late collisions (no need to uninstall-)
rpm-e php php-cliphp-ldap Php-common php-mysql–nodeps
Installing Libmcrypt
[Email protected]/usr/src]# cd/usr/src/libmcrypt-2.5.8/
[Email protected] Libmcrypt-2.5.8]#./configure
[[email protected] libmcrypt-2.5.8] #make && make install
[[email protected] libmcrypt-2.5.8] #ln-S/usr/local/lib/libmcrypt.*/usr/lib
Installing Mhash
[Email protected]/usr/src]# tar xzf mhash-0.9.9.9.tar.gz-c/usr/src/
[Email protected]/usr/src]# cd/usr/src/mhash-0.9.9.9/
[Email protected] Mhash-0.9.9.9]#./configure
[[email protected] mhash-0.9.9.9] #make && make install
[Email protected] mhash-0.9.9.9]ln-s/usr/local/lib/libmhash*/usr/lib
Installing MCrypt
(Install a libxml2-devel via RPM or yum)
Yum–y Install Libxml2-delvel
RPM–IVH Libxml2-delvel
[Email protected]/usr/src]# tar xzf mcrypt-2.6.8.tar.gz-c/usr/src/
[Email protected]/usr/src]# cd/usr/src/mcrypt-2.6.8/
[Email protected] Mcrypt-2.6.8]#./configure
[[email protected] mcrypt-2.6.8] #make && make install
Install PHP
[Email protected]/usr/src]# tar xzf php-5.3.6.tar.gz-c/usr/src/
[Email protected]/USR/SRC # cd/usr/src/php-5.3.6/
[[email protected]]#./configure--prefix=/usr/local/php5--with-mcrypt--with-apxs2=/usr/local/httpd/bin/apxs
--with-mysql=/usr/local/mysqld/--with-config-file-path=/usr/local/php5--enable-mbstring--prefix: Set the installation path of the PHP program-
-enable-mbstring: Set PHP Support multibyte string--WITH-APXS2: Set the file path location of the APXS module support program provided by Apache server
--with-configure-file-path: Set the location of the PHP program's configuration file
[[email protected] php-5.3.6] #make && make install2, copyphp.ini configuration file
[email protected]/]# Cp/usr/src/php-5.3.6/php.ini-development/usr/local/php5/php.ini 
3OptimizedZendguardloader
[[email protected] 1234] #tar xzf 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]]# CP zendguardloader.so/usr/local/php5/lib/php
Copy optimization module to PHPModule Folderand then modifyphp.ini
Vi/usr/local/php5/php.ini
zend_extension=/usr/local/php5/lib/php/zendguardloader.so
Zend_loader.enable=1
[email protected]]# vi/usr/local/httpd/conf/httpd.conf
addtypeapplication/x-httpd-php. PHP// This is to be added manually.PHPfunction
<IfModuledir_module>
DirectoryIndex index.html index.php// Add Web SupportPHP
</IfModule>
Notice that the restart takes effect after the change
Setenforce0 CloseSelinux
[email protected]]#/etc/init.d/httpd restart

3, TestPHPOperating EnvironmentcompilingPHPWeb Test file
[[email protected] htdocs] #vi test1.php
<?php
Phpinfo ();
?>
<ignore_js_op>
(2 test pages should be entered manually)

[[email protected] htdocs] #vi test2.php
<?php
$link =mysql_connect (' localhost ', ' root ', ' htuidc ');
if ($link)
echo "Success";
?>
<ignore_js_op>

<ignore_js_op>

CentOS Build Install Lamp

Related Article

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.