Tutorial on installing MySql+Apache2+PHP5.3.1 under Linux
Please download the following three necessary software to install first
1. Install apache2——————————————————————————————————
1. tar -zvxf httpd-2.2.14.tar.gz
2. cd httpd-2.2.14
3. ./configure –enable-modules=so –enable-rewrite
4.make
5.make install
6. /usr/local/apache2/bin/apachectl -k start //Start apahce
Use a browser to view [url]http://localhost[/url] and get it works, indicating that apache has been configured successfully.
7. /usr/local/apache2/bin/apachectl -k stop //Stop apache
8. After apache is successfully installed and started, apache will not start automatically after restarting the machine. It needs to be started manually. To set the random start execution command: echo "/usr/local/apache2/bin/apachectl" >>/etc/ rc.d/rc.local, the instruction means to append the string "/usr/local/apache2/bin/apachectl" to the last line of the rc.local file. rc.local is a file that is required after Linux starts successfully. A scripts file to execute.
9. Install apache2 and modify /usr/local/apache/conf/httpd.conf and find that it will not take effect. This is probably because the system uses the default installation of httpd (the default httpd configuration file is: /etc/httpd/conf/httpd. conf). To uninstall httpd installed by default on the system, execute the command: rpm -e httpd. If there are dependencies that cannot be uninstalled, add the parameter — nodeps.
Command:
rpm -e httpd --nodeps (if you want to uninstall httpd from the system, execute this)
tar -zvxf httpd-2.2.14.tar.gz
cd httpd-2.2.14
./configure --enable-modules=so --enable-rewrite
make
make install
/usr/local/apache2/bin/apachectl start
echo "/usr/local/apache2/bin/apachectl" >>/etc/rc.d/rc.local
2. Install MySql——————————————————————————————————
1. Unzip the mysql-5.1.42-linux-i686-glibc23.tar.gz file (i686 is a 32-bit operating system, glibc23 is a compiled binary file, unzip it and use it), and copy the generated folder Go to /usr/local/mysql and switch to this directory
2. sudo groupadd mysql –> Create mysql user group
3. sudo useradd -g mysql mysql –> Create a mysql user and add it to the mysql user group
4. sudo chown -R mysql . –> Set the owner of all files under mysql to the mysql user, sudo chgrp -R mysql . –> Set all groups of all files under mysql to the mysql user group (note that this is done After this step, go into the data directory and use the "ll" command to check the owner and group of all files. If there are any that do not belong to mysql, repeat this step in the data directory)
6. Execute scripts/mysql_install_db –> Create a MySQL database instance
7. Copy mysql.server under /usr/local/mysql/support-files/ to /etc/init.d/ and name it mysqld
8. Copy my-medium.cnf under /usr/local/mysql/support-files/ to /etc/ and name it my.cnf
9. At this time, you can use service mysqld start to start the mysql service. After starting, you can see that port 3306 is occupied through the netstat -atln command
10. The MySQL root user has no password by default. You can set the initial password through /usr/local/mysql/bin/mysqladmin -u root password "new password".
Command:
tar -zxvf mysql-5.1.42-linux-i686-glibc23.tar.gz
cp -a mysql-5.1.42-linux-i686-glibc23 /usr/local/mysql
cd /usr/local/mysql
groupadd mysql
useradd -g mysql mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
service mysqld start
netstat -atln
/usr/local/mysql/bin/mysqladmin -u root password "1q2w3e"
3. Install PHP5.3.1————————————————————————————————
1. tar -zvxf php-5.3.1.tar.gz decompress
2. cd php-5.3.1 switch directory
3. ./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/local/mysql
4.make
5.make install
6. cp php.ini-development /usr/local/php5/lib/php.ini
Command:
tar -zvxf php-5.3.1.tar.gz
cd php-5.3.1
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
make
make install
cp php.ini-development /usr/local/lib/php.ini
4. Reconfigure apache2 to support php——————————————————————————————————
cd /usr/local/apache2/conf
vim httpd.conf
Add LoadModule php5_module modules/libphp5.so
AddAddType application/x-httpd-php .php
or
SetHandler application/x-httpd-php