Linux Study Notes (LAMP-Environment setup)
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
Music 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 # modify datadir
Chkconfig -- add mysqld
Chkconfig mysqld on
Service mysqld start
2. install 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-mod-shared = most -- enable-so
Make & make install
Use: cat/usr/local/apache2/build/config. nice: You can view the compilation parameters.
./Bin/apachectl graceful: Do 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-ttf -- enable-mbstring -- enable -sockets -- enable-exif -- disable-ipv6
(Apxs is automatically configured for php)
Make & make install
Check which modules are installed:
/Usr/local/php/bin/php-m
/Usr/local/php/bin/php-I: Check the php parameters.
4. Configure apache with php
Vim/usr/local/apache2/conf/httpd. conf
Find:
AddType application/x-gzip. gz. tgz
Add below this row:
AddType application/x-httpd-php. php
Check:/usr/local/apache2/bin/apachectl-t
Find:
DirectoryIndex index.html
Change this row:
DirectoryIndex index.html index.htm index. php
Find:
# ServerName www.example.com: 80
To:
ServerName localhost: 80
5. Test parsing php
Vim/usr/local/apache2/htdocs/1.php
Write:
Phpinfo ();
?>
Save and continue the test:
Curl localhost/1.php
If the PHP file cannot be parsed:
Check if apache has loaded php:
Ls/usr/local/apache2/modules/libphp5.so
Ldd: Check whether the load is successful.
Check whether php has been loaded successfully:
Grep-I 'addtype'/usr/local/apche2/conf/httpd. conf
Restart apache and try again.
Test the connectivity of mysql:
Write a file and access it. The file content is as follows:
$ Conn = mysql_connect ("localhost", "root ","Password");
If ($ conn ){
Echo "mysql connection successful! ";
}
Else {
Echo "failed to connect to mysql! ";
}
?>
If "mysql is successfully connected" is output! "The connection is successful!