Sun Solaris 10 – How to Setup a SAMP Server + VSFTP + Phpmyadmin (Solaris Apache2 Mysql5 Php5)

INTRODUCTION

This tutorial assumes you have some basic knowledge of how to use Unix and/or Linux and you have already installed and setup your Sun Solaris server. If you have not, please check my other tutorials on setting up a Sun Solaris server and come back to this tutorial. I will be right here waiting for you!

Okay let’s get started, and as always we are assuming you have installed and have pkg-get working with blastwave set as your mirror site.

MYSQL

Let’s take a look at the available packages to install first.

# pkg-get -a | grep mysql

This should output a good list of packages. I am going to install mysql 5 for this tutorial.

# pkg-get install mysql5

This should install several packages that mysql depends on. So let this run for a while, it might take a while depending on your internet connection. Go ahead and select “y” to all questions.

It should finish successfully and say something like this:

Installation of was successful.

bash-3.00# ## Executing postinstall script.

bash-3.00# Configuring service in SMF

MySQL 5 is using Service Management Facility. The FMRI is:

svc:/network/cswmysql5:default

No database directory found in the default location.

If you need to build the initial database directory,

see /opt/csw/mysql5/share/mysql/quick_start-csw

If you are using a non-default database directory location, please start mysql manually.

Now, isn’t that nice. It even went ahead and created our SMF file for us so that we can use Solaris 10’s SMF system. But you will notice that it could not locate the database file. So that’s what we are going to do next. We are going to use blastwave’s configuration script. Run it at the location stated above:

bash-3.00# /opt/csw/mysql5/share/mysql/quick_start-csw

Then you should get some output to your terminal that looks like this:

This is the blastwave quick start script to setup a MySQL5 database directory.

The base directory is /opt/csw/mysql5.

The default database directory is /opt/csw/mysql5/var.

If you have not setup a partition for the database and you want one; now is a good time to exit this script and create and mount the partition.

If you have not setup a my.cnf file and you do not want one of the sample files; now is a good time to exit and create the file /opt/csw/mysql5/my.cnf.

Data directory: The default is /opt/csw/mysql5/var

Follow the onscreen directions. You can go ahead with default for everything, but you might want to select one of the sample my.cnf files. The default one uses the my-small.cnf which is for a small memory footprint server. You might want to go with one of the default configs for a server that has more memory.

You should get a success response and then a message stating how to run mysql server. You are almost there! Now just type the following at your command prompt:

# svcadm enable cswmysql5

Then check to see if everything is working fine.

# svcs | grep mysql

You should get an answer like this:

online 0:22:05 svc:/network/cswmysql5:default

If you get another state like offline or maintenance, this means you have a problem and you will need to check your mysql log files or the SMF log files to see why it’s not starting.

Let’s try to connect to our mysql server. Now, if your path is currently something like this:

/usr/sbin:/usr/bin:/opt/csw/bin/

You wont be able to just call mysql from the command line. I would recommend adding a symbolic link to the mysql executeable.

# ln -s /opt/csw/mysql5/bin/mysql /opt/csw/bin/mysql

Now let’s open mysql server by typing mysql.

# mysql

It should log us right in. Type exit to exit out of mysql server. Let’s now set a root password for our mysql server. Do so like this:

# /opt/csw/mysql5/bin/mysqladmin -u root password ‘new-password’

Now let’s check this login:

Try to just type mysql at the command prompt and see what happens. You should get a denied for user root.

try again like this:

# mysql -u root -p

Then when it asks for your password give it the one you set in the above command.

You should be now logged in. Now you are complete. You have a password protected mysql server and it is now running and fully functional.

ADDITIONAL MYSQL SERVER SETTINGS

Let’s say we want to create a mysql user account to use for our websites. Let’s create this user now.

Login to mysql as root and run these commands

use mysql;

grant all privileges on *.* to ausername @ localhost identified by ‘theuserspassword’ with grant option;

APACHE

Let’s take a look at the packages available.

# pkg-get -a | grep apache

For this tutorial we will be installing apache2

# pkg-get install apache2

Let this run for a while and install all needed software. It might take a while. Just enter Yes to most of the questions.

Since we used pkg-get to install apache2 it should be pretty much just ready to go.

Let’s first create a folder to host our web files. Since Sun Solaris likes to put a majority of your disk space during install in the /export/ partition, I will create a www folder in the /export folder.

# mkdir /export/www/

Now let’s edit the config file which is located here:

