Linux under Php+mysql+apache configuration process

Source: Internet
Author: User
Tags bz2 gettext phpinfo readable file permissions to domain

The following software is required:

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/

The software version used is as follows:

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

One. Install MySQL mysql-standard-5.0.18-linux-i686.tar.gz

I'll download all of him to the/usr/local/software directory.

Go to the installation package directory: Cd/usr/local/software

1, [[email protected] software]# chmod 755 mysql-standard-5.0.18-linux-i686.tar.gz

2, [[email protected] software]# tar xfz mysql-standard-5.0.18-linux-i686.tar.gz

After extracting the mysql-standard-5.0.18-linux-i686 directory, we enter the directory:

3, [[email protected] software]# CD mysql-standard-5.0.18-linux-i686

After entering the configuration of MySQL, the configuration process we want to give MySQL to set a

Install the directory, we set under/usr/local/mysql, think to put the file in a place easier to manage, if you also want to get more configuration information, use./configure--help:

Here I would like to highlight the compile time to choose a good MySQL default code, because if you do not choose to install by default in the JSP does not support GBK encoding

So I compiled this

To access MySQL to a dedicated user, and must give the appropriate access, here we set root and MySQL has access to.

7, we first set up a MySQL and MySQL user to access MySQL:

[Email protected] mysql-standard-5.0.18-linux-i686]# groupadd MySQL #建立mysql组

8, [[email protected] mysql-standard-5.0.18-linux-i686]# useradd mysql-g MySQL #建立mysql用户并且加入到mysql组中

9, set up the user after we initialize the table (note: You must perform this step before the following steps)

[Email protected] mysql-standard-5.0.18-linux-i686]#/scripts/mysql_install_db--user=mysql

#初试化表并且规定用mysql用户来访问初始化表以后就开始给mysql和root用户设定访问权限,;

10, [[email protected] mysql-standard-5.0.18-linux-i686]# MV Mysql-standard-5.0.18-linux-i686/usr/local/mysql

Then set permissions

Cd/usr/local/mysql

11, [[email protected] mysql]# chown-r root. #设定root能访问/usr/local/mysql

12, [[email protected] mysql]# chown-r mysql data #设定mysql用户能访问/usr/local/mysql/data, there is a MySQL database file

13, [[email protected] mysql]# chgrp-r MySQL. #设定mysql组能够访问/usr/local/mysql

14, the setup is finished, basically installed, well, we run our MySQL:

[Email protected] mysql]#/usr/local/mysql/bin/mysqld_safe--user=mysql &

If there is no problem, there should be a hint like this:

[1] 42264

# starting Mysqld daemon with databases From/usr/local/mysql/var

This proves that you've got the installation done.

Use the following command to modify the root password, the default installation password is empty, for security you must immediately modify

15,/usr/local/mysql/bin/mysqladmin-uroot Password xksoft321

Now change the password to: xksoft321

16. Set Boot auto start

CP support-files/mysql.server/etc/init.d/

Second, install Apache

Go to the installation package directory: 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

Start configuring 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, see the module compiled into Apache:

#/usr/local/apache2/bin/httpd-l

Compiled-in Modules:

Http_core.c

Mod_so.c

See the above information indicates that Apache supports the DSO mode. In this way, you can use the DSO method to add PHP and resin modules.

Iii. installation of GD

Go to 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

Iv. Installation of PHP

Go to the installation package directory: Cd/usr/local/software

1. # tar Xfz php-5.1.2.tar.gz

2, after decompression into the directory:

# CD php-5.1.2

3, the configuration, this step is more critical, be sure to set up, especially to consider what you want to support, such as GD Library, Xml,mysql and so on, if you want to know the detailed configuration, execute./configure--help to obtain:

#./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 (Troubleshooting PHP extension:mbstring)

If the above configuration is not wrong, then you should finally show thanks for using the words such as PHP, then prove that the configuration is successful, if the above configuration options are not supported, will prompt the error.

For example, you do not install MySQL, then--with-mysql can not be used, so be sure to note that the corresponding option system can support, if there is an error, then install the corresponding program, or remove the relevant options, the configuration will be compiled:

4. # make

"Build Complete" appears after successful compilation. , then you can install it:

5. # make Install

6. Copy the php.ini-dist to/usr/local/lib/and rename it to php.ini after the installation is complete.

