How is LAMP server started and configured?

I installed LAMP server yesterday from the OpenSuse DVD packages, as I intend to host a web page which uses Apache, PHP and MySQL. However I cannot find how to start it up and how to set LAMP server to automatically start on system login.

Also how do I configure it once I can start it? Do I need to edit some .cfg files again? Do Apache PHP and MySQL link together correctly by default? What is the path to the MySQL storage? Thanks.

You can start Apache and MySQL from YaST or from the CLI

chkconfig --set mysql on
chkconfig --set apache2 on
/etc/init.d/mysql start
/etc/init.d/apache2 start

Thereafter they will start at boot.

You don’t need to know where MySQL stores its files since you wouldn’t access those files directly. But you need the PHP5 module php5-mysql installed to be able to communicate with the MySQL server. Each app would have its own database, login and password. The doco that came with the app would instruct you on how to set those up.

A bit of background reading here:
HowTo: Configure a Linux Apache Web Server on openSUSE (including SSI and CGI)

Allright, I managed to get Apache working. All I had to do was go to YAST -> Network Services -> HTTP Server and configure everything there from a very comfortable and easy wizard. Now my web page can be accessed and entered.

I still have a problem however: I don’t know how to get PHP and MySQL working as well. How do I setup MySQL now so it connects with Apache and PHP and setup its databases, users, etc? Also I do need to know where MySQL keeps its storage cuz I sometimes have to work around there with these files manually.

No, you really don’t need to touch MySQL’s database files. What would you do with files like user.frm, user.MYD, user.MYI, etc? MySQL provides you with utilities to handle those. Unless you are doing a plain backup, and even then, a mysqldump is better, especially if the DB is constantly modified. Buf FYI, they are in /var/lib/mysql.

As mentioned before, PHP connects to MySQL by calling functions from the php5-mysql connector and libmysql library, which you will get by loading the php5-mysql package. It’s just a matter of programming. Each web app will have its ways of setting up the connection.

Php can be installed using the software management tool in Yast. I installed it–along with the php-mysql and various other extensions by simply searching on the term php.

It’s plain backups that I need to do, yes. I have experimented with dumps and other types of integrated MySQL backup systems and even lost a database basing myself on these, so plain backups are the only things I ever go with nowadays.

Anyway, if on the installation of LAMP server MySQL and PHP are already linked, how do I make databases, create users and give each permissions over which database I wish and everything else I must do?

I already have it installed with LAMP server, I just need to configure everything now.

Well, personally I use the mysql module in webmin to do that sort of thing but I know that’s not for everyone. A popular tool for configuring databases, tables, users, etc. in mysql is a tool called phpmyadmin. Or if you’re handy from the command line you can do that sort of thing with the mysql client. Just open a terminal and type mysql at the command line.

Tried that as root but it gives me this error:

linux-wdzw:~ # mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
linux-wdzw:~ #

Also, /var/lib/mysql appears to be a completely empty folder.

Humm, odd. What output do you get if (as root) you do:


/sbin/service mysql restart