Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The process of installing MySQL+Apache+PHP under FreeBSD

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the process of installing MySQL+Apache+PHP under FreeBSD. Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's learn how to install MySQL+Apache+PHP under FreeBSD.

See friends install mysql in Unix/Linux a little trouble, I also not easy to install finished, so let me say, maybe can help you. I am using FreeBSD 5.2.1, if the installation method for other operating systems may be different, please handle it.

FreeBSD installation will not talk about, as long as a little customization can be, the process I do not say, I use FreeBSD version 5.2.1, should be now relatively new version, do not know later:) .

I. install MySQL

I use Mysql is 4.0.20, source code version, you can also use RPM package or binary version, installation method may be different, please refer to other articles.

Download Mysql 2.0.20 source code version first, address: http://dev.mysql.com/downloads/mysql/4.0.html

Download it to/usr/local/src, or create your own if you don't already have one. The downloaded package is called mysql-4.0.20.tar.gz, and we unzip it:

# tar -zxvf mysql-4.0.20.tar.gz

After extracting the mysql-4.0.20 directory, we enter the directory:

# cd mysql-4.0.20

After entering the configuration mysql began, configuration process we have to set up an installation directory mysql, we set in/usr/local/mysql, think the file into a place easier to manage, if you want to get more configuration information, use./ configure --help:

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

Then wait a few seconds and compile the source code once the configuration is complete:

# make

