1. Install MySQL
cd/usr/local/src/
wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
Note: The above address is for 32-bit machines, if your machine is 64-bit, download this package (http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-x86_64- ICC-GLIBC23.TAR.GZ) installation method is the same.
Tar zxvf/usr/local/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
MV Mysql-5.1.40-linux-i686-icc-glibc23/usr/local/mysql
Useradd-s/sbin/nologin MySQL
Cd/usr/local/mysql
Mkdir-p/data/mysql
Chown-r Mysql:mysql/data/mysql
./scripts/mysql_install_db-user=mysql--datadir=/data/mysql
CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF
CP Support-files/mysql.server/etc/init.d/mysqld
chmod 755/etc/init.d/mysqld
Vim/etc/init.d/mysqld #修改datadir
Chkconfig--add mysqld
Chkconfig mysqld on
Service mysqld Start
2. Installing Apache
wget http://syslab.comsenz.com/downloads/linux/httpd-2.2.16.tar.gz
Tar zvxf httpd-2.2.16.tar.gz
CD httpd-2.2.16
./configure--prefix=/usr/local/apache2--enable-mods-shared=most--enable-so
Make && make install
Use: Cat/usr/local/apache2/build/config.nice: can view compilation parameters
./bin/apachectl graceful: Can not kill the process
3. Install PHP
wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
Tar zxf php-5.3.28.tar.gz
CD php-5.3.28
./configure--prefix=/usr/local/php--with-apxs2=/usr/local/apache2/bin/apxs--with-config-file-path=/usr/local/ Php/etc--with-mysql=/usr/local/mysql--with-libxml-dir--with-gd--with-jpeg-dir--with-png-dir--with-freetype- Dir--with-iconv-dir--with-zlib-dir--with-bz2--with-openssl--with-mcrypt--enable-soap--enable-gd-native-t TF--enable-mbstring--enable-sockets--enable-exif--disable-ipv6
(Apxs is automatically configured for PHP)
Make && make install
See which modules are installed:
/usr/local/php/bin/php-m
/usr/local/php/bin/php-i: You can see the PHP parameters
4. Configure Apache with PHP
Vim/usr/local/apache2/conf/httpd.conf
Found it:
AddType application/x-gzip. gz. tgz
Under this line, add the following:
AddType application/x-httpd-php. php
Detection:/USR/LOCAL/APACHE2/BIN/APACHECTL-T
Found it:
<ifmodule dir_module>
DirectoryIndex index.html
</IfModule>
Change the line to read:
<ifmodule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
Found it:
#ServerName www.example.com:80
Modified to:
ServerName localhost:80
5. Test parsing PHP
vim/usr/local/apache2/htdocs/1.php
Write:
<?php
Phpinfo ();
?>
After saving, continue testing:
Curl localhost/1.php
If you can't resolve PHP File:
See Apache loaded the PHP No:
Ls/usr/local/apache2/modules/libphp5.so
LDD you can see if the load is successful.
look at the loaded PHP success is not:
Grep-i ' AddType '/usr/local/apche2/conf/httpd.conf
and then restart Apache , and then try to see
To test the connectivity of MySQL:
Write a file and access it with the following file contents
<?php
$conn = mysql_connect ("localhost", "root", " password ");
if ($conn) {
echo "Connect MySQL successfully! ";
}
else{
echo "failed to connect MySQL! ";
}
?>
If the output "connect MySQL successfully!" "The connection is successful!"
April 27, 2015
By:champly
Linux Learning Notes (lamp-Environment Building)