bash-3.00# emacs /opt/csw/apache2/etc/httpd.conf

Change the variables you want to set. I pretty much just set the ServerName and ServerAdmin variables and changed the document root to a different place then the default. Search for the keywords to locate the portion of the config file to change.

DocumentRoot “/opt/csw/apache2/share/htdocs”

I changed this to DocumentRoot “/export/www”

And you have to change the Directory listing as well

# This should be changed to whatever you set DocumentRoot to

#

change to

Let’s edit the type of files we will serve with our web server. Search for DirectoryIndex. It should look like this:

DirectoryIndex index.html

let’s add some other pages to serve.

DirectoryIndex index.html index.php index.htm

You can add your virtual hosts to the end of this file as you like as well. More on this later.

Now let’s restart the apache2 server.

let’s check to make sure it’s loaded

# svcs | grep apache

If the response you get is the following then it’s already running, make sure it’s the cswapache2 service that is running.

online 18:03:03 svc:/network/http:cswapache2

If it’s not enabled and running you should issue the following command and check again:

# svcadm enable -rs cswapache2

Since we made changes to the httpd.conf file we should issue a restart command.

# svcadm restart cswapache2

We should be ready to go. Since the directory has no files in it yet, if you go to your browser and type the IP address of your Solaris server you should get a response with something like this:

Index of /

Congratulations! You have now gotten your apache server running.

PHP

Now let’s install php5.

# pkg-get -i php5

# pkg-get -i ap2_modphp5 mod_php5 php5_curl php5_gd php5_mcrypt php5_mysql php5_mysqli phpmyadmin

Let this install and make sure to hit “Y” to continue with the installation.

Let’s now configure our configuration file.

# emacs /opt/csw/php5/lib/php.ini

You will need to uncomment the following line (just remove the semicolon):

;extension=php_mysql.dll

Change the following three lines to match the below lines in the php.ini file

max_execution_time = 6000; Maximum execution time of each script, in seconds

max_input_time = 6000; Maximum amount of time each script may spend parsing request data

memory_limit = 128M; Maximum amount of memory a script may consume

After you make any changes to the php.ini file you will need to reboot the apache server.

Restart the apache server by issuing the command:

# svcadm restart cswapache2

Now let’s test to make sure php is working. Let’s create a file in our apache default directory.

# emacs /export/www/index.php

Then type the following in that document:

Save this file and again point your web browser to your Solaris server’s IP address. You should now get a nice php info page loading. Congratulations you have now setup your SAMP server.

VSFTP

Let’s install VSFTP

# pkg-get -i vsftpd

Let’s first edit the vsftpd config file. You will want to enable the options to allow local users to connect to the server.

# emacs /opt/csw/etc/vsftpd/vsftpd.conf

You will want to make the following changes to your config file to allow your local users to login (you might have to uncomment some of these lines so that they will be read):

anonymous_enable=NO

local_enable=YES

write_enable=YES

uncomment the xferlog_file

uncomment the data_connetion_timeout

add the following line:

chroot_local_user=YES

This will force the local user that logs in to be chrooted to his/her home directory.

The FTP server logs the user into the home directory specified by the /etc/passwd file so you need to make sure the paths are correct.

Let’s see if vsftp is running:

# svcs | grep vsftpd

It should be in an online state.

Since we made changes to the vsftp config file let’s restart the vsftpd server.

# svcadm restart cswvsftpd

PHPMYADMIN

Since we have already installed phpmyadmin with pkg-get it should already be located on our server. You can do a find to locate the folder, but it should be in the default folder. Let’s move it to our www folder

#mv /opt/csw/apache2/share/htdocs/phpmyadmin /export/www/phpmyadmin

Now you should be able to load up phpmyadmin by going to http:// yourserverip/phpmyadmin

Let’s edit our config file:

# cp /export/www/phpmyadmin/config.sample.inc.php /export/www/phpmyadmin/config.inc.php

# emacs /export/www/phpmyadmin/config.inc.php

You will want to edit the following lines:

$cfg[‘blowfish_secret’] = ‘putanythinghere’; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

// $cfg[‘Servers’][$i][‘controluser’] = ‘amysqlusername’;

// $cfg[‘Servers’][$i][‘controlpass’] = ‘amysqlpassword’;

After this, your all set! Just go back to the URL http:// yourserverip/phpmyadmin

Now it should connect to your mysql server and give you a login screen. Login with your mysql user and everything should be working at this point.

That concludes this tutorial.



Source link