Install Apache, MySQL and PHP on Linux
This tutorial aims to guide them, those willing to have a web server on Linux, the installation the three steps free and open source packages, Apache, MySQL and PHP.
In this case we use:
OS: SuSE Linux 10.1
Compiler: GCC 4.1.0
Web server: Apache 2.2.2
Database server: MySQL 5.0.22
Interpreter: PHP 5.1.4
~> Is the console prompt
Installation processes are carried out under root privileges (su "Enter" * root_password * »Enter)
Install Apache 2.2.2
Before starting the installation, is recommended (not required) to create a user and a group that will run Apache (ie, files created by Apache (possibly results PHP script execution) will belong to the user, apache2 in our case, and affiliated with this group, WWW in our case):
~> Groupadd www
~> Useradd-g www apache2
Next we get the source server: httpd-2.2.2.tar.gz (about 6 MB)
Once I got the sources, unpacking them go to your local hard drive, opening a console in the directory where I saved the archive. Tar.gz
~> Tar-xzf httpd-2.2.2.tar.gz
~> Cd httpd-2.2.2
~>. / Configure - prefix = / usr/local/apache2 - enable-so
In the example above, the first line is unpacking the sources, the second line represents the change in the current directory the unpacking was done and the third line is the source configuration: - prefix is the destination where it will install (and will be accessible) server Apache, and - enable-so Enable Dynamic Shared Object module, in order to provide future modules such as mod_rewrite example. Command. / Configure accepts many other parameters they can find it by running the option - help (. / Configure - help).
Once completed and at this stage, we get to the actual installation of Apache:
~> Make
~> Make install
At this point, if everything went flawlessly (at least that would be under normal conditions), Apache installation is completed. Follow the system and its configuration.
The first change you'll get is the Apache configuration file, namely httpd.conf
~> Mcedit / usr/local/apache2/conf/httpd.conf
or "sadistic"
~> Vi / usr/local/apache2/conf/httpd.conf
Once opened the file, be amended to show the lines below ("..." is what should be ignored):
ServerRoot "/ usr/local/apache2"
...
<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
User your_linux_user
Group www
</ IfModule>
</ IfModule>
...
DocumentRoot "/ path / to / files / thy
...
<Directory "/path/to/your/files">
Options FollowSymLinks
AllowOverride None
</ Directory>
...
DirectoryIndex index.php index.html index.htm index.html.var
Above changes are minimal, but sufficient for what we need now.
Now we set the user rights to the directory where files will be stored on our site:
chmod-R 750 / path / to / files / your
That said, to test what we've done so far, starting, stopping or restarting the server:
~> / Home usr/local/apache2/bin/apachectl
~> / Usr/local/apache2/bin/apachectl stop
~> / Usr/local/apache2/bin/apachectl restart
Currently Apache server is up and running. But since we reset the system at a time, to make the changes necessary for it to start with the system:
~> Cp / usr/local/apache2/bin/apachectl / etc / init.d
~> Chmod 755 / etc / init.d / apachectl
~> Chkconfig - add apachectl
~> Chkconfig - level 35 apachectl on
That said, I'm done with Apache
Install MySQL 5.0.22
Above all we must ensure that the user "mysql" system exists, if not, create one (under the MySQL server will work):
~> Groupadd mysql
~> Useradd-g mysql mysql
Further, we obtain source server: mysql-5.0.22.tar.gz (approximately 18.6 MB)
Further, sources are unpacking, installation and configuration, finally, install:
~> Tar-xzf mysql-5.0.22.tar.gz
~> Cd mysql-5.0.22
~>. / Configure - prefix = / usr/local/mysql-5.0.22 - with-charset = utf8 - with-collation = utf8_general_ci
~> Make
~> Make installc
Above, we used the - with-charset = utf8 and - with-collation = utf8_general_ci to avoid installing the default Swedish.
Now create a link to the directory where you installed MySQL. In the future for easy refer to it ( the PHP installation, for example);
~> Ln-s / usr/local/mysql-5.0.22 / / usr / local / mysql
Next create my.cnf file (configuration file of MySQL's). It contains control and security options. File not written to 0, with four different ready-made support-files directory / the kit. Read them all and choose the one you think fits best. I chose my-webhosting small.cnf that are not or what not ... I need for a simple localhost. Now where should you copy it and give it write access, etc.:
~> Support-files/my-small.cnf cp / etc / my.cnf
~> Chown root / etc / my.cnf
~> Chgrp root / etc / my.cnf
~> Chmod 644 / etc / my.cnf
Now editing the file and specify that the server will run as the mysql user privileges.
~> Mcedit / etc / my.cnf
or "sadistic"
~> Vi / etc / my.cnf
line search [mysqld] and inserted immediately below it a new line that says:
user = mysql
HDDs place where I leave databases can choose to edit the my.cnf file specifying datadir parameter. (@ Whooper)
Continue to function properly, MySQL needs a MySQL database. To create one, run:
~> / Usr / local / mysql / bin / mysql_install_db - user = mysql
It will create a directory / usr / local / mysql / var / which contains the necessary databases. Here are stored the remaining databases will be created over time. Director must be written by user "mysql".
Now to start the server first (if it is an upgrade from an older version installed in the system that already exists, so do not forget to stop that latter ...):
~> / Usr / local / mysql / bin / mysqld_safe - user = mysql &
press Enter to return to the cursor / prompt. Now the MySQL server, should work. To check, following the order below to receive response from the server with some information about it:
~> / Usr / local / mysql / bin / mysqladmin version
Connecting to the MySQL server is running:
~> / Usr / local / mysql / bin / mysql-u root
You will receive a welcome message and prompt will change to mysql>
Now we set the root password before any operation:
mysql> DELETE FROM mysql.user WHERE User ='';
mysql> flush privileges;
mysql> SELECT Host, User FROM mysql.user;
will be shown a table with two columns and two rows. Search among the root contains the User column and something other than localhost in the Host column. That something is MySQL hostname (host_name)
mysql> SET PASSWORD FOR 'root' @ 'localhost' = PASSWORD ('new_password');
mysql> SET PASSWORD FOR 'root' @ 'something' = PASSWORD ('new password');
It is super-user will have rights over any existing or future databases.
Now that I'm done with this, to get out.
mysql> quit;
MySQL Reserver Server is the next step necessary amendments being made:
~> / Usr / local / mysql / bin / mysqladmin-u root-p shutdown
~> / Usr / local / mysql / bin / mysqld_safe - user = mysql &
Like the Apache, to make him start only at start-up. In the directory where sources are unpacked running:
~> Support-files/mysql.server cp / etc / init.d / mysql
~> Chmod 755 / etc / init.d / mysql
~> Chkconfig - add mysql
~> Chkconfig - level 35 mysql on
I'm done with MySQL, we have left ...
Installing PHP 5.1.4
We will install PHP as Apache module, such as intialized to start the server.
Server get sources: php-5.1.4.tar.gz (about 7.9 MB)
Decompresses and configure:
~> Tar-xzf php-5.1.4.tar.gz
~> Cd php-5.1.4
~>. / Configure - prefix = / usr / local / php - with-apxs2 = / usr/local/apache2/bin/apxs - with-mysql = / usr / local / mysql - enable-module = so - enable-bcmath - enable-calendar - with-curl - enable-exif - enable-ftp - with-gd - with-jpeg-dir = / usr / local - with-png-dir = / usr / local / png - with-gettext - with-pear - enable-sockets - with-ttf - with-freetype-dir = / usr / include / freetype - enable-gd-native-ttf - -with-zip - with-zlib
The first two parameters establish access routes and the third specific and compile with MySQL support (since version 5 since there is no default). For the remaining available parameters. / Configure - help
Next install:
~> Make
~> Make install
All necessary changes in httpd.conf (Apache's configuration file) should be made already, but just in case, check FOLLOWING lines are found there (If no, add them manually.)
LoadModule php5_module modules/libphp5.so
AddType application / x-httpd-php. php
Next create the file php.ini file to configure how PHP runs. Choose from ready-made files (the directory where the kit is located) and copy it to / lib directory where PHP:
~> Php-5.1.4/php.ini-recommended cp / usr / local / php / lib / php.ini
and if you need to edit your php.ini file:
~> Mcedit / usr / local / php / lib / php.ini
or "sadistic"
~> Vi / usr / local / php / lib / php.ini
We have left to restart Apache server
~> / Usr/local/apache2/bin/apachectl restart
To check if everything is okay, create a file test.php
<?php
phpinfo ();
?>
and access to the browser http://localhost/test.php or http://127.0.0.1/test.php or http://linux/test.php
That is all. Now you have a web server in your computer, with functional parameters.
There are 7 similar articles, click here for list.
- Install IIS on windows server
- PHP-Java interoperability
- Installing MySQL on Windows
- Install Apache on Windows
- What's up with web hosting?
- .Net and PHP
- Install Apache, MySQL and PHP on Windows
| There are no comments on this article. Be the first to say your opinion. |






