CentOS and Apache/PHP/MySQL

  • camperjohn
  • Guru
  • Guru
  • User avatar
  • Posts: 1127
  • Loc: San Diego

Post 3+ Months Ago

I am a complete Linux newb. I admit my failures. But I figure I need to start someplace, so last week I installed CentOS on an extra machine here so I can learn something. (http://www.centos.org)

If you can answer any of these questions, much appriciated.

1) When I installed CentOS, it gave me options to have web publishing software, and MySQL. I assumed this would mean it would install Mysql and Apache for me, but I can't find it in the usr/local directory.

My question is: Does a fresh install of CentOS also include an install of Apache/MySQL/PHP? Where would it be if it isn't in the usr/local directory?

2) Since I cannot find Apache I assume it isnt installed, so I have downloaded it, but don't know how to get it from my PC machine to my CentOS machine to compile and install it? I was using the following tutorial on installing Apache/MySQL/PHP

http://www.hostlibrary.com/installing_a ... p_on_linux

My question is: How do I transfer files from my Windwos PC to my CentOS box?

3) Is there a more complete tutorial on installing Apache/MySQL/PHP that I haven't found?

4) After that, I will have questions on installing MySQL and PHP...

My goal is to learn how to get a website up and running, without using Cpanel.

john at mccarthy.net
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

http://www.lamphowto.com/
  • camperjohn
  • Guru
  • Guru
  • User avatar
  • Posts: 1127
  • Loc: San Diego

Post 3+ Months Ago

Woohoo! You rock Anarch, thanks. That page is really useful! I didn't find it in my Google Search.

I am actually surprized how fast I am moving forward with this considering I am a newb.
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

The author of that tutorial is an idiot, and I'll tell anyone as much. You NEVER, NEVER, NEVER install core package from source on any RPM based distribution - especially not on a server! Did I say "never" enough times? If you install packages from source on an RPM based distribution, you're going to have a heck of a time keeping that system up to date. For instance, if you ever decide to install the php-gd package through yum, yum will happily install new versions of GD, PHP and Apache, overwriting anything you may already have installed because it has no idea that you've already installed these. If you want to install packages from source, I'd recommend you use a different distribution such as Slackware or Gentoo.

To get everything that page is talking about under CentOS:
vi /etc/yum.repos.d/CentOS-Base.repo
hit "i"
find the line under [CentOSPlus] that reads:
Code: [ Select ]
enabled = 0

change it to
Code: [ Select ]
enabled = 1


Then do:
Code: [ Select ]
yum install php php-mysql mysql-server php-gd postgres ImageMagick ImageMagick-devel

php-gd and Imagemagick are used for creating dynamic images which you'll want later on if not now. Postgres is a more powerful database than MySQL which you'll probably also want later on if not now.

That's it, those two steps will give you a fully functional, ssl enabled, web server with PHP support. Your DocumentRoot is in /var/www/html and your logs are in /var/log/httpd/. What's more, you running "yum -y update" won't totally screw over your system.

If you've already installed any of these packages following those "instructions", I strongly suggest you uninstall them and do it right.

EOL
  • camperjohn
  • Guru
  • Guru
  • User avatar
  • Posts: 1127
  • Loc: San Diego

Post 3+ Months Ago

Is ImageMagik the same as the php Graphics library?

I reinstalled CentOS after I screwed up something. I set the enabled to 1, and am doing the yum update right now.
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

ImageMagick is a graphics library that php can utilize. there's also the GD library.
  • camperjohn
  • Guru
  • Guru
  • User avatar
  • Posts: 1127
  • Loc: San Diego

Post 3+ Months Ago

Cool. I assume I can install the GD library later once I get this up and running. I am more familiar with the GD libaray, all my tools work with that. I guess I use yum for that too, I can figure it out I am stupid but not dumb...or vice versa..I keep forgetting.

Anyway, I installed all that yum line (install php php-mysql...), and everything went fine.

Now I have some issues with "this is normal" on my new install.

1) Is it normal that apache is not started once the system reboots? I can figure out how to add it to the list of things to run on bootup, but I am not sure if it is normal that it isn't automatically run once I did the yum install.

2) Is it normal when I run "mysql" that I get the infamous ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2). I looked on Google, found a 1000 pages where others have had that. I can figure it out, but if you have 2 cents of advice it's always helpful...hint hint.

3) Do you suggest piggyback my DNS zone on top of my commercial server (with has Cpanel), and point my websites it to this new server, or do you suggest I actually add a DNS zone to this server, then create users etc?

4) Are there tools to create user accounts for websites? Or do I manually 1) create a new user, 2) manually create public_html folders and 3) manually edit the apache config file? etc?

I have so many questions, and I admit I am burnt out on reading the manuals. But it's all going well.
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

