Home  >  Article  >  Backend Development  >  PHP+MYSQL+APACHE configuration process under Linux (Excerpt) Page 1/2_PHP Tutorial

PHP+MYSQL+APACHE configuration process under Linux (Excerpt) Page 1/2_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:58:59695browse

需要软件如下: 
apache: http://www.apache.org 
mysql: http://www.mysql.com 
php: http://www.php.net/downloads.php 
gd: http://www.boutell.com/gd/#buildgd 
ZendOptimizer http://www.zend.org/products/zend_optimizer 
Gettext http://ftp.gnu.org/pub/gnu/gettext/ 
netpbm http://sourceforge.net/projects/netpbm/ 
所用的软件版本如下: 
Redhat Enterprise As 4 
(apache)httpd-2.0.50.tar.gz 
mysql-standard-5.0.18-linux-i686.tar.gz 
php-5.1.2.tar.gz 
gd-2.0.33.tar.gz 
ZendOptimizer-2.6.2-linux-glibc21-i386.tar.gz 
Imap 
Gettext 

一.安装MYSQL mysql-standard-5.0.18-linux-i686.tar.gz 
我把他全部下载到/usr/local/software目录下 
进入安装包目录:cd /usr/local/software 
1、[root@localhost software]# chmod 755 mysql-standard-5.0.18-linux-i686.tar.gz 
2、[root@localhost software]# tar xfz mysql-standard-5.0.18-linux-i686.tar.gz 
解压后生成mysql-standard-5.0.18-linux-i686目录,我们进入该目录: 
3、[root@localhost software]# cd mysql-standard-5.0.18-linux-i686 
进入后就开始配置mysql了,配置过程中我们要给mysql设置一个 
安装目录,我们设置在 /usr/local/mysql 下,以为把文件放到一个地方比较容易管理,如果你还想获得更多的配置信息,使用 ./configure --help: 
在这里我要特别强调在编译的时候要选择好MYSQL的默认编码,因为如果不选择按默认安装的时候在JSP中就不支持GBK编码了 
所以我这样编译 
访问mysql要一个专门的用户,而且必须给相应的访问权限,这里我们就设置root和mysql有权限访问. 
7、我们先建立一个mysql和mysql用户来访问mysql: 
[root@localhost mysql-standard-5.0.18-linux-i686]# groupadd mysql #建立mysql组 
8、[root@localhost mysql-standard-5.0.18-linux-i686]# useradd mysql -g mysql #建立mysql用户并且加入到mysql组中 
9、建立用户后我们就初始化表 (注意:必须先执行本步骤后才能进行以下步骤) 
[root@localhost mysql-standard-5.0.18-linux-i686]# ./scripts/mysql_install_db --user=mysql 
#初试化表并且规定用mysql用户来访问初始化表以后就开始给mysql和root用户设定访问权限,; 
10、[root@localhost mysql-standard-5.0.18-linux-i686]# mv mysql-standard-5.0.18-linux-i686 /usr/local/mysql 
然后设置权限 
cd /usr/local/mysql 