This compilation process is relatively long, if the machine is relatively slow, it may take nearly twenty minutes ( PS: my machine is a very ordinary machine, all used almost 15,6 minutes:( ) .

After compilation, install:

# make install

Wait a few seconds for installation to complete. Here is the most critical part, why the old installation failed,(PS: at least I installed N times,N > 10 , ha ha), the key to the problem here, access to mysql to a dedicated user, and must give the appropriate access rights, here we set root and mysql have access.

Let's create a mysql and mysql user to access mysql:

# pw groupadd mysql #create mysql group

# pw useradd mysql -g mysql #Create mysql user and join mysql group

Once the user is created, we initialize the table (note: this step must be performed before the following steps can be performed)

# ./ scripts/mysql_install_db --user=mysql #Initialize the table and specify access with mysql users

After initializing the table, we start to set access permissions for mysql and root users. We first go to the directory where mysql is installed:

# cd /usr/local/mysql

and set permissions.

# chown -R root . #Set root to access/usr/local/mysql

# chown -R mysql var #Set mysql users can access/usr/local/mysql/var , which stores mysql database files

# chown -R mysql var/. #Set mysql users to access all files under/usr/local/mysql/var

# chown -R mysql var/mysql/. The requested URL/var/mysql/was not found on this server.

# chgrp -R mysql . #Set mysql group to be able to access/usr/local/mysql

Once it's set up, it's basically installed. Okay, let's run our mysql:

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

If there are no problems, a prompt like this should appear:

[1] 42264

# Starting mysqld daemon with databases from /usr/local/mysql/var

This proves that your installation was successful if:

[1] 42264

# Starting mysqld daemon with databases from /usr/local/mysql/var

040818 10:53:45 mysqld ended

Check the error log: /usr/local/mysql/var/*.err and make sure the installation is successful. If not, check the steps above.

After installation is complete, you can connect mysql to manage it through/usr/local/mysql/bin/mysql. If you install 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.

The requested URL/usr/libexec/images/bg.png was not found on this server.

# /usr/local/mysql/libexec/mysqld start #Start mysql

# /usr/local/mysql/libexec/mysqld stop #stop mysql

The requested URL/usr/local/mysql/was not found on this server.

To run mysql every time the system restarts, we can write a script in/usr/local/etc/rc.d directory to run mysql, we write a script mysql_start.sh

#! /bin/sh

/usr/local/mysql/bin/mysqld_safe&

The requested URL/usr/local/etc/rc.d was not found on this server.

II. install Apache

Apache installation to be simple, I installed here Apache version is httpd-2.0.50, to download the compressed package: http://httpd.apache.org/download.cgi.

The downloaded package is called httpd-2.0.50.tar.gz and we put it in/usr/local/src.

First go to the directory and unzip:

# cd /usr/local/src

# tar -zxvf httpd-2.0.50.tar.gz

And then you get the httpd-2.0.50 directory, and we go into the directory.

# cd httpd-2.0.50

First configure:

# ./ configure

? --prefix=/usr/local/apache #We want to install Apache in that directory, we install it here under/usr/local/apache

? --enable-shared=max

? --enable-module=rewrite

? --enable-module=so

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

# make

After a minute or two of compilation, install:

# make install

After installation,Apache is stored in the directory/usr/local/apache, bin is the directory where the executable files are stored,conf is the directory where the configuration files are stored,htdocs is the home directory of the web pages, and logs is the log directory.

Apache starts and stops via bin/apachectl or bin/httpd.

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

# /usr/local/apache/bin/httpd -k stop #Stop apache

# /usr/local/apache/bin/httpd -k restart #restart apache

Then you can test whether apache is installed successfully via http://localhost, if apache page appears then installation is successful, otherwise please check the above steps.

III. install PHP

The PHP version we are using is 4.3.8. First download: http://www.php.net/downloads.php. The package that comes back is called php-4.3.8.tar.gz and put it in the/usr/local/src directory.

First enter the directory and unzip:

# cd /usr/local/src

# tar -zxvf php-4.3.8.tar.gz

Unzip and enter the directory:

# cd php-4.3.8

Configuration, this step is more critical, be sure to set it well, 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

? --with-apxs2=/usr/local/apache/bin/apxs

? --disable-debug #turn off php internal debugging

? --enable-safe-mode #Turn on safe mode for php

? --enable-trans-sid

? --with-xml #Support XML

? --with-mysql #Support mysql

? --enable-short-tags #Support PHP short tags

? --with-gd #Support GD library

? --with-zlib #Support zlib

? --with-jpeg

? --with-png

? --enable-memory-limit

? --disable-posix

? --with-config-file-path=/usr/local/lib

If there is no error in the above configuration, then it should finally show the words thank you for using PHP, then prove that the configuration is successful, if the above configuration options do not support it, it will prompt an error.

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 can support it, if there is an error, then install the corresponding program first, or remove the relevant options.

After configuration, compile:

# make

After successful compilation appears "Build complete." "The word, then you can install:

# make install

After installation, copy/usr/local/src/php-4.3.8/php.ini-dist to/usr/local/lib/and rename it php.ini

# cp /usr/local/src/php-4.3.8/php.ini-dist /usr/local/lib/php.ini

Basically here PHP installation is successful, if there is an error in the middle, in addition to configuration when there is no choice after the general error.

IV. Apache+PHP integration

In order for Apache to parse php directly, we need to configure it.

First go to the apache configuration file directory:

# cd /usr/local/apache/conf

Then open the configuration file httpd.conf with vi:

# vi httpd.conf

In the httpd.conf file, add

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

These two sentences should be added after the other AddTypes.

Make sure that the following sentence is in the file, not added by itself after all LoadModules.

LoadModule php4_module modules/libphp4.so

All right, save the httpd.conf file in vi using ":wq" and exit vi. Start Apache Server:

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

Now apache can run php, write a file to test it, in the directory/usr/local/apache/htdocs, create a phpinfo.php file,

There is only one line of code in the file:

Save this file and type http://localhost/phpinfo.php into your browser. You should see PHP system information.

If an error occurs, such as phpinfo.php, then apache is unable to parse php files, so check whether 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,

Also remind you can pass a phpMyadmin to manage your mysql, the latest version is phpMyadmin2.6-bet

At this point, I believe that everyone has a deeper understanding of the "FreeBSD installation MySQL+Apache+PHP process," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report