1). To start services automatically:
Code: [ Select ]
/etc/init.d/httpd restart
/sbin/chkconfig httpd --level 2345 on
  1. /etc/init.d/httpd restart
  2. /sbin/chkconfig httpd --level 2345 on

The first line (re)starts the service. chkconfig sets the service to run (or not) when the system enters a given runlevel (or boots). Change httpd to the service name (the name of the init script in /etc/init.d/), 2345 are the runlevels to start it in (2,3,4 and 5) and "on" tells it to start ("off" to stop it from starting)

2). /etc/init.d/mysqld restart. 9 times out of 10, you see this because mysql isn't running

3). You don't need to worry about a nameserver on a web server, though I'll usually install a caching only one. These are two different services which don't have anything to do with each other (on this level). If you're already using some sort of control panel which gives you easy access to add, edit and drop zones, just keep using that.

4). There are quite a few packages that do this, though I don't use any of them personally so can't say if one is better than the other. If you're going to be selling hosting, you're going to want something like this. Because my needs are meager, I simply create a directory structure under /etc/skel (this directory is copied to new user directories when you add users), then write a script that calls useradd and creates a virtual host file for the web server. Because I'm so paranoid, if I didn't actually know the people on my server, I'd probably use something like Xen to make sure they stayed in their own areas too.

The single yum command I posted earlier should install GD as the php-gd package is dependant upon it. If it didn't install it for some reason, you can do "yum install gd gd-devel"
  • camperjohn
  • Guru
  • Guru
  • User avatar
  • Posts: 1127
  • Loc: San Diego

Post 3+ Months Ago

Ok I did that and everything is working. Time to party!

I added this to get mysql running on reboot:

/sbin/chkconfig mysqld --level 2345 on

Then rebooted, and mysql seems to be running when I reboot. I hope that is ok. I just copied and pasted the level numbers, not really knowing what they do.

My web server is running when I look at the localhost, and mysql is running too. Thanks so much!

Next:

I am the only one that is going to be using this server. I don't need to get fancy in having users that can't access other directories since I am the only user.

So I just need to figure out how to add a user, website, and FTP access to the directory. I will experiment with the /etc/skel direcotry as you mentioned. From here I think I will be all good - I am well on my way. (famous last words)

JM
  • this213
  • Guru
  • Guru
  • User avatar
  • Posts: 1260
  • Loc: ./

Post 3+ Months Ago

I realize this has gotten old, just thought I'd clarify that the "--level 2345" means runlevels 2,3,4 and 5.

A runlevel determines what starts when the machine is booted. When you boot into runlevel 1, only the core system files are loaded (something like Windows safe mode). Runlevel 2 is there if you want to create a custom runlevel (hardly ever used) as is runlevel 4 (never used). Runlevel 3 is what most servers boot to, it starts all of your services and other things required for a true multi-user environment. Runlevel 5 is for starting a graphical interface (Xorg) and this is what most desktop systems boot to.

chkconfig adds and removes (on or off) services from the various runlevels.
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

lol
way to be thorough :D
  • dajohnso
  • Born
  • Born
  • dajohnso
  • Posts: 1

Post 3+ Months Ago

I know this post is kind old. I did everything here and I still cant get mysql to be usable from within php. I can see that when I do a phpinfo() that PHP was compiled --without-mysql, how do I re-enable it and get it to be included? I see many messages from people with the same issue and havent seen any solutions.
  • AnarchY SI
  • Web Master
  • Web Master
  • User avatar
  • Posts: 2521
  • Loc: /usr/src/MI

Post 3+ Months Ago

how does
Code: [ Select ]
yum install php-mysql
treat ya?
  • MotiveForce
  • Born
  • Born
  • MotiveForce
  • Posts: 2

Post 3+ Months Ago

Same problem here. CentOS 5.3

php.x86_64 is installed, so is php-mysql.x86_64 (both through yum). The phpinfo() shows that it was compiled "--without-mysql" and I can't seem to change this. It should be noted that I used the same commands (except for the .x86_64 extensions) to install this as I used on a similar server a week before (the only difference in the server was that one was 32 bit architecture so I was installing the .i386 versions).

Any insights on how to change this?
  • MotiveForce
  • Born
  • Born
  • MotiveForce
  • Posts: 2

Post 3+ Months Ago

Solved my incarnation of the problem.

In my case I was using a php.ini from a 32 bit architecture on the 64 bit server. The problem was caused by the fact that 64 bit architectures store their modules in /usr/lib64/php/modules instead of /usr/lib/php/modules. In the php.ini, the "extension_dir" must be updated accordingly.

Post Information

  • Total Posts in this topic: 15 posts
  • Users browsing this forum: No registered users and 47 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.