FreeBSD Install Mysql + Apache + PHP Novice Guide

xiaoxiao2021-03-06  25

FreeBSD Install Mysql Apache PHP Novice Guide

Seeing friends is a bit troublesome in Unix / Linux, I will not be easy to finish, so I will come to the talks, maybe I can help everyone. The operating system I use is FreeBSD5.2.1, such as

Country's operating system installation method may be different, please deal with it as appropriate. If you install FreeBSD, you can do it. Just let it customize it, I will not say it, I use the FreeBSD version of 5.2.1, it should be now now Compare new versions, I don't know later.

.

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 it is easy to put the file into a place.

Manage, if you 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 slower, it may be nearly 20 minutes (PS: My machine is a very ordinary machine, all use almost 15, 6 divisions). After the compilation is completed:

# 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 wants a special user, and must give appropriate access, here we set up root and mysql access to access. We first create a MySQL and mysql users to access mysql:

#Proupadd mysql # Create a mysql group # PW useradd mysql -g mysql #70901 to establish a mysql user and join in the mysql group

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

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 there is: [1] 42264 # starting mysqld daemon with databases from / usr / local / mysql / var 040818 10:53:45 mysqld ended

Then you have confirmed that your mysql is running, please check the error log: /usr/local/mysql/var/*.err and then determine if the installation is successful, if not successful, please check if the above steps are correct

After the installation is complete, you can use the / usr / local / mysql / bin / mysql to manage, if you installed Apache and can analyze the php, you can also use phpmyadmin to manage

Have your MySQL, remember to use mysql or mysqladmin after installation, this will not be said, please refer to the relevant article.

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 main directory of the web page. Logs is a log

Record. Apache controls startup or stop via bin / apachectl or bin / httpd.

# / 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 well, especially to consider what you want to support, such as GD library, xml, mysql, etc., if you want to know 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 the configuration is compiled:

# Make

After the compilation is successful, Build Complete. The word is displayed, then it can be installed:

# 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

Basically, the PHP is successfully installed. If there is an error in the middle, there is no error in addition to the options when the option is configured.

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 .php Addtype 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 in VI: WQ saves httpd.conf files, exits 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 reminding you of your disaster PHPINFO.PHP, apache is not to resolve the php file, then please check if the above operation is correct. Well, here, basically Mysql Apache PHP installation is completed, 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

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

New Post(0)