# CP Php.ini-dist/usr/local/lib/php.ini

Basically here PHP is installed successfully, if there is an error in the middle, in addition to the configuration when there is no selection of the option after the general error.

7, in order to allow Apache to directly parse PHP, we have 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 the other AddType)

AddType application/x-httpd-php. php. phtml

AddType Application/x-httpd-php-source. Phps

Make sure that you have the following sentence in the file, without adding it to all loadmodule:

LoadModule Php5_module modules/libphp5.so

Add the index.php to the following DirectoryIndex back

DirectoryIndex index.php index.html Index.html.var

OK, in VI use ": Wq" to save the httpd.conf file, Exit VI.

8. Start Apache server:

#/usr/local/apache2/bin/apachectl Restart

Now Apache is able to run PHP, write a file test, in the/usr/local/apache2/htdocs directory, create a new phpinfo.php file,

There is only one line of code in the file:

Save this file, enter http://localhost/phpinfo.php in your browser, and you should see the system Information for PHP.

If an error occurs, such as prompting you to download phpinfo.php, then Apache is still unable to parse the php file, then please carefully check the above operation is correct.

Wu, Zendoptimizer

Go to the installation package directory: Cd/usr/local/software

1. # tar Xfz zendoptimizer-2.6.2-linux-glibc21-i386.tar.gz

2. # CD Zendoptimizer-2.6.2-linux-glibc21-i386

3, #./install.sh

4. Ask confirm the location of your php.ini file when entering/usr/local/lib/

Q Is you using Apache Web server? Select Yes

Six

1,./configure--prefix=/usr

2. Make

3. Make check

4. Make install

Start service configuration with System

If you want to run the HTTPD service when the computer starts, you can include these lines in the/etc/rc.d/rc.local file:

#start Apache

/usr/local/apache2/bin/apachectl start

If you cannot start, execute permissions for the appropriate startup script

Like Apache can't start chmod a=x apachectl

For later operation do not enter a path like/usr/local/apache2/bin, add the $path variable in the/etc/profile file

Add Apache, tomcat, and MySQL paths together.

Report:

First, the establishment of resin and Apache virtual host

For example, set up a tes1.jsp.com test2.jsp.com two virtual hosts

Vi/usr/java/httpd2/conf/httpd.conf

Copy the following into the httpd.conf.

Namevirtualhost 192.168.0.* Virtual Host building IP

directory where the documentroot/home/jsp1/files are located

ServerName tes1.jsp.com access to domain names

VirtualHost 192.168.1.*>

documentroot/home/jsp2/

ServerName test2.jsp.com

Vi/usr/java/resin/conf/resin.conf

Find the following code and modify:

<!--
-Configures an explicit root web-app matching the
-WebApp ' s ROOT
-
<web-app id= '/' document-directory= '/usr/java/httpd2/htdocs '/>
<web-app id= '/' document-directory= '/home/jsp1 '/>
<web-app id= '/' document-directory= '/home/jsp2 '/>

Save from Kai Apache and resin

Tes1.jsp.com and tes2.jsp.com Virtual hosts can run the

Can do the following test http://localhost/caucho-status/

You can see that the test surface has

Virtual host:tes1.jsp.com:80

Virtual host:tes2.jsp.com:80

Prove that JSP virtual host is working properly

II. installation of Linux software

Linux packages found on the website or on a CD-ROM, common formats include rpm,deb,tar,gz,tgz,zip,bz2, and so on. We usually use the most is the RPM and tgz, according to statistics, the most popular online version should be changed to Redhat and Mandrake, and these two versions are in RPM package

, Tar is the most versatile package format, and almost every Linux software will provide a tar-formatted package, since this format is supported by any version of Linux, so you should at least understand how tar and RPM are used. As for the Deb can be converted to tgz or RPM using the Alien tool. BZ2 can be unpacked with BUNZIP2.

1. Installation of RPM files

RPM is an abbreviation for the Redhat Package Manager (Redhat Packages management tool), although the file format name is Redhat, but its original design concept is open and now includes Openlinux,mandrake and turbo Linux distributions, such as Linux, are accepted as industry standards.

RPM files are 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 is fast enough, you can install the application directly from the network by simply adding the appropriate URL path to the software's file name:

Rpm-i ftp://ftp.trilon.com/pub/xv/xv-3.10a-13.i386.rpm