11、[root@localhost mysql]# chown -R root . #设定root能访问/usr/local/mysql 
12、[root@localhost mysql]# chown -R mysql data #设定mysql用户能访问/usr/local/mysql/data ,里面存的是mysql的数据库文件 
13、[root@localhost mysql]# chgrp -R mysql . #设定mysql组能够访问/usr/local/mysql 
14、设置完成后,基本上就装好了,好了,我们运行一下我们的mysql: 
[root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql & 
如果没有问题的话,应该会出现类似这样的提示: 
[1] 42264 
# Starting mysqld daemon with databases from /usr/local/mysql/var 

这就证明你安装成功了 
用如下命令修改root密码,默认安装密码为空,为了安全你必须马上修改 
15、/usr/local/mysql/bin/mysqladmin -uroot password xksoft321 
现在修改的密码为:xksoft321 
16.设置开机自动启动 
cp support-files/mysql.server /etc/init.d/ 



二、安装apache 
进入安装包目录:cd /usr/local/software 
1、# chmod 755 httpd-2.0.50.tar.gz 
2、# tar xfz httpd-2.0.50.tar.gz 
3、# cd httpd-2.0.50 
开始配置APACHE 
4、#./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-mods-shared=most 
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-module=most --enable-shared=max --enable-rewrite 
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-access 
#./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all –-enable-rewrite=shared 

5、# make 
6. # make install
7. Check the modules compiled into apache:
# /usr/local/apache2/bin/httpd -l
compiled-in modules:
http_core.c
mod_so.c
Seeing the above information indicates that apache supports the dso method. In this way, the php and resin modules can be added using dso.

3. Install GD
Enter the installation package directory: cd /usr/local/software
1. tar -zxvf gd-2.0.33.tar.gz
2. cd gd- 2.0.33
3../configure --prefix=/usr/local/gd2
4. make
5. make install

Gettext
1 .tar xfz
2 cd
3 ./configure –with-prefix=/usr/local/gettext
4 make
5 make install

4. Install php
Enter the installation package directory: cd /usr/local/software
1. # tar Configuration, this step is more critical and must be set up properly, especially considering what you want to support, such as GD library, xml, mysql, etc. If you want to know the detailed configuration, execute ./configure --help to get:
# ./configure --enable-mbstring=LANG --with-mysql=/usr/local/mysql --with-gd=/usr/local/gd2 --with-apxs2=/usr/local/apache2/ bin/apxs –with-gettext=/usr/local/gettext
—enable-mbstring=LANG (solve the problem of php extension:mbstring)
If there are no errors in the above configuration, then thank you should be displayed at the end If you use PHP and other words, it proves that the configuration is successful. If the above configuration options are not supported, an error will be prompted.
For example, if you do not install mysql, then --with-mysql cannot be used, so be sure to pay attention to whether the corresponding option system It can be supported. If an error occurs, then install the corresponding program first, or remove the relevant options, and then compile after configuration:
4. # make
After the compilation is successful, the words "Build complete." will appear, then you can Installed:
5. # make install
6. After the installation is complete, copy php.ini-dist to /usr/local/lib/ and rename it to php.ini
# cp php.ini -dist /usr/local/lib/php.ini
Basically, PHP has been installed successfully here. If an error occurs in the middle, there will generally be no error except that the correct option is not selected during configuration.
7. In order to allow Apache to directly parse php, we need to do some configuration.
# vi /usr/local/apache2/conf/httpd.conf
In the httpd.conf file, add (the following two sentences should be added After other AddType)
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
Make sure there is the following sentence in the file, if not, add it yourself After all LoadModules:
LoadModule php5_module modules/libphp5.so
Add index.php after the following DirectoryIndex
DirectoryIndex index.php index.html index.html.var
Okay, in vi Use ":wq" to save the httpd.conf file and exit vi.
8. Start apache server:
# /usr/local/apache2/bin/apachectl restart
Now apache can run php. Write a file to test it in /usr/local/apache2/htdocs Directory, create a new phpinfo.php file.
There is only one line of code in the file:

Save this file and enter http:// in your browser localhost/phpinfo.php, you should see PHP system information.
If an error occurs, such as prompting you to download phpinfo.php, then apache is still unable to parse the php file, so please carefully check whether the above operations are correct.

5. ZendOptimizer
Enter the installation package directory :cd /usr/local/software
1. # tar 🎜>3. # ./install.sh
4. When asking Confirm the location of your php.ini file, enter /usr/local/lib/
When asking Are you using Apache web server? YES

6.
1../configure --prefix=/usr
2. make
3. make check
4. make install



Start the service configuration with the system
If you want to run the httpd service when the computer starts, you can add these lines to the /etc/rc.d/rc.local file:
#start apache
/usr/local/apache2/bin/apachectl start

If it cannot be started, please give the corresponding startup script executable permissions
For example, apache cannot be started chmod a=x apachectl


For future operations, do not enter a path similar to /usr/local/apache2/bin, add the $PATH variable in the /etc/profile file
Add the paths of apache, tomcat and mysql


Attachment:
1. Create virtual hosts for resin and apache
For example, two virtual hosts tes1.jsp.com test2.jsp.com are created

vi /usr/ java/httpd2/conf/httpd.conf
Copy the following content into httpd.conf
NameVirtualHost 192.168.0.* IP where the virtual host is established

DocumentRoot /home/jsp1/ The directory where the file is located
ServerName tes1.jsp.com The domain name accessed

VirtualHost 192.168.1.*>
DocumentRoot /home/jsp2/
ServerName test2.jsp.com

vi /usr/java/resin/conf/resin.conf
Find the following code and modify it:

< host id="" root-directory=".">









Save and start apache and resin
tes1.jsp.com and tes2.jsp.com virtual hosts can run
You can do the following test http://localhost/caucho-status/
You can see that there is
Virtual Host: tes1 on the test surface .jsp.com:80
Virtual Host: tes2.jsp.com:80
Prove that the JSP virtual host is working properly
2. Linux software installation
Linux software found on the website or CD Packages, common formats include rpm, deb, tar, gz, tgz, zip, bz2, etc. The ones we usually use most are rpm and tgz. According to statistics, the most popular versions on the Internet should be redhat and mandrake. Both versions are packaged in rpm
, and tar is the most versatile. Software package format, almost every Linux software will provide tar format software packages, because this format of software packages is supported by any version of Linux, so everyone must at least understand how to use tar and rpm. As for deb, you can use the alien tool to convert it to tgz or rpm. bz2 can be unpacked with bunzip2.
1. Installation of RPM files
RPM is the abbreviation of RedHat Package Manager (RedHat software package management tool). Although the name of this file format is marked with the RedHat logo, its original design concept is open. Now Linux distributions including OpenLinux, mandrake and Turbo Linux have adopted it, and it can be regarded as a recognized industry standard.
RPM files are the easiest to install on Linux systems. Take the famous image processing software XV as an example:
In Terminal, the basic installation instructions are as follows:
rpm -i xv-3.10a-13.i386.rpm
If your connection speed is fast enough , you can also install the application software directly from the network, just add the appropriate URL path before the file name of the software:
rpm -i ftp://ftp.trilon.com/pub/xv/xv-3.10a- 13.i386.rpm
As a software package management tool, RPM manages the data of all RPM program components installed on the system. We can also use RPM to uninstall related applications.
rpm-e File information;
-qpi: List description information of RPM software packages;
-qf: Find which RPM software package the specified file belongs to;
-Va: Verify all RPM software packages and find missing ones File;
For more detailed parameters and their usage, please view the RPM help document.
In X-Window, the graphical installation and management of RPM files is more user-friendly. After installing kpackage on kde, installing rpm is just a click of the mouse, which is more convenient than windows 98. But kde must be installed first.
Let me introduce the more commonly used method. Still taking XV software as an example, after finding the xv-3.10a-13.i386.rpm file in the Linux file manager, use the right mouse button Click it, and you can find three instructions specially prepared for RPM software packages in the pop-up menu: Show Info, Upgrade, and Install.
After selecting “Show Info”, we will see the package information window as shown in the figure. The window is divided into three parts. The top shows the software name, size, creation and installation date, developer website and other related information; in the middle box, there is an overview of the software; and the bottom shows the information in the software package. It contains all files and their path information. It will tell you which directories of the system each file in the package will be installed into.
The advantage of paying attention to this information is that you can easily find the path to start the program.
After clicking the "Install" or "Upgrade" button at the bottom, the software installation or upgrade will begin, and a window will pop up to prompt the installation progress.
RPM software packages have many advantages over other types of software packages, but this does not mean that the installation of RPM software is always smooth. Common mistakes include trying to install an already installed software, the software to be installed requires the support of other software or system library files (in this case, these related software or system library files should be installed first), etc. The situation is similar to that of Windows similar.

2. Installation of tar
tar.gz, tar.Z, tgz, bz2 and other file formats must be decompressed into tar first and then unpacked and installed with tar. Examples of decompression and unpacking instructions are briefly described below:
1. Solution xv.tar.gz: tar zxf xv.tar.gz
2. Solution to xv.tar.Z: tar zxf xv.tar.Z
3. Solution xv.tgz: tar zxf xv.tgz
4. Unpack xv.bz2: bunzip2 xv.bz2
5. Unpack xv.tar: tar xf xv.tar
A bunch of files obtained after unpacking are usually stored in a directory. Depending on the software author, some will be already compiled programs, while more will be source code that needs to be compiled by yourself. After entering the corresponding directory, use the "ls -F -color" command. The executable program will be displayed in bright green with an "*" mark. For compiled programs, just type the command line with the path to run the program.
It is recommended to read the description file first after unzipping. You should first use a document editor such as vi to read the Readme, Install and other important related documents in the software directory. Here you will find the detailed compilation steps and precautions of the software, which you can learn about. What are the installation requirements? If necessary, the compilation configuration needs to be modified.
The source code of some software packages can be uninstalled using the make install command after compilation and installation. If this function is not provided, the uninstallation of the software must be manually deleted. Since the software may install files scattered in multiple directories of the system, it is often difficult to delete them cleanly. Then you should configure it before compiling and specify the target path where the software will be installed: ./configure --prefix=directory name , so that you can use the "rm -rf software directory name" command to perform a clean and complete uninstall. Compared with other installation methods, it is the most difficult for users to compile and install by themselves. It is suitable for people who have some experience in using Linux and is generally not recommended for beginners.
The usual compilation steps will be as follows:
./configure
make
make install (you need to obtain root identity to execute this command)
Uninstallation is available: make uninstall or manual deletion
After compilation is completed, the executable program of the software can be easily found in the current directory or a subdirectory named src. At this point, the software installation comes to an end.




http://www.bkjia.com/PHPjc/317435.html

www.bkjia.com

http: //www.bkjia.com/PHPjc/317435.htmlTechArticleThe software required is as follows: apache: http://www.apache.org mysql: http://www.mysql .com php: http://www.php.net/downloads.php gd: http://www.boutell.com/gd/#buildgd ZendOptimizerhttp://...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn