LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   How-To run Apache, php, MySQL on startup and install phpMyAdmin - Slackware 12.2 (http://www.linuxquestions.org/questions/slackware-14/how-to-run-apache-php-mysql-on-startup-and-install-phpmyadmin-slackware-12-2-a-693708/)

Penthux 12-29-2008 04:26 PM

How-To run Apache, php, MySQL on startup and install phpMyAdmin - Slackware 12.2
 
After a new install of Slackware 12.2, I carried out the following procedures to get everything working successfully right out of the box.
The server is a standalone system, used for testing and educational purposes, so please bear that in mind.

NB: Throughout this post when you see a single # at the start of a line it means you are typing the commands as root user. You should not include the #, only the text after it.

### setup Apache with php enabled
Login as root user on your Slackware box and type:
# pico -w /etc/httpd/httpd.conf

Press CTRL+w to search and type mod_php.conf to find this line:
#Include /etc/http/mod_php.conf
Uncomment it, just remove the # from the begining of the line.

Also find the following line:
DirectoryIndex index.html
Change it to this:
DirectoryIndex index.html index.htm index.php default.htm

Save the file and exit ( press CTRL+x ). Now type this:
# chmod 755 /etc/rc.d/rc.httpd
# /etc/rc.d/rc.httpd start

If the httpd server is not already running, you should have Apache and php running. Your web file root directory is: /var/www/htdocs
If you receive the message "httpd (pid 12345) already running" (NB: pid is just here for example and can be any value), type this:
# /etc/rc.d/rc.httpd restart

Open your browser and go to http://localhost/ and you should see this big bold message on a blank white page: It Works!

### Extra - test php is working ###
To test php is working, back on the command line type this:
# pico -w /var/www/htdocs/info.php

Copy and paste the following text into the pico text editor, or type it:
<?php
phpinfo();
?>

Press CRTL+x and save the file as info.php, or any filename you like with the .php extension.

In your browser go to http://localhost/info.php (or the filename you chose, obviously!)
You should be presented with a nice page full of information which means php is working perfectly.


### setup MySQL (secure installation)
Still logged in as root user, to setup MySQL type this:
# chmod 755 /etc/rc.d/rc.mysqld
# mysql_install_db
# chown -R mysql:mysql /var/lib/mysql
# cp /usr/share/mysql/mysql.server /etc/rc.d/rc.mysql
# chmod 755 /etc/rc.d/rc.mysql
# /etc/rc.d/rc.mysql start
# /usr/bin/mysqladmin -u root password 'password'
** ( NB: the password for MySQL root user will now be: password )
# mysql_secure_installation

Enter your password when requested ( password is: password ), follow the prompts, answering ALL questions. Then type:
# /etc/rc.d/rc.httpd restart

Now the MySQL database should be running too.

#### install phpMyAdmin 3.1.1
Again, as root user type:
# cd /var/www/html
# wget http://ovh.dl.sourceforge.net/source...english.tar.gz
# tar zxvf phpMyAdmin-3.1.1-english.tar.gz
# mv phpMyAdmin-3.1.1-english phpmyadmin
# cd phpmyadmin
# cp config.sample.inc.php config.inc.php
# pico -w config.inc.php

Now edit this line by putting anything between the quotes:
( The example here is 'your_text', you can use any letter or number combination but NO special chars! )
$cfg['blowfish_secret'] = 'your_text'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Also change 'cookie' to 'http' on this line:
$cfg['Servers'][$i]['auth_type'] = 'http';
exit and save ( press CRTL+x )
# /etc/rc.d/rc.httpd restart

Open your browser and go to http://localhost/phpmyadmin/ and you should be presented with either a login prompt or the phpMyAdmin interface, depending on your selections during the MySQL secure install process.

user: root
password: password

NB: if you changed the mysql root password, during the secure installation, use the new password.

### eof

I thought this might be a good idea for new(ish) Slackware users as there seems to be a little confusion about setting up Apache/php/MySQL.
Any corrections, additions, advice, suggestions or otherwise are, of course, gladly welcome. :>

ErV 12-31-2008 06:39 AM

I think the better place for this would be in your blog. But it is up to you.

440Music 01-14-2009 03:04 PM

Penthux,

Thanks for the info, I'd been trying to start MySQL for a couple of days and when I located this entry I found the correct answer. This wasn't a priority as I also had an error with my ATI Radon 9800. Now I can get back to testing my development on a local server.

TBones
440MUSIC.COM Internet Radio
Beyond The Reach Of Satellite

BCarey 01-14-2009 04:36 PM

why do you do

Quote:

# cp /usr/share/mysql/mysql.server /etc/rc.d/rc.mysql
# chmod 755 /etc/rc.d/rc.mysql
# /etc/rc.d/rc.mysql start
?

Brian

mRgOBLIN 01-14-2009 07:09 PM

If I remember correctly that's what the mysql documentation says to do. Certainly not required with recent versions of Slackware though.

Another optional step would be to copy (or create) an /etc/my.cnf file first. There are already sample /etc/my-{small,medium,large,huge}.cnf files that can be copied into place.

Probably something worth mentioning that is often mis-understood is that the root mysql user (and all mysql users) are totally separate from the system accounts. The passwords for all mysql accounts are stored in the mysql database itself.

BCarey 01-14-2009 07:20 PM

Quote:

Originally Posted by mRgOBLIN (Post 3408889)
If I remember correctly that's what the mysql documentation says to do.

Ah, yes, you are quite right.

Penthux: on slackware you should be able to shorten the mysql part to:

Code:

# chmod 755 /etc/rc.d/rc.mysqld
# mysql_install_db --user=mysql
# /etc/rc.d/rc.mysqld start
# mysql_secure_installation  (this will prompt to set the root password)

Also, I don't think you need to restart apache after installing phpMyAdmin.

Brian

440Music 01-15-2009 02:18 PM

I was able to get MySQL running because of this info but I'm still having trouble with PHP. I've scanned 20 to 30 post about PHP but still no luck. When I try to look at info.php I get a blank page, no error just a blank page.

<?php
phpinfo();
?>

That is what is in my test page. I only have PHP5 loaded on the Slackware 12.1 server

TBones

mRgOBLIN 01-15-2009 06:00 PM

Usually a blank page is indicative of a syntax error.

If that is the only code in your page then I would take a look at your error logs (/var/log/httpd/error_log by default) see if something shows up there.

astrogeek 01-15-2009 06:49 PM

Hi 440Music,

Quote:

Originally Posted by 440Music (Post 3410115)
I was able to get MySQL running because of this info but I'm still having trouble with PHP.... When I try to look at info.php I get a blank page, no error just a blank page.

From that and the previous posts in this thread it is not at all clear to me how you have things set up and how you are trying to look at the page. You really only state that you have mysql going, presumably from the command line (ie, not from an http process).

So, to be very clear you need to know:
1. That you have the http server running
2. That it is configured to handle php code
3. That you are accessing the page via an http request (ie, not a simple file request).

So, for the first two parts, be sure to edit /etc/httpd/httpd.conf as indicated in the first post, uncomment #Include /etc/http/mod_php.conf and restart the httpd server with /etc/rc.d/rc.httpd restart (as root). To see if it is working you should be able to open a browser, enter the address http://localhost/index.html and get a recognizable response page (/var/www/htdocs/index.html by default as I recall).

Next, unless you have set up another server root path or some virtual hosts, copy your info.php file to /var/www/htdocs/ and in your browser enter the address http://localhost/info.php - that should show the php info you are looking for.

I suspect from your post that you might be trying to open your info.php file as a file from your browser, but not as an http request, in which case you will get the blank page you describe.

You should also copy one of the /etc/httpd/php.ini-recommended or other files to /etc/httpd/php.ini, edit it and set the lines...
Code:

error_reporting = E_ALL
display_errors = on

That will allow PHP errors to be passed through to your pages.

Hope this helps!

duryodhan 01-16-2009 01:03 AM

I just find it ridiculously more simple to use xampp , it comes with all this and many other tools, is fast easy to configure , secure and makes my life easy .. just untar and you are ready to go (so if I want to reinstall etc. I don't loose the mysql tables )

and security updates are also installed easily

(not that slackware's security updates are any harder)

mRgOBLIN 01-16-2009 01:57 AM

Unless you run the mysql_install_db again you won't lose any tables with an upgrade using the standard packages. That is intended to only set up the initial DB structure.

If you are really concerned you can backup with mysqldump (or even a copy of /var/lib/mysql if the server isn't running) before the upgrade. (should be doing this anyway)

Staying up-to-date is also much easier if you stick with the stock packages.. it really isn't difficult and it's explained in many places.

One thing to be aware of is there are some X lib dependencies for some of the modules such as gd. I've listed them before in another thread.

BCarey 01-16-2009 10:27 AM

440Music,

Check the apache logs (/var/log/httpd/error_log). It must be some kind of syntax error.

Brian

440Music 01-16-2009 01:37 PM

Thanks, I found the error and got it corrected. I ran into trouble when I installed PHP5. It was already installed and I created a conflict.

Thanks for the help,
TBones

BCarey 01-16-2009 04:03 PM

Quote:

Originally Posted by duryodhan (Post 3410664)
I just find it ridiculously more simple to use xampp , it comes with all this and many other tools, is fast easy to configure , secure and makes my life easy .. just untar and you are ready to go (so if I want to reinstall etc. I don't loose the mysql tables )

and security updates are also installed easily

(not that slackware's security updates are any harder)

xampp may be a better tool for you, but setting this up in slackware is also pretty ridiculously easy.
To set up php you uncomment one line in one file.
Setting up mysql is a matter of issuing four commands.
And you get to keep the well-maintained standard slackware packages on your system.

I'm not criticizing or trying to convince, I just want to make clear to anyone looking to do this and reading this thread that configuring the already installed software is really easy. It happens frequently that people assume the stuff is not there, install some of the components from somewhere, and run into trouble. Indeed that happened in this case. (Knowing about and) using what's there gives you benefit from the robust, reliable, well-tested system for which Slackware is famous.

Brian

bsurfin 02-11-2009 10:41 PM

Now the MySQL database should be running too.

#### install phpMyAdmin 3.1.1
Again, as root user type:
# cd /var/www/html

This is where I got stopped in my tracks, here is the output:
bash: cd: /var/www/html: No such file or directory

I also physically opened the folders by clicking on the home folder, var, www, no html file inside, should I just add it as root?


All times are GMT -5. The time now is 05:35 AM.