User:Dan Nessett/Sandboxes/Sandbox 4: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Dan Nessett
(l)
No edit summary
 
(48 intermediate revisions by one other user not shown)
Line 1: Line 1:
==Installing postgres==
{{AccountNotLive}}
<math>\pi=\frac{3}{4} \sqrt{3}+24 \int_0^{1/4}{\sqrt{x-x^2}dx}</math>


The version of postgres we want is not available through the normal CentOS software repositories. So, we have to modify the repository information to direct yum (the CentOS software installation utility) to install the correct version. (Note: these instructions are based on those given at [http://www.yetanotherguide.com/postgres-83-on-centos  Yet Another Guide].
[[Hydrogen |<div style="filter:alpha(opacity=99);
-moz-opacity:.99; opacity:.99;
width:6px;
height:9px;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
border-top:1px solid #fff;
border-right:1px solid #fff; background-color:#333">
</div> ]]


First find out what is the latest install package for postgres 8.3 (install packages for CentOS have the suffix '''rpm'''). Using a new tab or browser window, follow the link [http://yum.pgsqlrpms.org/reporpms/8.3 postgres rpms]. Three files should display in the browser window. One of these will have the name '''pgdg-centos-8.3-x.noarch.rpm''', where '''x''' will be a number, such as 6.  Now download the appropriate yum repository configuration by entering the following at a terminal command prompt (replacing the x in the file name with the integer just discovered):


<pre>cd /tmp
[[Hydrogen |<div style="-moz-opacity:.99; opacity:.99;width:6px;
sudo wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-x.noarch.rpm</pre>
height:9px;
border-bottom:1px solid #fff;
border-left:1px solid #fff;
border-top:1px solid #fff;
border-right:1px solid #fff; background-color:#333">
</div> ]]


Then install this information using the following command (again changing the x to the appropriate integer):
[[Helium |<div style="filter:alpha(opacity=20);
-moz-opacity:.2; opacity:.2;
width:6px;
height:9px;
border-bottom:1px solid #000;
border-left:1px solid #000;
border-top:1px solid #888;
border-right:1px solid #888; background-color:#2fc900"><font style="size:0px;"></font>
</div> ]]


<pre>sudo chmod +x pgdg-centos-8.3-x.noarch.rpm
[[Helium |<div style="-moz-opacity:.2; opacity:.2;
sudo rpm -ivf pgdg-centos-8.3-x.noarch.rpm</pre>
width:6px;
height:9px;
border-bottom:1px solid #000;
border-left:1px solid #000;
border-top:1px solid #888;
border-right:1px solid #888; background-color:#2fc900"><font style="size:0px;"></font>
</div> ]]


If you are working on a CentOS installation on which some other software has already been installed, it is possible that other repositories are indicated in the yum configuration files that may interfere with the installation of postgres 8.3. You can determine this as folows. Execute the following commands:
Test.


<pre>cd /etc/yum.repos.d
Another Test
sudo gedit CentOS-base.repo &</pre>
 
If this file is non-empty, then do the following. (If the file is empty, simply close it without making any changes). There are sections in the configuration file each headed by a word in square brackets. If there are two sections labeled '''<nowiki>[base]</nowiki>''' and '''<nowiki>[updates]</nowiki>''' then at the bottom of those sections add the line:
 
<pre>exclude=postgresql*</pre>
 
Click on the '''Save''' button at the top of the edit window and close it.
 
Now execute the following commands:
 
<pre>sudo yum install postgresql
sudo yum install postgresql-server</pre>
 
For each command a bunch of text is displayed followed by a line that specifies the total download size. The next line is a prompt: '''Is this ok [y/N]:'''. You must type '''y'''. The default is '''N''', which (of course) means no and taking it will abort the install.
 
The install of postgres on CentOS does not initialize the directory that postgres uses to store database information. So, the next step is to do this. Execute the following commands:
 
<pre>sudo /etc/rc.d/init.d/postgresql initdb</pre>
 
Installing postgres doesn't mean the server starts up when the system boots. We have to configure the system to do that. First, check that '''chkconfig''' is in your execution path. At a command prompt enter:
 
<pre>chkconfig</pre>
 
If the error '''bash: chkconfig: command not found''' is returned, you will have to add /sbin to $PATH. This requires editing .bash_profile:
 
<pre>gedit .bash_profile &</pre>
 
In the edit window there should be a line starting with '''$PATH'''. At the end of this line add ''':/sbin''' (don't forget the colon at the beginning of this text and there should be no space between the colon and the rest of the line). Then save the edit,  exit the editor and type:
 
<pre>source .bash_profile
chkconfig</pre>
 
This should result in an error message about usage. When '''chkconfig''' is working, enter the following commands:
 
<pre>sudo chkconfig --add postgresql
sudo chkconfig postgresql on</pre>
 
Now reboot you system and when that completes open a terminal window. Type:
 
<pre>su
su postgres
psql</pre>
 
A welcome message should display, followed by hints on psql commands and then the prompt '''postgres=#'''. At this prompt type ''\q''.
 
There is one more thing we have to do before proceeding. In CentOS, the default trust model is '''ident''' based. This causes problems when configuring the postgres databases using pgAdmin III. So, we need to make one change to the postgres configuration file. Execute the following commands at a terminal window prompt:
 
<pre>cd /var/lib/pgsql/data
sudo gedit pg_hba.conf &</pre>
 
An edit window should appear. Scroll to the end of the file and find the entry with the comment '''# IPv4 local connections:'''. The next entry controls access when connections to the postgres server comes from the local host. Copy it and paste a copy below the current entry. Now comment out the original entry and change the last part of the copied line from '''ident sameuser''' to '''trust'''. The entry should now look like the following (you can simply copy and paste the following text over the existing entry to save time):
 
<pre># IPv4 local connections:
#host    all        all        127.0.0.1/32          ident sameuser
host    all        all        127.0.0.1/32          trust
</pre>
 
Save the file and exit the editor. Now restart the postgres server with the following command:
 
<pre>/etc/rc.d/init.d/postgresql restart</pre>
 
This change allows you to manipulate postgres through pgAdmin III without changing your CentOS user identity using '''su''' or '''sudo'''. The install of postgres is now complete.
 
==Installing apache2 and PHP==
 
Installing postgres is a lot of work. Fortunately, installing the other two components of the LAPP stack takes much less effort. First, we will install the apache2 web server. In a terminal window execute the following command:
 
<pre>sudo yum install httpd</pre>
 
Follow the normal install procedure by answering '''y''' to the question. You may be prompted with a question whether it is OK to import a GPG key. If so, answer '''y'''.
 
After the install completes, execute the following two commands:
 
<pre>sudo chkconfig --levels 235 httpd on
sudo /etc/init.d/httpd start</pre>
 
Then in your favorite browser, create a new tab or window and in the URL field type: '''http://localhost'''. An apache2 test page should display. If so, apache2 is installed. If not, then make sure you correctly executed all of the commands specified above.
 
To install PHP5 is even simpler. Execute the following commands:
 
<pre>sudo yum install php
sudo yum install mod_php</pre>
 
If you want to test that PHP5 is working properly, cd to /var/www/html and execute:
 
<pre>sudo gedit phpinfo.php</pre>
 
When the empty edit window appears, enter the following information:
 
<pre>
<?php
phpinfo();
?>
</pre>
 
Save the edit and then execute:
 
<pre>sudo /etc/init.d/httpd restart</pre>
 
This command restarts the apache2 server so it is aware that PHP5 is available. Now in a browser create a new tab or window and in the URL field type:
 
<pre>http://localhost/phpinfo.php</pre>
 
A page containing information about the PHP5 installation should appear, followed by information about installed PHP5 extensions.
 
At this point, installation of the LAPP stack is complete. Return to the page on [[User:Dan_Nessett/Technical/How_to_set_up_a_CZ_clone#Configuring_the_LAPP_stack | How to set up a CZ Clone]] and continue with LAPP stack conguration. You may skip the first part of the Configure Apache2 section, since you have already tested that PHP5 is correctly working. (Furthermore, document root on CentOS is different than that on Ubuntu, so there are some differences in how to carry out this test).

Latest revision as of 02:39, 22 November 2023


The account of this former contributor was not re-activated after the server upgrade of March 2022.



Test.

Another Test