As a package management tool, RPM manages the data for all RPM program components that the system has installed. We can also use RPM to uninstall the relevant application.

RPM-E XV

Common parameters for RPM also include:

-VH: Display the installation progress;

-U: Upgrade package;

-QPL: Lists the file information in the RPM software package;

-QPI: Lists description information for RPM packages;

-QF: Find out which RPM package the specified file belongs to;

-va: Check all RPM packages to find the missing files;

More detailed parameters and their usage can be viewed in the RPM help documentation.

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 mouse click, which is more convenient than Windows 98. But this must first install KDE.

I still introduce the more common method, still take the XV software as an example, after finding the xv-3.10a-13.i386.rpm file in the Linux file Manager, right-click on it, and in the pop-up menu, you can find three instructions for the RPM package: Show Info, Upgrade, Install.

After selecting "Show info", we will be able to see the Package Information window. The window is divided into three parts, the top shows the software name, size, creation and installation date and the developer's website and other relevant information, in the middle of the box is about the software overview, and the following shows the package contains all the files and their path information, It will tell you which files within the package will be installed in the system's directory,

The advantage of being aware of this information is that you can easily find the path to the startup program.

When you click on the "Install" or "Upgrade" button at the bottom, the installation or upgrade of the software will begin, and a window will appear prompting for the installation progress.

The RPM package has many advantages over other types of packages, but it does not mean that the RPM software installation is smooth. Common errors include the installation of an installed software, the software to be installed requires support for other software or system library files (which should be installed before the relevant software or system library files), and so on, similar to Windows.

2, the installation of tar

tar.gz, Tar. Z, tgz, bz2 and other file formats must first be decompressed to tar and then unpacked with tar to install. Examples of decompression and unpacking instructions are described below:

1. Solution Xv.tar.gz:tar ZXF xv.tar.gz

2. Solution Xv.tar.z:tar ZXF Xv.tar.z

3. Solution Xv.tgz:tar ZXF xv.tgz

4. Solution Xv.bz2:bunzip2 XV.BZ2

5. Solution Xv.tar:tar XF Xv.tar

A bunch of files that get unpacked will usually be stored in a directory. Depending on the software author, some of them will be compiled programs, and more is the need to compile their own source code. After entering the corresponding directory, using the "ls-f-color" instruction, the executable program will be marked with "*" bright green display, for the compiled program, directly type the command line with the path to run the program.

Recommended to read the document after the decompression, you should first use VI and other document editor to read the readme, install and other important related documents, here you will find the software detailed compilation steps and notes, you can understand the installation of the requirements, if necessary, you need to change the compilation configuration.

The source code of some packages can be uninstalled with the Make install command after compilation and installation, and if this feature is not provided, the uninstallation of the software must be manually removed. Since the software may be distributed across multiple directories in the system, it is often difficult to remove it cleanly, you should configure it before compiling, specifying that the software will be installed to the target path:./configure--prefix= directory name, so you can use "RM-RF Software directory Name" command to perform a clean and thorough uninstallation. Compared with other installation methods, it is most difficult for users to compile and install themselves, it is suitable for people who have some experience in Linux, and it is generally not recommended for beginners to use.

The usual compilation steps would be this:

./configure

Make

Make install (requires root to execute this command)

Uninstall available: Make uninstall or delete manually

Once compiled, the executable program of the software can be easily discovered in the current directory or in a subdirectory named SRC. At this point, the installation of the software will be over.

3, about SRC source code file package

The source code SRC of the Linux software refers to the release form of all the program sources of the software, which requires the user to compile the executable binary code bin and install it, which has the advantage of flexible configuration, can remove or retain certain functions/modules, adapt to a variety of hardware/operating system platforms and the compilation environment. Disadvantage is difficult, generally not suitable for beginners to use.

How do you know if a tar.gz/bz2 package is a binary package or a source code package? The best way to tell what it is is to look at the list of files in the package, use the command tar ZTVF *.tar.gz extract and unpack, and go to the newly generated directory.

