Created
Updated
Viewed
222.5k times

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.

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

  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 isn't 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? My question is: How do I transfer files from my Windows 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.

add a comment
1

6 Replies

  • Votes
  • Oldest
  • Latest
Replied
Updated

http://www.lamphowto.com/

  • 0
    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. — camperjohn
add a comment
0
Replied
Updated

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:

enabled = 0

change it to

enabled = 1

Then do:

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.

  • 0
    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. — camperjohn
  • 0
    ImageMagick is a graphics library that PHP can utilize. there's also the GD library. — this213
add a comment
1
Replied
Updated

Cool. I assume I can install the GD library later once I get this up and running. I am more familiar with the GD library, 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, and found 1000 pages where others have had that. I can figure it out, but if you have 2 cents of advice it's always helpful.

  3. Do you suggest piggybacking my DNS zone on top of my commercial server (which has Cpanel), and pointing my websites 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:

    • create a new user
    • create public_html folders
    • manually edit the apache config files
    • etc

I have so many questions, and I admit I am burnt out on reading the manuals. But it's all going well.

add a comment
0
Replied
Updated
  1. To start services automatically:

    /etc/init.d/httpd restart
    /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 that 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 dependent upon it. If it didn't install for some reason, you can do:

yum install gd gd-devel
add a comment
0
Replied
Updated

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 directory as you mentioned. From here I think I will be all good - I am well on my way. (famous last words)

  • 0
    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. — this213
add a comment
0
Replied
Updated

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.

  • 0
    Try: yum install php-mysql. That should do the trick! — AnarchY SI
  • 0
    Same problem here. CentOS 5.3 PHP.x86_64 is installed, and 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
  • 0
    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. — MotiveForce
add a comment
0