Installing Apache, Php, mysql on ubuntu server
I am new to the linux distribution so if anyone could kinnda guide me through the process would be great..
Correct me if I am wrong do I need to install apache server on ubuntu server or does ubuntu server comes with apache?
If yes, how can i install apache, php and mysql using putty as my SSH?
Any help would be appreciated
Thanks
19 Replies
follow that. skip parts you don't need.
I followed along, and got no errors, but i cannot load my site. if i ping the server, i get a response, but no site.
my site is silliemunkie.com
thanks,
Jason
Can your stop then start your apache or do you get errors?
I rebuilt the server, and started from the beginning. It seems the problem was I deleted something from the sites-available/default
I followed the rest of the tutorial, and got a site running on silliemunkie.com
I am having trouble creating a second vHost. I went through the tutorial a second time, and created the same directories, and files. when i run a2ensite for the new domain, and then reload, i get a fail error. then my original site won't load. if i run a2dissite for the new domain and reload the original domain loads again.
Is there a configuration that i need to make to allow both vhosts to run?
thank you,
Jason
…
sudo nano sites-available/default
Delete the ‘NameVirtualHost *’ line and change the next ‘VirtualHost’ line so the file begins like this:
DocumentRoot /var/www/
if so open up you apache error log and post it for me. /etc/apache2/error.log
here are the entries in the error log
[Thu Dec 18 21:40:12 2008] [notice] Graceful restart requested, doing restart
(2)No such file or directory: apache2: could not open error log file /var/www/v$
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/v$
Unable to open logs
[Thu Dec 18 21:40:42 2008] [warn] pid file /var/run/apache2.pid overwritten – $
[Thu Dec 18 21:40:42 2008] [notice] Apache/2.2.9 (Ubuntu) configured – resumin$
[Thu Dec 18 21:43:19 2008] [notice] Graceful restart requested, doing restart
[Thu Dec 18 21:43:19 2008] [notice] Apache/2.2.9 (Ubuntu) configured – resumin$
[Thu Dec 18 21:43:32 2008] [notice] Graceful restart requested, doing restart
(2)No such file or directory: apache2: could not open error log file /var/www/v$
Unable to open logs
(2)No such file or directory: apache2: could not open error log file /var/www/v$
Unable to open logs
[Thu Dec 18 21:44:34 2008] [warn] pid file /var/run/apache2.pid overwritten – $
[Thu Dec 18 21:44:34 2008] [notice] Apache/2.2.9 (Ubuntu) configured – resumin$
[Thu Dec 18 22:05:43 2008] [error] [client 199.217.156.114] File does not exist$
[Thu Dec 18 22:05:46 2008] [error] [client 199.217.156.114] File does not exist$
[Thu Dec 18 22:30:34 2008] [error] [client 221.192.199.36] File does not exist:$
thanks,
Jason
Custom Virtual Hosts
We’ve set up the basics and now we’re ready to add our own virtual hosts so we can start to serve our domains.
Let’s go ahead and create the vhost file for domain.com:
nano /etc/apache2/sites-available/domain.com
The contents need to look like this:
Place any notes or comments you have here
It will make any customisation easier to understand in the weeks to come
domain: domain1.com
public: /var/www/vhosts/domain.com/domain.com/
ServerAdmin
ServerName domain.com
ServerAlias
Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /var/www/vhosts/domain.com/htdocs
****# Custom log file locations
LogLevel warn
ErrorLog /var/www/vhosts/domain.com/log/error.log
CustomLog /var/www/vhosts/domain.com/log/access.log combined****
here is the default from sites-available/default
DocumentRoot /var/www/
AllowOverride None
AllowOverride None
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog /var/log/apache2/error.log
Possible values include: debug, info, notice, warn, error, crit,
alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
here is the code from sites-available/silliemunkie.com
Place any notes or comments you have here
It will make any customisation easier to understand in the weeks to come
domain: domain1.com
public: /var/www/vhosts/domain.com/domain.com/
ServerAdmin
ServerName silliemunkie.com
ServerAlias
Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /var/www/vhosts/silliemunkie.com/htdocs
Custom log file locations
LogLevel warn
ErrorLog /var/www/vhosts/domain.com/log/error.log
CustomLog /var/www/vhosts/domain.com/log/access.log combined
anything look out of order?
thanks,
Jason
silliemunkie.com
thecatatemysourcecode.com
thanks,
Jason
thanks for your help,
Jason
NameVirtualHost *:80
<ifmodule mod_ssl.c="">NameVirtualHost *:443</ifmodule>
If I didn't add that line, I got the following error when reloading Apache2:
[warn] default VirtualHost overlap on port 80, the first has precedence
Try the above, and see if that works.
I post this page because I think it's a complete guide on an application (WordPress) setup, so it's very helpful for newcomers. And, one day, you may be interested in Nginx
please be noted, this page is written for SliceHost, but really it can be used on any Ubuntu server.
@zhouxiaohu:
maybe a little off topic. This page is about Nginx, mysql, php and wordpress
http://www.mensk.com/webmaster-toolbox/ … wordpress/">http://www.mensk.com/webmaster-toolbox/perfect-ubuntu-hardy-nginx-mysql5-php5-wordpress/ I post this page because I think it's a complete guide on an application (WordPress) setup, so it's very helpful for newcomers. And, one day, you may be interested in Nginx
:-) please be noted, this page is written for SliceHost, but really it can be used on any Ubuntu server.
To add some extra confusion, in my signature there's a guide for Lighttpd instead of Apache and nginx, in combination with PHP/MySQL and mail via Google apps for domain (with msmtp)
(1) I began with step 8
(2) AppArmor did not seem to be installed by default.
(3) Step 15 asks you to telnet to test an install. My results differed slightly:
250-AUTH PLAIN NTLM LOGIN DIGEST-MD5 CRAM-MD5
instead of
250-AUTH PLAIN LOGIN
(4) phpMyAdmin was not included in guide, but I installed it before step 22 (ISPConfig installation). At this point, the phpMyAdmin index page would show text (due to php being disabled globally I assume) and visiting the site
(5) The installation of ISPConfig 3 seemed to duplicate a lot of the packages I had already installed following the guide. I left those out. I did not install suPHP.
(6) During the installation of ISPConfig I landed at this prompt: > ISPConfig Port [8080]:
Without finding any further instructions I quit and was greeted with:
> Installation terminated by user.
This was not my intention. If there's further configuration to do I'm unsure how to go about it.
(7) I made the Apache fixes as instructed for ISPConfig, then uncommented the lines in /etc/mime.types for PHP, assuming this would let me run php files (such as phpmyadmin). However… things appear to be fubar'd. I get a nice 404 visiting the site now, and restarting Apache gives me this warning:
> [warn]NameVirtualHost *:80 has no VirtualHosts
Is the installation salvageable, or do I start from scratch? Any help is appreciated.
> Correct me if I am wrong do I need to install apache server on ubuntu server or does ubuntu server comes with apache?
You might want to install lighttpd instead of apache, depending on how much memory your linode account has, as it uses less RAM.
Steps
1. Firewall
# apt-get install arno-iptables-firewall
The installation will prompt you for the ports to enabled. Ports you may want to enable:
* 7 echo (for ping)
22 ssh
25 smtp
80 http
110 pop3
143 Imap
443 https
993 Imap over ssl/tls
995 pop3 over ssl/tls
3306 mysql
2. Create a script, say, ~/firewall-stop to flush all iptables rules (just in case you need it).
#!/bin/bash
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# sudo chmod u+x ~/firewall-stop
You can execute it
# sudo ~/firewall-stop
if you get locked out, from the linode console java applet (without needing to ssh).
3. Install lighttpd
# aptitude install lighttpd
4. Either create a file uploads directory for lighttpd or set uploadtmpdir in php.ini and create the directory, setting the group to www-data (chgrp) and setting the permissions appropriately. This step is not needed as of lighttpd 1.4.19 and above.
# mkdir /var/cache/lighttpd/uploads
# chgrp –R www-data /var/cache/lighttpd/uploads
# chmod g+rw /var/cache/lighttpd/uploads
5. Enable fastcig and auth modules
# lighty-enable-mod fastcgi auth
6. Install php and phpmyadmin
# aptitude install php-cgi php5-cli php-db php-pear php5-gd php5-mcrypt php5-mysql php5-xcache phpmyadmin
7. Create the ‘recommended’ php.ini
# cp /usr/share/doc/php5-common/examples/php.ini-recommended /etc/php5/cgi/php.ini
8. Configure fast-cgi
fastcgi.server =
(
".php" => (( "bin-path" => "/usr/bin/php-cgi -c /etc/php5/cgi/php.ini",
"socket" => "/tmp/php.socket",
"max-procs" => 1,
"idle-timeout" => 20,
"bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "10000" ),
"bin-copy-environment" => ( "PATH", "SHELL", "USER" ),
"broken-scriptfilename" => "enable"
))
)
See Lighttpd and PHP configuration
9. Install php op code cacher xcache.
# aptitude install php5-xcache
Encrypt and set the password for the administration page for xcache. See How to Install XCache Administration Page
substituting your actuall password for "password". Then edit /etc/php5/conf.d/xcache.ini and change the lines
xcache.admin.user = "mOo"
xcache.admin.pass = "5f4dcc3b5aa765d61d8327deb882cf99"
using a user name of your choice and the encrypted password generate from the script above.
10. Set up any virtual hosts for lighttpd (If you have many, then you would want to either enable simple_vhost or use the built-in evhost.path-pattern setting in /etc/lighttpd/lighttpd.conf).
Sampe virtual hosts
# sudo nano /etc/lighttpd/lighttpd.conf
$HTTP["host"] =~ "^(www\.)?sampledomain1.com$" {
server.document-root = "/usr/share/phpgedview/"
}
$HTTP["host"] =~ "^(www\.)?someblog.com$" {
server.document-root = "/usr/share/wordpress/"
}
$HTTP["host"] =~ "^(www\.)?sampledomain3.com$" {
server.document-root = "/var/www/sampledomain3.com/"
}
# /etc/init.d/lighttpd force-reload.
=~ signifies a regular expresssion syntax is being used.
Include any aliases in a separate file.
# sudo nano /etc/lighttpd/myconf.conf
alias.url += ( "/xcache-admin" => "/usr/share/xcache/admin",
"/aptitude" => "/usr/share/doc/aptitude/html/en",
"/apt-doc" => "/usr/share/doc/apt-doc")
Edit /etc/lighttpd/lighttpd.conf and add the line
include "myconf.conf"
after the virtual host entries.
11. Set up users and password for any password-protected lighttpd directories. See this guide: Lighttpd setup a password protected directory
12. restart lighttpd
# /etc/init.d/lighttpd restart