The files in the source package will often contain various source code files, header files *.h, C code source files *.c, C + + code source files *.cc/*.cpp, and so on, while the files in the binary package will have an executable file (often the same name as the software is the main execution file), the flag is the path containing the directory named bin (with only a few exceptions).

If Src.tar is available after unpacking and compiling in the newly generated directory, the method is described earlier, and now we will talk about the installation and co-download of src.rpm:

Installation: Rpm-rebuild xv.src.rpm

cd/usr/src/redhat/rpms/

RPM-IVH *.rpm

Uninstall: Rpm-e XV

Description: The rpm--rebuild *.src.rpm command compiles the source code and generates a binary RPM package/usr/src/redhat/rpms, and then installs the binary package.

Third, file permissions change

chmod------Some common sense of getting started

Http://www.chinaunix.net Author: wangbin posted: 2003-09-13 23:49:13

Directive Name: chmod

Usage rights: All users

Mode of use: chmod [-CFVR] [--help] [--version] Mode file ...

Description: Linux/unix file access rights are classified into three levels: file owners, groups, and others. The use of chmod can be used to control how files are accessed by others.

Put the meter:

Mode: Permission set string in the following format: [Ugoa ...] [[+-=][RWXX] ...] [,...], where u represents the owner of the file, G indicates that the owner of the file belongs to the same group (group), and O denotes other persons, a means that all three are.

+ indicates an increase in permissions,-represents a cancellation permission, = Represents a unique set of permissions.

R is readable, w means writable, x is executable, x means only if the file is a subdirectory, or the file has been set as executable.

-C: If the file permissions have changed, the change action will be displayed

-F: Do not display an error message if the file permissions cannot be changed

-V: Show details of permission changes

-r: The same permissions change for all files in the current directory and subdirectories (that is, they are changed in a recursive manner)

--HELP: Show Auxiliary Instructions

--version: Display version

Example: Set the file file1.txt to be read by everyone:

chmod ugo+r File1.txt

Set the file file1.txt to be readable by everyone:

chmod a+r File1.txt

The file file1.txt and File2.txt are set as the owner of the file, and the same group as the person to which they belong can be written, but others other than the other are not writable:

chmod ug+w,o-w file1.txt File2.txt

Set ex1.py to only the owner of the file can perform:

chmod u+x ex1.py

Set all files and subdirectories in the current directory to be readable by anyone:

Chmod-r A+r *

In addition chmod can also use numbers to represent permissions such as chmod 777 file

The syntax is: chmod ABC file

Each of the a,b,c is a number that represents the permissions of the user, Group, and other respectively.

R=4,w=2,x=1

To rwx the attribute then 4+2+1=7;

To rw-the attribute then 4+2=6;

To r-x the property, 4+1=7.

Example:

chmod a=rwx File

And

chmod 777 File

Same effect

chmod ug=rwx,o=x File

And

chmod 771 File

Same effect

Use chmod 4755 filename to give the program root privileges

Directive Name: Chown

Usage rights: Root

How to use: chmod [-CFHVR] [--help] [--version] user[:group] File ...

Description: Linux/unix is a multi-person and multi-work system, with all files owned by the owner. The chown can be used to change the owner of the file. Generally speaking, this instruction is only used by the system administrator (root), the general user does not have the authority to change the other person's file owner, and does not have the authority to change the owner of their own files to other persons. Only the system administrator (root) has this permission.

Put the meter:

User: New file owner's user idgroup: The user group of the new file owner (group)-C: If the file owner has changed, the change action is not displayed-F: If the file owner cannot be changed, do not display the error message-H: Only the link is changed More, not the one that link really points to.-V: Shows the details of the owner change-r: the same owner change (that is, one-by-one change) for all files in the current directory and subdirectories--help: Display Auxiliary description--version: Display version

Example:

Set the owner of the archive file1.txt to the Users group user jessie:

Chown Jessie:users File1.txt

The owner of all files and subdirectories in the current directory is set to user Lamport of the Users group:

Chmod-r Lamport:users *

-RW-------(600)--only the master has read and write permission.

-rw-r--r--(644)--only the master has read and write permission, and the group user and other users have Read permission only.

-RWX------(700)--only the owner has read, write, and execute permissions.

-rwxr-xr-x (755)-The master has read, write, execute permission, but the group user and other users only read, execute permissions.

-rwx--x--x (711)-The master has read, write, execute permissions, but the group user and other users only execute permissions.

-rw-rw-rw-(666)--All users have file read and write permissions. This approach is undesirable.

-RWXRWXRWX (777)-All users have read, write, and execute permissions. More undesirable approach.

Here are two general settings for the directory:

DRWX------(700)-only the owner can read and write in the directory.

Drwxr-xr-x (755)-All users can read the directory, but only the owner can change the contents of the directory.

Iv. Common Linux Commands

1. Enter the pure command line

In the terminal input

#/sbin/telinit 3

2, root password loss resolution

GRUB: On the boot loader menu, type [e] to enter edit mode.

You will face a list of boot projects. Look for a line of lines that resembles the following output:

kernel/vmlinuz-2.4.18-0.4 ro root=/dev/hda2

Press the arrow key until the line is highlighted, and then press [E].

You can now empty a box at the end of the text and add a single to tell the GRUB boot-user Linux mode. Press the [Enter] key to make the edit result effective.

You will be brought to edit mode screen, from here, press, GRUB will boot single user Linux mode. After loading, you will face a shell hint similar to the following:

sh-2.05#

Now you can change the root command and type:

bash# passwd Root

You will be asked to re-type the password to verify. After the end, the password will be changed, you can type reboot at the prompt to reboot, and then, as usual, log on as the root user.

Lilo: When the system boots to the Lilo boot screen, press the TAB key to enter the text mode for the graphical boot mode, and then at Lilo

Enter Linux single to enter the password-free console, and then use the passwd command to change the root password

Can.

V. MySQL database operation

Connect to the database server./mysql-h host_name-u user_name-p

*-H HOST_NAME (--host=host_name), the connected database hostname, can be omitted if on the local host.

*-u user_name (--user=user_name), database user name, on UNIX systems, if the login name of the system is the same as the data user name, it can be omitted. In a Windows system, you can give the database user name, such as set User=username, by setting the environment variable user.

*-P (--password), provide the database user password, with this option MySQL will prompt you to enter the password. The password entered is displayed as an asterisk to ensure security. You can also write the password directly after-p (no spaces between-p and password), but this is unsafe and not recommended.

After the connection is successful, the MySQL database server displays some welcome information. You can then open the specified database by using the mysql>use database_name command. Grant all on egroupware.* to [email protected] identified by ' Oletolet ';

Server start-up and shutdown

There are a lot of different ways to start a MySQL server under Linux and the Windows platform, which will be described separately:

* Linux platform: Under the Linux platform, each process needs to be run by a user, MySQL is best not to run as root user. We can create a MySQL user and MySQL group, MySQL server program directory and data directory owned by this user and group, other users do not have any permissions. Run the MySQL server as a MySQL user. % mysqld--user=mysql

#即使以root用户执行该命令, the MySQL database will still be associated with the MySQL user ID. In order for the server to run automatically as a MySQL user at system startup, you need to configure the My.cnf configuration file to include User=mysql in the [Mysqld] segment.

Shutdown server available% Mysql.server stop or% mysqladmin-u root-p shutdown

* Windows Platform: Manual mode: Run the c:\mysqld command directly.

As a service: Run the c:\mysqld-nt--install command, install Mysqld-nt as a service for Windows, and then run automatically whenever Windows starts. Mysqld-nt is a MySQL server that supports named pipes.

Run C:\mysqld-nt--remove to remove the service.

The way to manually start the shutdown service is to run the c:\net start MySQL and c:\net stop mysql command.

Under Windows platform:

Log on to the server with the Administrator account and close the MySQL database server.

Start the server with the--skip-grant-tables parameter:

C:\mysql\bin>mysqld-nt--skip-grant-tables

Reopen a console window and log in to the server with the MySQL command to set a new password for root:

C:\mysql\bin>mysql

mysql> use MySQL

mysql> set password for ' root ' @ ' localhost ' = password (' password ');

Uninstalling rpm

See if the installation

Rpm-qa | grep Package Name

Uninstalling the Rpm–e package name

Loading disc mount-t Iso9660/dev/hdc/mnt/cdrom

./configure \

--WITH-APXS2=/USR/LOCAL/APACHE/BIN/APXS \

--disable-debug \

--ENABLE-FTP \

--enable-inline-optimization \

--enable-safe-mode \

--enable-track-vars \

--ENABLE-TRANS-SID \

--enable-xml \

--with-mysql \

--with-xml \

./configure--with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql--with-pdo-mysql=/usr/local/ MySQL--enable-mbstring--with-xml--enable-sockets

Linux under Php+mysql+apache configuration process

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.