FreeBSD Install Mysql + Apache + PHP Novice Guide

xiaoxiao2021-03-06  114

FreeBSD Install Mysql Apache PHP Novice Guide

Author: heiyeluren QQ group: 5415735 (Linux / BSD installation and maintenance group) Date: 2004/8/18 - special thanks QQ group Friends Anan, the paper was produced under the guidance of his patience -

Seeing friends is a bit troublesome in Unix / Linux, I will not be able to finish it, so come to the talks, maybe help everyone. I use the operating system is FreeBSD 5.2.1, if other operating system installation The method may be different. Please handle it as appropriate. If you install FreeBSD, you can do it. Just let it customize it. I will not say it. I don't say it. I use the freebsd version of 5.2.1, it should be a new version, afterwards I don't know :).

I. Install MySQL

The mysql I use is 4.0.20, source code version, you can also use the RPM package or binary version, the installation method may not be the same, please refer to other articles. First download mysql2.0.20 source code version, address: http: / /dev.mysql.com/downloads/mysql/4.0.html The next to the / usr / local / src directory, if you don't have this directory, you will build one. Download the bag name called mysql-4.0.20.tar .gz, then we decompressed it:

# tar -zxvf mysql-4.0.20.tar.gz

After decompression, generate the mysql-4.0.20 directory, we enter the directory:

# CD mysql-4.0.20

After entering, you will start configuring mysql. In the configuration process, we have to set a installation directory for MySQL. We set it under / usr / local / mysql, think that putting the file into a place is easier to manage, if you still want to get more Configuration information, use ./configure --help:

# ./configure --prefix = / usr / local / mysql

Then wait for a few seconds, compile the source code after the configuration is completed:

# Make

This compilation process is relatively long. If the machine is slow, it may be nearly 20 minutes (PS: My machine is a very ordinary machine, all used almost 15, 6 divisions: (). Install after compilation :

# make install

Waiting for a few seconds, the installation is complete. The following is the most critical part, why is the old installation unsuccessful, (ps: at least I installed N times, n> 10, huh, huh), the key is here, visit mysql To be a special user, but must give the corresponding access, here we set up root and mysql have permission access. Let's build a MySQL and MySQL users to access mysql:

# p p gadd mysql # Established mysql group # pw useradd mysql -g mysql # Establish mysql users and join in the mysql group, it is best to re-use Chpass to remove the mysql user's landable shell, such as changed to / sbin / nologin, in order to prevent future Authorized users access.

After establishing users, we will initialize the table (note: This step must be performed first after the steps can be performed.

# ./scripts/mysql_install_db --user = mysql # initial test table and regulate the use of mysql users to access

After the initialization table starts to set access to mysql and root users, let's go to the directory where Mysql is installed:

# CD / usr / local / mysql

Then set permissions

# chown -r root. # Set Root Access / usr / mysql # chown -r mysql var # Set MySQL users can access / usr / local / mysql / var, existing mysql database file # chown -R mysql var /. # Set mysql users to access all files under usr / local / mysql / var # chown -r mysql var / mysql /. # Set MySQL users can access / usr / local / mysql / var All files under mysql # chgrp -r mysql. # Set the mysql group to access / usr / local / mysql

// Supplement, because the above privilege setting is a bit problem, then refer to other information, set the following: chown -r root / usr / local / mysql chgrp -r mysql / usr / local / mysql chown -r root / usr / local / mysql / Bin chgrp -r mysql / usr / local / mysql / bin chown -r root / usr / local / mysql / var chgrp -r mysql / usr / local / mysql / var chmod 777 / usr / local / mysql / var chown -r Root / usr / local / mysql / var / mysql chgrp -r mysql / usr / local / mysql / var / mysql chmod 777 / usr / local / mysql / var / mysql chown -r root / usr / local / mysql / var / Mysql / * chgrp -r mysql / usr / local / mysql / var / mysql / * chmod 777 / usr / local / mysql / var / mysql / * chmod 777 /usr/local/mysql/lib/mysql/libmysqlclient.a

After the setting is complete, basically install it, ok, we run our mysql:

# / usr / local / mysql / bin / mysqld_safe --user = mysql &

If there is no problem, you should appear like this:

[1] 42264 # starting mysqld daemon with databases from / usr / local / mysql / var

This proves that you have successful installation, if you appear:

[1] 42264 # starting mysqld daemon with databases from / usr / local / mysql / var040818 10:53:45 mysqld ended

If your MySQL is not running, please check the error log: /usr/local/mysql/var/*.err then determine if the installation is successful, if not successful, please check if the above steps are correct. After the installation is complete, it can pass / usr / local / mysql / bin / mysql to connect to MySQL for management, if you installed apache and can resolve PHP, you can also use phpMyAdmin to manage your MySQL, remember to use MySQL or mysqladmin to modify the root password after installation. Here we don't say it, please refer to the related articles.

Control MySQL will control the start or stop mysql by / usr / local / mysql / libexec / mysqld:

# / usr / local / mysql / libexec / mysqld start # 启 m mq q l / e / m m m m m # m

In order to run mysql after each system is restarted, you can write a script to put it in /usr/local/tc/rc.d directory, used to run mysql, we write a script mysql_start.sh

#! / bin / sh / usr / local / mysql / bin / mysqld_safe &

Then save it to the /usr/local/tc/rc.d directory, then you can start MySQL after the Reboot system later.

2. Install Apache

Installing apache to be simple, I installed the Apache version is httpd-2.0.50, go to download the compressed package: http://httpd.apache.org/download.cgi. Download the package called httpd-2.0.50.tar We are placed in / usr / local / src directory. First enter the directory and decompressed:

# CD / usr / local / src # tar -zxvf httpd-2.0.50.tar.gz then get httpd-2.0.50 directory, we enter the directory

# CD httpd-2.0.50

First configure:

# ./configure /? --prefix = / usr / local / apache / # We have to install Apache in that directory, we are installed under / usr / local / apache? --enable-shared = max /? - ENABLE-MODULE = REWRITE /? --ENABLE-Module = SO

Execute the above command, if there is no error message, prove that the configuration is successful, then compile:

# Make

Compiled in one or two minutes, then install:

# make install

After the installation is complete, Apache is stored in the / usr / local / apache directory. BIN is the directory of the execution file. Conf is the configuration file directory. HTDOCS is the home directory of the web page. Logs is a log directory .apache via bin / apachectl or bin / httpd to control start or stop.

# / usr / local / apache / bin / httpd -k start # 启 Apache # / usr / local / apache / bin / httpd -k stop ipache # / usr / local / apache / bin / httpd -k restart # restart Apache

Then you can test whether apache is successful via http: // localhost, if you appear on the page, you will be successful, otherwise check the steps above.

3. Install PHP

The PHP version we use is 4.3.8, first downloaded: http://www.php.net/downloads.php, the next package is called PHP-4.3.8.tar.gz, put it in / usr / local / Under the src directory. First enter the directory and decompressed:

# CD / usr / local / src # tar -zxvf php-4.3.8.tar.gz

After decompression, enter the directory:

# CD PHP-4.3.8

Configure, this step is more important, you must set it, especially if 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 /? --with-apxs2 = / usr / local / apache / bin / apxs /? --disable-debug / # 关 内 内部 内部? --enable-save-mode / # Open PHP security mode ? --Nable-trans-sid /? --with-xml / # support XML? --with-mysql / # support mysql? --enable-short-tags / # 支持 p p p 短? --with-GD / # Support GD library? --With-zlib / # support Zlib? --With-jpeg /? --With-png /? --Nable-Memory-Limit /? --Disable-posit /? --With- Config-file-path = / usr / local / lib

If the above configuration has no error, you should finally show the words like this, then the confirmation is successful. If the above configuration option does not support, you will prompt the error. For example, you don't have mysql, then --with-mysql Unable, so be sure to pay attention to whether the corresponding option system can support, if an error occurs, then install the corresponding program, or remove the relevant options. After configuration, compile:

# Make

After the compilation is successful, "Build Complete." Appears, then you can install:

# make install

After the installation is complete, copy the /usr/local/src/php-4.3.8/php.ini-dist to / usr / local / lib /, and renamed PHP.ini

# cp /usr/local/src/php-4.3.8/php.ini-dist /usr/local/lib/php.ini Basic to the PHP is successful, if there is an error in the middle, in addition to being configured There is no error after selecting the option.

Four. Integrated Apache PHP

In order to let Apache can directly parse PHP, we have to configure some configuration. First enter the Apache configuration file directory:

# cd / usr / local / apache / conf

Then open the configuration file httpd.conf with VI:

# vi httpd.conf

Add in httpd.conf files

AddType Application / X-httpd-php .phpaddType Application / X-httpd-php-source .phps

The above two sentences should be added after other addtype.

Make sure there is a sentence in the file, not adding yourself after all LoadModule.

LoadModule PHP4_Module Modules / Libphp4.so

Ok, use ": wq" in VI to save the httpd.conf file, exit the VI. Start Apache Server:

# / usr / local / apache / bin / httpd start

Now Apache can run PHP, write a file test, in the / usr / local / apache / htdocs directory, create a new PHPINFO.PHP file, 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 of PHP. If there is an error, such as prompting you to disaster PHPINFO.PHP, apache is not able to resolve the PHP file, then please check if the above operation is correct.

Ok, here, basically MySQL Apache PHP installation is complete, then you can do a web server, such as a forum, while reminding you to pass a phpMyAdmin to manage your mysql, now the latest version is phpmyadmin2.6-beta

Writetime 2004-8-18 19:30

转载请注明原文地址:https://www.9cbs.com/read-125344.html

New Post(0)